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

'MacPorts'에 해당되는 글 2건

  1. 2009.07.27 OpenCV 1.0 설치 on Mac OS X
  2. 2009.07.08 to install Freeimage on mac
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