블로그 이미지
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

2011. 2. 10. 13:49 Computation
웹 업로드용으로 png가 부담스러워서 jpg로 바꾸고자 한다.

ref. 

터미널에서 다음과 같이 치면 된다고.

$$ defaults write com.apple.screencapture type jpg

물론 jpg 자리에 tiff나gif나 taga 등을 넣을 수 있다. 

그리고 재부팅해야 적용된단다.


cf.

'Computation' 카테고리의 다른 글

안드로이드 내부 구조 Day #3  (0) 2011.10.26
안드로이드 내부구조 #1  (0) 2011.10.24
Matthias Felleisen et al. <How to Design Programs>  (0) 2010.09.26
Octave on Mac OS X  (1) 2009.08.12
Cloud Computing 클라우드 컴퓨팅  (0) 2009.07.03
posted by maetel
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
2009. 8. 17. 20:15 Computer Vision
Oxford 대학  Active Vision Group에서 개발한
PTAM (Parallel Tracking and Mapping for Small AR Workspaces)
Questions? E-mail ptam@robots.ox.ac.uk
README

맥미니에서의 설치를 끝내고 (test log on mac) 테스트해 보면 성능이 좋지 않아 그대로 쓸 수는 없는 상태이다.


0. Video Input
The software requires a video camera with a wide-angle lens, capable of 640x480x30Hz video capture and an appropriate driver installation (which is supported by libCVD.)




1. Camera Parameters
 
CameraCalibrator를 실행시키면 calibrator_settings.cfg 파일을 읽어 온다.
여기에 gvars (PTAM 라이브러리를 지원하는 Gvars3 라이브러리) settings이 설정되어 있...어야 하는데 빈 채로 주어졌다.

CameraCalibrator를 실행시킨 결과로 연산된 카메라 파라미터는 camera.cfg 파일에 저장된다.
실행 후 열어 보면,
Camera.Parameters=[ 3.02629 6.17916 0.524049 0.291111 2.1234 ]
라는 식으로 CameraCalibrator 실행창에서 나타나는 그대로 되어 있다. save 버튼을 눌렀을 때 저장되는 것.

PTAM을 실행시키면 settings.cfg 파일을 읽어 온다. 파일을 열어 보면, 여기에도 gvars setting을 첨가할 수 있다는 주석이 있고, 다음 명령문으로 위에서 저장한 camera.cfg 파일을 불러서 실행한다.
exec camera.cfg
즉, Camera.Parameters 변수에 값이 assign되는 것.

정리하면,
calibrator_settings.cfg -> CameraCalibrator -> camera.cfg -> settings.cfg -> PTAM







fast feature detection
http://mi.eng.cam.ac.uk/~er258/work/fast.html

ref.
http://en.wikipedia.org/wiki/Feature_detection_%28computer_vision%29



main.cc
1) settings.cfg 파일 로드 GUI.LoadFile("settings.cfg");

2) 사용자 입력 parsing GUI.StartParserThread();

3) 클래스 system (system.h) 실행 s.Run();

atexit
Set function to be executed on exit
The function pointed by the function pointer argument is called when the program terminates normally.

try-if 구문
1) Deitel 823p "catch handler"
2) theuhm@naver: "에러가 발생한 객체는 예외를 발생시킴과 동시에 try블럭 안의 모든 객체는 스코프를 벗어나 참조할 수 없게 되므로 예외를 처리하는 동안 try블럭 안에서 예외를 발생시켰을 수 있는 객체의 참조를 원천적으로 막아 더 안전하고 깔끔한 예외처리를 할 수 있는 환경을 만들어줍니다. 그리고 예외를 던질 때에 예외 객체의 클래스를 적절히 구성하면, 예외 객체에 예외를 처리하는 방법을 담아서 던질 수도 있습니다. 그렇게 구성하면 굉장히 깔끔한 코드를 얻을 수 있죠.

set
Sets are a kind of associative containers that stores unique elements, and in which the elements themselves are the keys. Sets are typically implemented as binary search trees.

namespace

system.h
1) PTAM에서 핵심적 기능을 하는 클래스들과 클래스 "System"을 선언
// Defines the System class
// This stores the main functional classes of the system
class ATANCamera;
class Map;
class MapMaker;
class Tracker;
class ARDriver;
class MapViewer;
class System;



system.cc



ATANCamera.h
FOV distortion model of Deverneay and Faugeras

Duvernay and Faugeras


'Computer Vision' 카테고리의 다른 글

Five-Point algorithm  (0) 2009.08.18
UNIX references  (0) 2009.08.17
PTAM test log on Mac OS X  (7) 2009.08.05
SLAM related generally  (0) 2009.08.04
Kalman Filter  (0) 2009.07.30
posted by maetel
2009. 7. 27. 20:50 Computer Vision
http://opencv.willowgarage.com/wiki/InstallGuide

