블로그 이미지
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'에 해당되는 글 4건

  1. 2009.08.05 PTAM test log on Mac OS X 7
  2. 2009.07.27 OpenCV 1.0 설치 on Mac OS X
  3. 2009.07.27 cameras on mac os x
  4. 2009.07.08 to install Freeimage on mac
2009. 8. 5. 14:36 Computer Vision
Oxford 대학  Active Vision Group에서 개발한
PTAM (Parallel Tracking and Mapping for Small AR Workspaces)
http://www.robots.ox.ac.uk/~gk/PTAM/

Questions? E-mail ptam@robots.ox.ac.uk


0. requirements 확인

readme 파일에서 언급하는 대로 프로세서와 그래픽카드를 확인하니

내가 설치할 컴퓨터 사양:
Model Name:    Mac mini
  Model Identifier:    Macmini3,1
  Processor Name:    Intel Core 2 Duo
  Processor Speed:    2 GHz
  Number Of Processors:    1
  Total Number Of Cores:    2
  L2 Cache:    3 MB
  Memory:    1 GB
  Bus Speed:    1.07 GHz
  Boot ROM Version:    MM31.0081.B00

그래픽 카드:
NVIDIA GeForce 9400

"Intel Core 2 Duo processors 2.4GHz+ are fine."이라고 했는데, 2.0이면 되지 않을까? 그래픽 카드는 동일한 것이니 문제 없고.


1. library dependency 확인

1. TooN - a header library for linear algebra
2. libCVD - a library for image handling, video capture and computer vision
3. Gvars3 - a run-time configuration/scripting library, this is a sub-project of libCVD.
셋 다 없으므로,

1-1. TooN 다운로드

