Finally I have some video footage of the exhibition we made some work for a couple of months ago. The project is described in my projects section here.
To install opencv through macports its the usual sudo port install opencv. If you already have an old version of opencv you will get the following error;
---> Computing dependencies for opencv ---> Building opencv Error: opencv 2.3.1a cannot be built while opencv 2.2.0 is installed and active. Error: Please deactivate opencv 2.2.0 first. Error: Target org.macports.build returned: incompatible opencv version active Log for opencv is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_opencv/opencv/main.log Error: Status 1 encountered during processing. To report a bug, see <http://guide.macports.org/#project.tickets>
Getting opencv to run on ubuntu 11.04 is not so easy due to problems with ffmpeg. However, If you compile and install ffmpeg from source it should allow for opencv 2.2 to install hassle free. Sabastian Monabone explains the process better than I could here.
I first tried to install OpenCV 2.2 through macports and from source but with little luck. According to google there seem to be a few issues with the new quicktime and opencv 2.2. That and the network proxy wont let me talk with macports, meaning no update is possible without faffing around with network files.
So I chose to go with 2.1 because it works. It can be downloaded from here http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/. You will need cmake to build an xcode project. I made no changes to the cmake file other than to create a build folder, just configure, configure then generate. I then opened up the generated xcode project as root (its needed to install opencv completely). It should build cleanly. Once built, right click on the target “install” and build. I found this to fail because it could not find the opencv libraries because they were in a release/debug subfolder. Just copy the appropriate files up one level and you should get no further problems.
Library files are installed to /usr/local/lib and headers in /usr/local/include/opencv. To view these folders in the finder press cmd Shift G and type the location.
To create a new project with opencv in xcode ….
1 – File new project -> command line tool
2 – Project Settings -> add header search path /usr/local/include/opencv/
3 – Add library search path /usr/local/lib/
4 – Create new group OpenCV_lib and add libraries found in said lib folder to the group.
I found that the new settings didn’t get applied straight away, so try restarting the project if that happens. In main copy the follow hello world program…
int main ( int argc, char **argv )
cvNamedWindow( “My Window”, 1 );
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
double hScale = 1.0;
double vScale = 1.0;
int lineWidth = 1;
cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,hScale, vScale, 0, lineWidth );
cvPutText( img, “Hello World!”, cvPoint( 200, 400 ), &font,
cvScalar( 255, 255, 0 ) );
cvShowImage( “My Window”, img );
Compile and test… If it doesnt work I dont know why!
Update: Ive made an xcode template that should work, place it in /Developer/Library/Xcode/Project Templates/Application/OpenCV/ and download it here OpenCVTemplate