http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port

Installing OpenCV on OS/X with Python - Princess Polymath


0. MacPorts 설치 -> 참조

1. SubVersion 설치

%% sudo port install subversion
Password:




2. OpenCV 다운로드

%% svn co http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk opencv



3. 다운로드 받은 OpenCV 확인

%% port search opencv

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


3-1. 좀 더 자세한 정보 보기

%% port info opencv

opencv @1.0.0 (graphics, science)
Variants:    universal

opencv is a library that is mainly aimed at real time computer
vision. Some example areas would be Human-Computer Interaction
(HCI), Object Identification, Segmentation and Recognition, Face
Recognition, Gesture Recognition, Motion Tracking, Ego Motion,
Motion Understanding, Structure From Motion (SFM), and Mobile
Robotics.
Homepage:    http://www.intel.com/technology/computing/opencv/

Library Dependencies: gtk2, zlib, jpeg, libpng, tiff
Platforms:            darwin
Maintainers:          stante@gmail.com



4. OpenCV 설치하기

OpenCV 공식 위키의 설명대로 하면 안 되어서,
( cf. http://en.wikipedia.org/wiki/CMake
http://www.cmake.org/ )

예전에 Freeimage를 설치했던 과정을 참고로 MacPorts를 사용하자.
ref. http://opencv.darwinports.com/


%% sudo port install opencv



4-1. Python 2.5를 (OpenCV의 무엇에 대해서란 말인지는 모르겠으나;;;) 기본으로 설정하기

(맥에 파이썬이 기본으로 설치되어 있음은 나도 알고 있다. 여기에서는 버전을 지정/설정해 주라는 뜻인 것 같은데... 확실치 않다...)
To fully complete your installation and make python 2.5 the default, please run

    sudo port install python_select 
    sudo python_select python25

위와 같은 메시지가 있기에, 그대로..
%% sudo port install python_select 

실행 결과:
--->  Fetching python_select
--->  Attempting to fetch select-0.2.1.tar.gz from http://svn.macports.org/repository/macports/contrib/select/
--->  Verifying checksum(s) for python_select
--->  Extracting python_select
--->  Configuring python_select
--->  Building python_select
--->  Staging python_select into destroot
--->  Installing python_select @0.2.1_0+darwin_9
--->  Activating python_select @0.2.1_0+darwin_9
--->  Cleaning python_select

그리고...
%% sudo python_select python25

Selecting version "python25" for python


4-2. Python에 대하여

그냥 한 번 보기 (버전 업그레이드해야 하는 지도 모르고 하니...)
%% port info python25

python25 @2.5.4, Revision 6 (lang)
Variants:    darwin_10, darwin_7, darwin_8, darwin_9, macosx,
             puredarwin, universal

Python is an interpreted, interactive, object-oriented programming
language.
Homepage:    http://www.python.org/

Library Dependencies: gettext, zlib, openssl, tk, sqlite3, db46,
                      bzip2, gdbm, readline, ncurses
Platforms:            darwin
Maintainers:          mww@macports.org


cf.
http://wiki.python.org/moin/MacPython/Leopard
(상위 버전이 나왔으나 지금은 OpenCV를 위해서라면 그대로 2.5가 괜찮을 듯.)

ref.
Installing OpenCV on OS/X with Python - Princess Polymath


4-3. Mac에서 Unix application을  porting하는 문제에 대하여

http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/



4-4. private framework

공식 위키의 안내대로 OpenCV를 Xcode에서 부를 수 있도록 Mac OS X용 frameworks를 만들기 위해,
생성된 opencv 폴더 아래에서 make_frameworks.sh가  opencv 폴더에 있음을 확인하고 실행을 시켰다.

%% ./make_frameworks.sh

실패. 빌딩 준비만 하다가 끝난 것이라고 한다.



5. Xcode에서 OpenCV frameworks 추가하기

frameworks에는 public과 private이 있는데, OpenCV는 private framework이다.
(Mac의 public frameworks들은 /System/Library/Framework 에 있다.)


5-1. OpenCV  프레임웍 추가

4-4의 시도가 실패했으므로 (이를 바로잡기보다 우선은 편하게),
아래 링크에서 미리 built된 맥용 OpenCV frameworks를 다운로드 한다. (또는 두번째 링크에서 1.2버전 바로 받기 )
Institut für Nachrichtentechnik – OpenCV - Universal Binary Frameworks for MacOS X

.dmg 파일을 실행시켜 마운트된 이미지에서 OpenCV.framework 폴더를
/Library/Frameworks 에 넣는다.

5-2. Xcode 프로젝트에 프레임웍 삽입 (Xcode 3.1 기준)

Xcode를 열고 새 프로젝트 Command Line Utility / C++ Tool 을 만들고,
(자동으로 프로젝트와 동일명의 target 이 생성됨)
왼쪽 바 Groups & Files에서 프로젝트를 오른쪽 마우스 클릭하여 Add > Existing Frameworks 선택한다.
탐색창이 뜨면 /Library/Frameworks/OpenCV.framework 를 찾아 추가한다.

5-3. 테스트

아래 링크들의 예제 파일들을 실행시켜 본다.

ref.
http://stefanix.net/opencv-in-xcode
Wonwoo's Life DB :: OpenCV를 MAC OS X의 XCODE 에서 사용하기
Phillip Whisenhunt - Using openCV for Mac OS in XCode
Installing OpenCV on Mac OS X - NUI Group Community Wiki


5-4. Mac에서의 frameworks에 대하여
 
http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port 를 보고도 헤매여야 했던 이유를
http://opencv.willowgarage.com/wiki/PrivateFramework 에서 알 수 있었다.

ADC: Framework Programming Guide: Creating a Framework
A framework is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, nib files, image files, localized strings, header files, and reference documentation in a single package.

A framework is also a bundle and its contents can be accessed using Core Foundation Bundle Services or the Cocoa NSBundle class.

Frameworks can include a wider variety of resource types than libraries.

http://en.wikipedia.org/wiki/Framework

http://en.wikipedia.org/wiki/Software_framework


OpenCV is a Private Framework
(2007-06-10, Mark Asbach)

posted by maetel
2009. 7. 8. 21:56 Computer Vision
0. Freeimage 설치 실패
http://freeimage.sourceforge.net/ 에서
FreeImage3.12.0 을 다운로드하여 풀어 보니 FreeImage라는 이름의 폴더가 생성된다.
(.frameworks가 아니라서 당황하였으나, FreeImage가 library라 하였기에 frameworks라고 굳게 믿어 버렸고 경험도 있다고 자부하며, Xcode에서  프로젝트를 만들어  C++로 코딩할 때 어떻게 삽입해야 하는지를 놓고 엉뚱한 정보의 홍수에서 허우적대다가...)

다시 겸허한 마음으로
README.osx 파일을 TextEdit으로 열고, 다음 설명에 따라
Building the Library
--------------------
Makefile detects the environment by calling 'uname'. Assuming this reports 'Darwin' on your system, Makefile will automatically
defer commands to Makefile.osx. If this doesn't work, type 'make -f Makefile.osx' in place of just 'make'

The build process is as simple as this:
1) Enter the FreeImage directory
2) Build the distribution:
make
3) The libraries and header will be in the Dist directory when the build is finished

