When I hunted the net and books, I found that 1.x articles and 2.x articles were messed up. I'm confused, so I've summarized the steps that are easy to set up.
Follow the steps below to install OpenCV 2.4 and the library to use it from python.
sudo port -v install opencv +python27
#Check OS X standard python
$ which python
/usr/bin/python
$ sudo port -v install opencv +python27
・ ・ ・ The result is omitted.I was able to install it in about 10 minutes in my environment ...
#Make sure OS X standard python hasn't changed
$ which python
/usr/bin/python
$ python --version
Python 2.7.2
#Check the installed python.MacPorts directory( /opt/local/bin )Under
$ which python2.7
/opt/local/bin/python2.7
#Apparently python2.It seems that the command is passing by the name of 7.
$ python2.7 --version
Python 2.7.5
#Check the OpenCV library path
#python2 installed by port.It seems that it is installed under the influence of 7
$ ls -l /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2.so
-rwxr-xr-x 1 root wheel 1579428 9 16 23:36 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cv2.so
It is confirmed that the library can be referenced from python2.7.
$ python2.7
Python 2.7.5 (default, Aug 1 2013, 01:01:17)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
#Judging that the installation was successful because there was no error when importing the cv2 library
#Try running the sample program distributed by the developer official
# http://sourceforge.net/projects/opencvlibrary/files/
$ python2.7 opencv-2.4.6/samples/python2/find_obj.py
Feature-based image matching sample.
USAGE
find_obj.py [--feature=<sift|surf|orb>[-flann]] [ <image1> <image2> ]
--feature - Feature to use. Can be sift, surf of orb. Append '-flann' to feature name
to use Flann-based matcher instead bruteforce.
Press left mouse button on a feature point to see its mathcing point.
using sift
img1 - 604 features, img2 - 969 features
matching...
75 / 80 inliers/matched
Here is a capture of the window displayed at this time.
Now you can run the OpenCV program. That annoying Cmake seems to be done in port install.
The installation command used is based on "1.Build via MacPorts" described in Developer Official.
Recommended Posts