Sunday, February 7, 2010

Installing OpenCV 2 on OSX with Python

Starting with instructions on the Willow Garage site, I fell at the first hurdle because thought I didn't need to install svn. Briefly, this is what I did and the more detailed explanation follows.

The short route:

1. sudo fink install svn-ssl (which takes a long time!)
2. sudo port install cmake
3. svn co https://code.ros.org/svn/opencv/trunk opencv
4. cd opencv
5. mkdir opencv/build
6. cd opencv/build
7. cmake ..
8. ccmake . (option c then option g)
9. make
10. sudo make install

On my osx 10.5 it copied the shared objects file to:

/usr/local/lib/python2.5/site-packages/cv.so

so I needed to move it to the site-packages I was using

11. cp /usr/local/lib/python2.5/site-packages/cv.so /Users/phoebebr/Development/site-packages

Now I can do:

python
>>> import cv

no error

and I can run the tests in my downloaded opencv folder,

cd opencv/opencv/tests/python
python test.py

This did report a few problems but most stuff seemed to run. Tried to run some tests calling opencv from Aptana but this caused the following error: " cp /usr/local/lib/python2.5/site-packages/cv.so /Users/phoebebr/Development/site-packages". Having installed successfully (I hope!) will have a go a writing a few programs next week....




The long route:

Already had svn so did:
svn co https://code.ros.org/svn/opencv/trunk opencv
and got
svn: SSL is not supported
so thought, I don't need https
svn co http://code.ros.org/svn/opencv/trunk opencv

and got

svn: PROPFIND request failed on '/svn/opencv/trunk'
svn: PROPFIND of '/svn/opencv/trunk': 301 Moved Permanently (http://code.ros.org)


So tried the instructions from the top:

The-Black-Book-2:site-packages phoebebr$ sudo port install subversion
Password:
---> Fetching apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://www.mirrorservice.org/sites/ftp.apache.org/apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://apache.multidist.com/apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://apache.mirroring.de/apr
---> Attempting to fetch apr-1.3.5.tar.bz2 from http://archive.apache.org/dist/apr
---> Verifying checksum(s) for apr
---> Extracting apr
---> Configuring apr
---> Building apr
---> Staging apr into destroot
---> Installing apr @1.3.5_0
---> Activating apr @1.3.5_0
Error: Target org.macports.activate returned: Image error: /opt/local/bin/apr-1-config already exists and does not belong to a registered port. Unable to activate port apr.
Error: The following dependencies failed to build: apr apr-util expat libiconv gperf sqlite3 ncurses ncursesw readline cyrus-sasl2 openssl zlib gettext neon serf
Error: Status 1 encountered during processing.

So found this URL:
http://project-tigershark.com/people/rob/blog/2006/08/21/svn-on-os-x-with-fink-part-i-installation/
which explained that I needed the server version of svn and I only had the client version installed.

and did

sudo fink install svn-ssl


and that install svn so could continue with instructions above, missing the first step. Phew....

No comments: