블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
  • total
  • today
  • yesterday

Category

'Mac OS X'에 해당되는 글 3건

  1. 2011.10.31 iPhone 기본 과정 week #1 day#1
  2. 2010.04.14 OpenCV 2.1 설치 on Mac OS X
  3. 2008.06.17 bluetooth on Mac
2011. 10. 31. 11:22

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2010. 4. 14. 16:40 Computer Vision
매킨토시에서 OpenCV 버전 2로 업그레이드
http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port

현재 연구실 맥미니 사양 (Leopard)
 System Version:    Mac OS X 10.5.8 (9L30)
 Kernel Version:    Darwin 9.8.0


0. MacPorts 업그레이드


1) MacPorts 포트 정보 확인

$ port info macports

MacPorts @1.8.2 (sysutils)
Variants:             darwin_10, darwin_7, darwin_8, darwin_8_i386,
                      darwin_8_powerpc, darwin_9, darwin_9_i386,
                      darwin_9_powerpc, universal

Description:          MacPorts provides the infrastructure that allows easy
                      installation and management of freely available software
                      on Mac OS X 10.4 or newer systems.
Homepage:             http://www.macports.org/

Platforms:            darwin, freebsd
License:              unknown
Maintainers:          macports-mgr@lists.macosforge.org


2) 기존 MacPorts 버전 확인 및 새 버전 다운로드

$ sudo port selfupdate

MacPorts base version 1.710 installed
Downloaded MacPorts base version 1.800

Installing new MacPorts release in /opt/local as root:admin - TCL-PACKAGE in /Library/Tcl; Permissions: 0755


3) MacPorts 새 버전 설치

$ sudo port -v selfupdate
Password:



4) OpenCV 포트 확인

$ port search opencv

opencv @2.0.0 (graphics, science)
    Intel(R) Open Source Computer Vision Library

이 포트를 설치하면 64 비트 OpenCV 2.0이 된다고 하는데, 이 말은 눈표범에 해당하는 게 아닌가 한다. 그냥 표범인 지금 맥미니는 (확실친 않지만) 32비트인 것으로 확인되었다.  어쨌든, 무엇보다 snow leopard 스노우 러퍼드 (Mac OS X 10.6) 사용자는 quicktime (iSight)과 carbon (GUI) support를 포기해야 한다고 되어 있다. 나는 그냥 러퍼드 (Mac OS X 10.5)이지만, 왠지 불안하므로 맥포트로 OpenCV를 업그레이드 하는 방법은 일단 제외하기로 한다. 대신, 공식 위키 안내대로 CMake를 이용하여 OpenCV 새 버전을 설치하기로 한다.


1. CMake를 사용하여 OpenCV 설치하기

1) subversion 설치

 맥포트로 subversion을 다운로드, 설치한다.

$ sudo port install subversion

subversion ( http://en.wikipedia.org/wiki/Subversion_%28software%29 )은 예전 내 파워북에 설치해서 써 본 경험이 있기는 하다. 그때도 이렇게 오래 걸렸었나...



2) CMake 설치

$ sudo port install cmake



cf. CMake?
http://en.wikipedia.org/wiki/CMake
http://www.cmake.org/


3) OpenCV source code 다운로드

svn co https://code.ros.org/svn/opencv/trunk/opencv

에러 메시지가 나와서 기존의 "opencv" 폴더명을 바꾸고 다시 명령을 줬더니, 새로 "opencv" 폴더와 다음 파일들이 생성된다.


마지막에 "Checked out revision 3024."라는 메시지가 나왔다.
https://code.ros.org/trac/opencv/changeset/3024


4) Make 파일 만들기

생성된 opencv 폴더에 들어가서 CMake로 유닉스 메이크 파일을 생성한다. (옵션을 추가할 수 있다. 공식 위키 안내 참조)

$ cd opencv
$ sudo cmake -G "Unix Makefiles"




5) 빌드하기


$ sudo make -j8





$ sudo make install




6) 확인

-1) 파인더 창에서 보이지 않는 디렉토리는 "/usr/local/" 파인더 메뉴의 Go > Go to folder에서 직접 입력하여 들어갈 수 있다.
-2) OpenCV 새 버전을 MacPorts로 설치하지 않았으므로, 맥포츠 명령어 "port installed"로 설치된 포트들을 검색하면 이전에 맥포츠로 설치한 1.0.0 버전만 확인할 수 있다. (이전에 맥포츠로 설치한 1.0.0 버전은 "/opt/local/var/macports/software/opencv/1.0.0_0/opt/local/lib"에 들어 있다.)



2. Xcode에서 OpenCV 라이브러리 사용하기

공식 위키의 안내문:

Using the OpenCV libraries in an Xcode OS X project

These instructions were written for Xcode 3.1.x

  • Create a new XCode project using the Command Line Utility/Standard Tool template
  • Select Project -> Edit Project Settings

  • Set Configuration to All Configurations
  • In the Architectures section, double-click Valid Architectures and remove all the PPC architectures
  • In the Search Paths section set Header Search Paths to /usr/local/include/opencv
  • Close the Project Info window
  • Select Project -> New Group and create a group called OpenCV Frameworks

  • With the new group selected, select Project -> Add to Project…

  • Press the "/" key to get the Go to the folder prompt
  • Enter /usr/local/lib
  • Select libcxcore.dylib, libcvaux.dylib, libcv.dylib, libhighgui.dylib, and libml.dylib.

  • Click Add
  • Uncheck Copy Items… and click Add

