세상을 놀라게 하자!

Build OpenCV and python interface on Mac OS X 본문

Technical writing

Build OpenCV and python interface on Mac OS X

유진호 2009. 5. 5. 11:42

 The standard guide to build open computer vision library is written on OpenCV wiki. How to use openCV in X code is described in this link (Korean). It's simple. Mac OS X is UNIX os using Darwin kernel. But building python interface was difficult. So I googled and tested the results. I summarized the search result.


  1. Download MacPorts

    • MacPorts is the project of porting UNIX program to Mac OS X and it can manage pre-built packages like apt-get in Debian or Ubuntu. The similar one is Fink.

  2. Download open compter vision library.

    • You can download 'OPENCV-LINUX' from sourceforge.  If you click package file twice, Mac OS X shall extract whole package.

  3. Standard build

    1. Let extract OpenCV code pacakage into  $OpenCV$ folder.
    2. Make folder build (mkdir build) under  $OpenCV$ and go into this folder(cd build ). 
    3. Type "../configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib" in terminal. It shall configure build environment of OpenCV. If you install fink instead MacPorts, type "../configure CPPFLAGS="-I/sw/include" LDFLAGS="-L/sw/lib".
    4. If there are nothing strange in output message, execute  "make" in terminal
    5. If there are nothing strange in output message, execute "sudo make install" in terminal.

  4. Build Python binding

    1. OpenCV wiki described that  "--with--python" option in configure ( see 3.3 ) will compile python binding.  But I got the error message in output.  I found that the same problem made people crazy.
    2. Go into $OpenCV$/interfaces/swig/python/ in terminal.
    3. Run "python setup-for-win.py install" in terminal.
    4. Run IDLE and type the command below. If you success, building process is successfully done.
      import opencv

  5. I executed  facedetect.py. Hello gramma Lenna. ;-)


 

 I have failed with this method. But this result is top listed in Google result. Please have fun. ;-).

Comments