To install FreeImage in the /usr/local/lib and /usr/local/include directories (not recommended):
make install

To clean all files produced during the build process:
make clean


Additional notes
----------------

Building on Mac OS X Leopard :

Install the xcode dev tools from the Leopard disk.
When installing the dev tools make sure to have installed 10.3.9 SDK (it's not selected by default).

Terminal에서 freeimage 폴더로 들어가서 make 명령을 치면 다음과 같이 무수한 에러가 나온다.

ga07087:freeimage lym$ make
make -f Makefile.osx
g++-4.0 -Wno-ctor-dtor-privacy -Os -fexceptions -fvisibility=hidden -arch ppc -I. -ISource -ISource/Metadata -ISource/FreeImageToolkit -ISource/LibJPEG -ISource/LibMNG -ISource/LibPNG -ISource/LibTIFF -ISource/ZLib -ISource/LibOpenJPEG -ISource/OpenEXR -ISource/OpenEXR/Half -ISource/OpenEXR/Iex -ISource/OpenEXR/IlmImf -ISource/OpenEXR/IlmThread -ISource/OpenEXR/Imath  -isysroot /Developer/SDKs/MacOSX10.3.9.sdk -c Source/FreeImage/BitmapAccess.cpp -o Source/FreeImage/BitmapAccess.o-ppc
Source/FreeImage/BitmapAccess.cpp:30:20: error: stdlib.h: No such file or directory
In file included from Source/FreeImage/BitmapAccess.cpp:35:
Source/FreeImage.h:55:51: error: wchar.h: No such file or directory
Source/FreeImage.h:152:22: error: inttypes.h: No such file or directory
In file included from Source/FreeImage/BitmapAccess.cpp:37:
Source/Utilities.h:31:18: error: math.h: No such file or directory
Source/Utilities.h:33:20: error: memory.h: No such file or directory
Source/Utilities.h:34:19: error: stdio.h: No such file or directory
Source/Utilities.h:35:20: error: string.h: No such file or directory
Source/Utilities.h:36:20: error: stdarg.h: No such file or directory
Source/Utilities.h:37:19: error: ctype.h: No such file or directory
Source/Utilities.h:38:20: error: assert.h: No such file or directory
Source/Utilities.h:40:18: error: string: No such file or directory

...(중략)


여기서 첫번째 에러 "error: stdlib.h: No such file or directory"는 Kernel error라고 하여 Linux 등의 kernel에서 바로 standard library에 접근할 수 없어 나타난다고 한다. (이를 해결하기 위한 Linux 사용자들의 "sudo apt-get install 어쩌구"와 같은 명령어도 통하지 않고 있다.)

등등등 사흘 간의 초삽질 끝에...
source codes을 mac에서 직접 compile하는 것은 내 능력으로 어렵다고 보고, MacPorts라는 것을 이용해 보기로 한다.


1. Macports 설치 성공
MacPorts (구 Darwin Ports)의 공식사이트: http://www.macports.org
MacPorts는 Apple 사가 진행하는 OpenDarwin 프로젝트의 일부이며, 오픈 소스 소프트웨어의 컴파일, 설치, 업그레이드를 쉽게 할 수 있게 해 주는 오픈 소스 '패키지 관리 시스템'이라고 하는데 자세히는 모르겠다. (참고: http://en.wikipedia.org/wiki/Macports)

(Mac 용 Freeimage가 frameworks 형식으로 제공되는 것이 아니라서 내게 생소했던 것이다. 그냥 소스코드와 헤더파일, 다큐먼트 등을 몽땅 모아 놓은 것을 package라 부른다.)

MacPorts를 설치하기 전에 먼저 Xcode와 X11이 설치되어 있어야 한다.

웹페이지(Installing MacPorts)의 안내에 따라 MacPorts-1.7.1-10.5-Leopard.dmg를 받아서 (클릭들만으로) 설치한 후,  착실하게 MacPorts “selfupdate” command라는 것을 따라해 보니 (웬일인지) 잘된다.

Last login: Wed Jul  8 21:17:08 on ttys000
%% sudo port -v selfupdate
Synchronizing local ports tree from rsync://rsync.macports.org/release/ports/
receiving file list ... done

sent 36 bytes  received 384171 bytes  109773.43 bytes/sec
total size is 23568484  speedup is 61.34
receiving file list ... done

sent 36 bytes  received 6909 bytes  2778.00 bytes/sec
total size is 4061730  speedup is 584.84

MacPorts base version 1.710 installed
Downloaded MacPorts base version 1.710

The MacPorts installation is not outdated so it was not updated
%%

Macports가 업데잇될 때마다 자동으로 업그레이드해 주겠다는 뜻이겠지.


2. MacPorts로 Freeimage 설치
http://guide.macports.org/ (상세한 설명)
http://trac.macports.org/wiki/UsingMacPortsQuickStart (간략한 설명)

특정 포트 검색 명령어를 써서 freeimage가 있음을 확인했다.
%% port search freeimage
freeimage @3.12.0 (graphics)
    Library for FreeImage, a dependency-less graphics library

특정 포트에 대한 정보를 보기 위한 명령어는 "port info"
%% port info freeimage
freeimage @3.12.0 (graphics)
Variants:    universal

FreeImage is a library for developers who would like to support most popular
graphics image formats. Some highlights are: extremely simple in use, not
limited to the local PC (unique FreeImageIO) and Plugin driven!
Homepage:    http://freeimage.sourceforge.net/

Platforms:            macosx
Maintainers:          toby@macports.org

이외 port command 몇 가지를 Freeimage에 대해 실행해 보면,
%% port deps freeimage
freeimage has no dependencies
%% port variants freeimage
freeimage has the variants:
    universal: Build for multiple architectures


포트를 설치하라는 명령어: "sudo port install (포트 이름)"
참고: MacPorts Guide 3.1.8. install
%% sudo port install freeimage
Password:
--->  Fetching freeimage
--->  Attempting to fetch FreeImage3120.zip from http://nchc.dl.sourceforge.net/freeimage
--->  Verifying checksum(s) for freeimage
--->  Extracting freeimage
--->  Applying patches to freeimage
--->  Configuring freeimage
--->  Building freeimage
--->  Staging freeimage into destroot
--->  Installing freeimage @3.12.0_0
--->  Activating freeimage @3.12.0_0
--->  Cleaning freeimage

무슨 파일들이 설치되었는지 확인해 보면,
%% port contents freeimage
Port freeimage contains:
  /opt/local/include/FreeImage.h
  /opt/local/lib/libfreeimage.3.12.0.dylib
  /opt/local/lib/libfreeimage.3.dylib
  /opt/local/lib/libfreeimage.a
  /opt/local/lib/libfreeimage.dylib


MacPorts.org 사이트의 포트 검색에서 Freeimage를 찾을 수 있다.
freeimage 3.12.0
    Library for FreeImage, a dependency-less graphics library
    Maintained by: toby
    Categories: graphics
    Platforms: macosx
    Variants: universal




3.


posted by maetel