Now you should be able to include the OpenCV libraries, compile, and run your project


1) 빌드 환경 설정
 
XCode 메뉴에서 Project -> Edit Project Settings를 클릭하면 Project Info 창이 뜬다. Build 탭에 들어가서
-1) Configuration 설정이 "Active (Debug)"로 되어 있는 것을 "All Configurations"로 변경한다.
-2) Architectures에서 "Valid Architectures"를 더블 클릭하여 목록이 뜨면 그 중 PPC 아케텍처에 해당하는 것들을 모두 삭제한다.
-3) Search Paths에서 Header Search Paths를 " /usr/local/include/opencv  "로 설정한다.


2) OpenCV  프레임웍스를 프로젝트에 추가

-1) Project Info 창을 닫고, 프로젝트에 "New Group"을 추가하여 "OpenCV Frameworks"라 명명한다.
-2) 이 그룹을 선택한 상태로 인용부 설명대로 usr/local/lib에 위치한 5개의 라이브러리 파일을 추가한다.




3. Xcode 프로젝트 테스트...ing




/* Test: video capturing from a camera
 camera: Logitech QuickCam Pro 4000
 */

//#include <OpenCV/OpenCV.h>
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;

int main()
{
    IplImage* image = 0; // image
    // initialize capture from a camera
    CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0
    cvNamedWindow("camera");
   
    while(1) {
//        printf("bbbbbbbbbbbbbb");
        if ( !cvGrabFrame(capture) ){
            printf("Could not grab a frame\n\7");
            exit(0);
        }
        else {
            printf("ccccccccccccccccccccc");
            cvGrabFrame( capture ); // capture a frame           
            image = cvRetrieveFrame(capture); // retrieve the caputred frame
           
            cout << image->width << "   " << image->height << endl;
           
            cvShowImage( "camera", image );
           
            if( cvWaitKey(10) >= 0 )
                break;
        }
    }
   
    cvReleaseCapture( &capture ); // release the capture source
    cvDestroyWindow( "camera" );
   
    return 0;
   
}




[Session started at 2010-04-15 01:11:16 +0900.]
2010-04-15 01:11:22.273 opencv2test01[1192:7f23] *** _NSAutoreleaseNoPool(): Object 0xc5f0d0 of class NSThread autoreleased with no pool in place - just leaking
Stack: (0x9143bf4f 0x91348432 0x9134e1a4 0xa260db7 0xa265e9a 0xa2649d3 0xa268cbd 0xa268130 0x90088935 0x93fcedb9 0x93e8f340 0x93e8f6ac 0x90088935 0x93fd117d 0x93e981c4 0x93e8f6ac 0x90088935 0x93fcfa81 0x93e7bc5d 0x93e80b2d 0x93e7b167 0x90088935 0x97ab89f8 0xdbf116 0xe6a016 0xe6a116 0x96917155 0x96917012)
ccccccccccccccccccccc320   240
ccccccccccccccccccccc320   240

[Session started at 2010-04-15 01:11:24 +0900.]
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/lym/Documents/VIP/2010/opencv2test01/build/Debug/opencv2test01', process 1192.
unable to read unknown load command 0x22
unable to read unknown load command 0x22
StartNextIsochRead-ReadIsochPipeAsync: Error: kIOReturnIsoTooOld - isochronous I/O request for distant past!

The Debugger Debugger is attaching to process(gdb)

실행 중지하면, (gdb) 대신 다음 메시지가 추가되며 프로그램 종료된다.

StartNextIsochRead-ReadIsochPipeAsync: Error: kIOReturnIsoTooOld - isochronous I/O request for distant past!
kill

The Debugger Debugger is attaching to process(gdb)




카메라에서 비디오 입력 받지 말고, 폴더에서 이미지 파일 읽으면

/* Test: video capturing from a camera
 camera: Logitech QuickCam Pro 4000
 */

//#include <OpenCV/OpenCV.h>
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;

int main()
{
    IplImage* image = 0; // image
    // initialize capture from a camera
    CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0
    cvNamedWindow("camera");
   
    while(1) {
//        printf("bbbbbbbbbbbbbb");
        if ( !cvGrabFrame(capture) ){
            printf("Could not grab a frame\n\7");
            exit(0);
        }
        else {
            printf("ccccccccccccccccccccc");
            cvGrabFrame( capture ); // capture a frame           
//            image = cvRetrieveFrame(capture); // retrieve the caputred frame
            image = cvLoadImage("werol.jpg"); // retrieve the caputred frame
           
            cout << image->width << "   " << image->height << endl;
           
            cvShowImage( "camera", image );
           
            if( cvWaitKey(10) >= 0 )
                break;
        }
    }
   
    cvReleaseCapture( &capture ); // release the capture source
    cvDestroyWindow( "camera" );
   
    return 0;
   
}



 