TooN (Tom's object oriented Numerics)선형대수 (벡터, 매트릭스 연산)를 위해 Cambridge Machine Intelligence lab에서 개발한 C++ 라이브러리라고 한다.

ref. TooN Documentation (<- 공식 홈보다 정리가 잘 되어 있군.)

다음과 같은 명령으로 다운로드를 받는다.
%% cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/toon co TooN

실행 결과:

생성된 TooN 폴더에 들어가서
%%% ./configure

실행 결과:


1-1-1. 더 안정적인(?) 버전을 받으려면

%% cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/toon co -D "Mon May 11 16:29:26 BST 2009" TooN

실행 결과:


1-2. libCVD 다운로드

libCVD (Cambridge Video Dynamics)같은 연구실에서 만든 컴퓨터 비전 관련 이미지 처리를 위한 C++ 라이브러리

ref. CVD documentation

%% cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/libcvd co -D "Mon May 11 16:29:26 BST 2009" libcvd

실행 결과:



1-3. Gvars3 다운로드

Gvars3 (configuration system library)
 
%% cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/libcvd co -D "Mon May 11 16:29:26 BST 2009" gvars3

실행 결과:


2. 다운로드한 기반 라이브러리 설치

2-1. TooN 설치

2-1-1. configure file 실행

configure scripts는 source code를 compile하고 실행시킬 수 있게 만들어 주는 것.

생성된 TooN 폴더에 들어가서
%%% ./configure

실행 결과:

2-1-2. 설치

(TooN은 헤더파일들의 모음이므로 compile이 필요없다.)

%%% sudo make install

실행 결과:
mkdir -p //usr/local/include/TooN
cp *.h //usr/local/include/TooN
cp -r optimization //usr/local/include/TooN/
cp -r internal //usr/local/include/TooN/


2-2. libCVD 설치

2-2-1. configure 파일 실행

생성된 libCVD 폴더에 들어가서
%%% export CXXFLAGS=-D_REENTRANT
%%% ./configure --without-ffmpeg

실행 결과:

2-2-2. documents 생성 (생략해도 되는 듯)

다시 시도했더니
%%% make docs

make: *** No rule to make target `docs'.  Stop.
여전히 안 되는 듯... 아! doxygen을 맥포트로 설치해서 그런가 보다. (데이터베이스가 서로 다르다고 한다.)_M#]


2-2-3. compile 컴파일하기

%%% make

실행 결과:


2-2-4. install 설치하기

%%% sudo make install

실행 결과:


2-3. Gvars3  설치

2-3-1. configure 파일 실행

Gvars3 폴더에 들어가서
%%% ./configure --disable-widgets

실행 결과:


2-3-2. compile 컴파일하기

%%% make

실행 결과:


2-3-3. install 설치하기

%%% sudo make install

mkdir -p //usr/local/lib
cp libGVars3.a libGVars3_headless.a //usr/local/lib
mkdir -p //usr/local/lib
cp libGVars3-0.6.dylib //usr/local/lib
ln -fs  //usr/local/lib/libGVars3-0.6.dylib //usr/local/lib/libGVars3-0.dylib
ln -fs  //usr/local/lib/libGVars3-0.dylib //usr/local/lib/libGVars3.dylib
mkdir -p //usr/local/lib
cp libGVars3_headless-0.6.dylib //usr/local/lib
ln -fs  //usr/local/lib/libGVars3_headless-0.6.dylib //usr/local/lib/libGVars3_headless-0.dylib
ln -fs  //usr/local/lib/libGVars3_headless-0.dylib //usr/local/lib/libGVars3_headless.dylib
mkdir -p //usr/local/include
cp -r gvars3 //usr/local/include


2-4. OS X에서의 컴파일링과 관련하여

ref. UNIX에서 컴파일하기
Porting UNIX/Linux Applications to Mac OS X: Compiling Your Code in Mac OS X



3. PTAM 컴파일

3-1. 해당 플랫폼의 빌드 파일을 PTAM source 디렉토리로 복사

내 (OS X의) 경우, PTAM/Build/OS X에 있는 모든 (두 개의) 파일 Makefile과 VideoSource_OSX.cc를 PTAM 폴더에 옮겼다.

3-2. video source 셋업

카메라에 맞는 video input file을 컴파일하도록 Makefile을 수정해 주어야 한다.
맥의 경우, (아마도 Logitech Quickcam Pro 5000 을 기준으로 하는) 하나의 소스 파일만이 존재하므로 그대로 두면 될 듯.

3-3. video source 추가

다른 비디오 소스들은 libCVD에 클래스로 만들어져 있다고 한다. 여기에 포함되어 있지 않은 경우에는 VideoSource_XYZ.cc 라는 식의 이름을 갖는 파일을 만들어서 넣어 주어야 한다.

3-4. compile

PTAM 폴더에 들어가서
%% make

실행 결과:
g++ -g -O3 main.cc -o main.o -c -I /MY_CUSTOM_INCLUDE_PATH/ -D_OSX -D_REENTRANT
g++ -g -O3 VideoSource_OSX.cc -o VideoSource_OSX.o -c -I /MY_CUSTOM_INCLUDE_PATH/ -D_OSX -D_REENTRANT
g++ -g -O3 GLWindow2.cc -o GLWindow2.o -c -I /MY_CUSTOM_INCLUDE_PATH/ -D_OSX -D_REENTRANT
In file included from OpenGL.h:20,
                 from GLWindow2.cc:1:
/usr/local/include/cvd/gl_helpers.h:38:19: error: GL/gl.h: No such file or directory
/usr/local/include/cvd/gl_helpers.h:39:20: error: GL/glu.h: No such file or directory
/usr/local/include/cvd/gl_helpers.h: In function 'void CVD::glPrintErrors()':
/usr/local/include/cvd/gl_helpers.h:569: error: 'gluGetString' was not declared in this scope
make: *** [GLWindow2.o] Error 1

이 에러 메시지는 다음 링크에서 논의되고 있는 문제와 비슷한 상황인 것 같다.
http://en.allexperts.com/q/Unix-Linux-OS-1064/Compiling-OpenGL-unix-linux.htm


3-4-1. OpenGL on UNIX

PTAM이 OpenGL을 사용하고 있는데, OpenGL이 Mac에 기본으로 설치되어 있으므로 신경쓰지 않았던 부분이다. 물론 system의 public framework으로 들어가 있음을 확인할 수 있다. 그런데 UNIX 프로그램에서 접근할 수는 없는가? (인터넷에서 검색해 보아도 따로 설치할 수 있는 다운로드 링크나 방법을 찾을 수 없다.)

에러 메시지에 대한 정확한 진단 ->
philphys: 일단 OpenGL은 분명히 있을 건데 그 헤더파일과 라이브러리가 있는 곳을 지정해 주지 않아서 에러가 나는 것 같아. 보통 Makefile에 이게 지정되어 있어야 하는데 실행결과를 보니까 전혀 지정되어 있지 않네. 중간에 보면 -I /MY_CUSTOM_INCLUDE_PATH/ 라는 부분이 헤더 파일의 위치를 지정해 주는 부분이고 또 라이브러리는 뒤에 링크할 때 지정해 주게 되어 있는데 거기까지는 가지도 못 했네.
즉, "링커가 문제가 아니라, 컴파일러 옵션에 OpenGL의 헤더파일이 있는 디렉토리를 지정해 주어야 할 것 같다"고 한다.

문제의 Makefile을 들여다보고

Makefile을 다음과 같이 수정하고 (보라색 부분 추가)
COMPILEFLAGS = -I /MY_CUSTOM_INCLUDE_PATH/ -D_OSX -D_REENTRANT -I/usr/X11R6/include/

philphys: /usr/X11R6/include 밑에 GL 폴더가 있고 거기에 필요한 헤더파일들이 모두 들어 있다. 그래서 코드에선 "GL/gl.h" 하는 식으로 explicit하게 GL 폴더를 찾게 된다.

그러고 보면 아래와 같은 설명이 있었던 것이다.
Since the Linux code compiles directly against the nVidia driver's GL headers, use of a different GL driver may require some modifications to the code.

다시 컴파일 하니,
실행 결과:

설치 완료!
두 실행파일 PTAM과 CameraCalibrator이 생성되었다.


3-5. X11R6에 대하여

X11R6 = Xwindow Verion 11 Release 6

Xwindow
X.org



4. camera calibration

CameraCalibrator 파일을 실행시켜 카메라 캘리브레이션을 시도했더니 GUI 창이 뜨는데 연결된 웹캠(Logitech QuickCam Pro 4000)으로부터 입력을 받지 못 한다.

4-0. 증상

CameraCalibrator 실행파일을 열면, 다음과 같은 터미널 창이 새로 열린다.
Last login: Fri Aug  7 01:14:05 on ttys001
%% /Users/lym/PTAM/CameraCalibrator ; exit;
  Welcome to CameraCalibrator
  --------------------------------------
  Parallel tracking and mapping for Small AR workspaces
  Copyright (C) Isis Innovation Limited 2008

  Parsing calibrator_settings.cfg ....
! GUI_impl::Loadfile: Failed to load script file "calibrator_settings.cfg".
  VideoSource_OSX: Creating QTBuffer....
  IMPORTANT
  This will open a quicktime settings planel.
  You should use this settings dialog to turn the camera's
  sharpness to a minimum, or at least so small that no sharpening
  artefacts appear! In-camera sharpening will seriously degrade the
  performance of both the camera calibrator and the tracking system.

그리고 Video란 이름의 GUI 창이 열리는데, 이때 아무런 설정을 바꾸지 않고 그대로 OK를 누르면 위의 터미널 창에 다음과 같은 메시지가 이어지면서 자동 종료된다.
  .. created QTBuffer of size [640 480]
2009-08-07 01:20:57.231 CameraCalibrator[40836:10b] ***_NSAutoreleaseNoPool(): Object 0xf70e2c0 of class NSThread autoreleasedwith no pool in place - just leaking
Stack: (0x96827f0f 0x96734442 0x9673a1b4 0xbc2db7 0xbc7e9a 0xbc69d30xbcacbd 0xbca130 0x964879c9 0x90f8dfb8 0x90e69618 0x90e699840x964879c9 0x90f9037c 0x90e7249c 0x90e69984 0x964879c9 0x90f8ec800x90e55e05 0x90e5acd5 0x90e5530f 0x964879c9 0x94179eb9 0x282b48 0xd9f40xd6a6 0x2f16b 0x2fea4 0x26b6)
! Code for converting from format "Raw RGB data"
  not implemented yet, check VideoSource_OSX.cc.

logout

[Process completed]

그러므로 3-3의 문제 -- set up video source (비디오 소스 셋업) --로 돌아가야 한다.
즉, VideoSource_OSX.cc 파일을 수정해서 다시 컴파일한 후 실행해야 한다.

Other video source classes are available with libCVD. Finally, if a custom video source not supported by libCVD is required, the code for it will have to be put into some VideoSource_XYZ.cc file (the interface for this file is very simple.)

삽질...



4-1. VideoSource_OSX.cc 파일 수정



수정한 VideoSource 파일

터미널 창:
Welcome to CameraCalibrator
  --------------------------------------
  Parallel tracking and mapping for Small AR workspaces
  Copyright (C) Isis Innovation Limited 2008

  Parsing calibrator_settings.cfg ....
  VideoSource_OSX: Creating QTBuffer....
  IMPORTANT
  This will open a quicktime settings planel.
  You should use this settings dialog to turn the camera's
  sharpness to a minimum, or at least so small that no sharpening
  artefacts appear! In-camera sharpening will seriously degrade the
  performance of both the camera calibrator and the tracking system.
>   .. created QTBuffer of size [640 480]
2009-08-13 04:02:50.464 CameraCalibrator[6251:10b] *** _NSAutoreleaseNoPool(): Object 0x9df180 of class NSThread autoreleased with no pool in place - just leaking
Stack: (0x96670f4f 0x9657d432 0x965831a4 0xbc2db7 0xbc7e9a 0xbc69d3 0xbcacbd 0xbca130 0x924b09c9 0x958e8fb8 0x957c4618 0x957c4984 0x924b09c9 0x958eb37c 0x957cd49c 0x957c4984 0x924b09c9 0x958e9c80 0x957b0e05 0x957b5cd5 0x957b030f 0x924b09c9 0x90bd4eb9 0x282b48 0xd414 0xcfd6 0x2f06b 0x2fda4)



4-2. Camera Calibrator 실행


Camera calib is [ 1.51994 2.03006 0.499577 0.536311 -0.0005 ]
  Saving camera calib to camera.cfg...
  .. saved.



5. PTAM 실행


  Welcome to PTAM
  ---------------
  Parallel tracking and mapping for Small AR workspaces
  Copyright (C) Isis Innovation Limited 2008

  Parsing settings.cfg ....
  VideoSource_OSX: Creating QTBuffer....
  IMPORTANT
  This will open a quicktime settings planel.
  You should use this settings dialog to turn the camera's
  sharpness to a minimum, or at least so small that no sharpening
  artefacts appear! In-camera sharpening will seriously degrade the
  performance of both the camera calibrator and the tracking system.
>   .. created QTBuffer of size [640 480]
2009-08-13 20:17:54.162 ptam[1374:10b] *** _NSAutoreleaseNoPool(): Object 0x8f5850 of class NSThread autoreleased with no pool in place - just leaking
Stack: (0x96670f4f 0x9657d432 0x965831a4 0xbb9db7 0xbbee9a 0xbbd9d3 0xbc1cbd 0xbc1130 0x924b09c9 0x958e8fb8 0x957c4618 0x957c4984 0x924b09c9 0x958eb37c 0x957cd49c 0x957c4984 0x924b09c9 0x958e9c80 0x957b0e05 0x957b5cd5 0x957b030f 0x924b09c9 0x90bd4eb9 0x282b48 0x6504 0x60a6 0x11af2 0x28da 0x2766)
  ARDriver: Creating FBO...  .. created FBO.
  MapMaker: made initial map with 135 points.
  MapMaker: made initial map with 227 points.


The software was developed with a Unibrain Fire-i colour camera, using a 2.1mm M12 (board-mount) wide-angle lens. It also runs well with a Logitech Quickcam Pro 5000 camera, modified to use the same 2.1mm M12 lens.

iSight를 Netmate 1394B 9P Bilingual to 6P 케이블로  MacMini에 연결하여 해 보니 더 잘 된다.



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

UNIX references  (0) 2009.08.17
PTAM to be dissected on OS X  (0) 2009.08.17
SLAM related generally  (0) 2009.08.04
Kalman Filter  (0) 2009.07.30
OpenCV 1.0 설치 on Mac OS X  (0) 2009.07.27
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. 27. 17:04 Computer Vision
software

macam : USB webcam support for Mac OS X
http://webcam-osx.sourceforge.net/cameras/index.php

webcam + opencv - SWiK
http://swik.net/webcam+opencv

Video device drivers - IOXperts is a leading provider of drivers for USB and FireWire cameras
http://www.ioxperts.com/devices/supportedvideo.html


cameras

Logitech QuickCam® Communicate STX™

Logitech QuickCam Pro 4000

iSight
http://en.wikipedia.org/wiki/ISight

MacOS X Compatible Cameras




Macintosh computers


Mac mini 맥미니 (Firewire 800)

Mac mini 맥미니 (Firewire 800)





cables

Mac mini 맥미니 (Firewire 800) - 1394 (Firewire 400) 카메라 케이블:
6-pin to 9-pin FireWire Adapter

Sonnet - FireWire 400 to 800 Adapter
Netmate 1394B 9P Bilingual to 6P 케이블 2M



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