Tuesday, November 13, 2012

Installing OpenCV with Python on mac osx

There are many ways to do it and I have tried most of them but got only troubles. Only one worked for me. Lo and behold, here it is

For the record, I have Mac OS X 10.7.4

The recipe.

  1. Install Xcode from apple app store then install command line tools from xcode preference
  2. Install macports from here http://www.macports.org/install.php
  3. Open terminal put the command: sudo port selfupdate
  4. Install python26 by: sudo port install python26
  5. then: sudo port install py26-numpy
  6. (probably you don't need this step but I am recording it just because I have done it) then: sudo port install python_select 
  7. then: sudo port -v install opencv +python26
  8. it will take several hours. and install opencv-2.4.3
  9. then: sudo port select python python26
  10. this will select the newly installed python as your default. Which is absolutely necessary
  11. note, that IDLE will not work at this point. But python + opencv will. 
  12. now: sudo port install py26-tkinter
  13. this will make idle work
  14. to check it, run python from terminal and put: import cv2
  15. this should work smoothly. 
  16. do it step by step in the order stated in this recipe. Otherwise there is a high chance of falling in trouble. 
  17. now do amazing projects :) 
I have failed trying to use opencv-2.4.3 with python27. It simply does not work. If you don't want to take extra pain do it with python26 as I did. But If you really want to figure out how to use python27 check this link http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port 
And please let me know how you made it work. 


No comments:

Post a Comment