[Session started at 2010-04-15 01:26:38 +0900.]
usbConnectToCam-SetConfiguration: Error: kIOReturnNotResponding - device not responding
usbConnectToCam-SetConfiguration: Error: kIOReturnNotResponding - device not responding
usbConnectToCam-SetConfiguration: Error: kIOReturnNotResponding - device not responding
2010-04-15 01:26:43.235 opencv2test01[1333:7f23] *** _NSAutoreleaseNoPool(): Object 0xc56040 of class NSThread autoreleased with no pool in place - just leaking
Stack: (0x9143bf4f 0x91348432 0x9134e1a4 0xa260db7 0xa265e9a 0xa2649d3 0xa268cbd 0xa268130 0x90088935 0x93fcedb9 0x93e8f340 0x93e8f6ac 0x90088935 0x93fd117d 0x93e981c4 0x93e8f6ac 0x90088935 0x93fcfa81 0x93e7bc5d 0x93e80b2d 0x93e7b167 0x90088935 0x97ab89f8 0xdbf116 0xe6a016 0xe6a116 0x96917155 0x96917012)
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825





카메라 캡처 부분을 지우면

/* Test: video capturing from a camera
 camera: Logitech QuickCam Pro 4000
 */

//#include <OpenCV/OpenCV.h>
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;

int main()
{
    IplImage* image = 0; // image
    // initialize capture from a camera
    CvCapture* capture = cvCaptureFromCAM(0); // capture from video device #0
    cvNamedWindow("camera");
   
    while(1) {
//        printf("bbbbbbbbbbbbbb");
        if ( !cvGrabFrame(capture) ){
            printf("Could not grab a frame\n\7");
            exit(0);
        }
        else {
            printf("ccccccccccccccccccccc");
//            cvGrabFrame( capture ); // capture a frame           
//            image = cvRetrieveFrame(capture); // retrieve the caputred frame
            image = cvLoadImage("werol.jpg"); // retrieve the caputred frame
           
            cout << image->width << "   " << image->height << endl;
           
            cvShowImage( "camera", image );
           
            if( cvWaitKey(10) >= 0 )
                break;
        }
    }
   
    cvReleaseCapture( &capture ); // release the capture source
    cvDestroyWindow( "camera" );
   
    return 0;
   
}


[Session started at 2010-04-15 01:32:37 +0900.]
2010-04-15 01:32:43.091 opencv2test01[1377:7f23] *** _NSAutoreleaseNoPool(): Object 0xc50970 of class NSThread autoreleased with no pool in place - just leaking
Stack: (0x9143bf4f 0x91348432 0x9134e1a4 0xa260db7 0xa265e9a 0xa2649d3 0xa268cbd 0xa268130 0x90088935 0x93fcedb9 0x93e8f340 0x93e8f6ac 0x90088935 0x93fd117d 0x93e981c4 0x93e8f6ac 0x90088935 0x93fcfa81 0x93e7bc5d 0x93e80b2d 0x93e7b167 0x90088935 0x97ab89f8 0xdbf116 0xe6a016 0xe6a116 0x96917155 0x96917012)
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825
ccccccccccccccccccccc558   825




카메라 입력도 이미지 파일 로드도 없이 그냥 이미지를 하나 만들어 준 다음 디스플레이/저장해 보면,

/* Test: video capturing from a camera
 camera: Logitech QuickCam Pro 4000
 */

//#include <OpenCV/OpenCV.h>
#include <cv.h>
#include <highgui.h>
#include <iostream>
using namespace std;

int main()
{
   
    IplImage *iplImg = cvCreateImage(cvSize(500, 500), 8, 3);
    cvZero(iplImg);
    cvLine(iplImg, cvPoint(10, 10), cvPoint(300, 300), CV_RGB(255, 0, 0), 20);
    cvCircle(iplImg, cvPoint(400, 400), 40, CV_RGB(0, 255, 255), 5);
    cvNamedWindow("temp"); cvShowImage("temp", iplImg); cvSaveImage("temp.bmp", iplImg);  cvWaitKey();

    return 0;
}



실행 결과 "temp 창"에 뜨는 (비정상적인) 이미지와 파일로 (정상적으로) 저장되는 "temp.bmp"는 아래와 같다.

실행 폴더에 저장된 temp.bmp

"temp" 창 부분을 화면 캡처한 이미지





http://tech.groups.yahoo.com/group/OpenCV/message/70200


/opt/local/.........../opencv/1.0.0_0/opt/local/include/opencv/

..................../opt/local/lib






MacPorts로 설치했던  OpenCV 1.0.0 테스트

프로젝트 헤더 파일 경로 설정: /opt/local/include/opencv
프로젝트에 추가할 라이브러리 파일 위치:  /opt/local/lib






$ sudo port install opencv


posted by maetel
2008. 6. 17. 03:41 Hardware/network

'Hardware > network' 카테고리의 다른 글

RS232 data communication - MT9  (0) 2008.08.16
UART (범용 비동기화 송수신기)  (0) 2008.07.02
Video Tracking on PC  (0) 2007.08.11
posted by maetel