Tag Archives: OpenCV

macports opencv 2.2 to 2.3

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>

Continue reading

OpenCV 2.1 Mac OS X 10.6 & XCode 3.2

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…


#include <iostream>
#include <cv.h>

int main ( int argc, char **argv )
cvNamedWindow( “My Window”, 1 );
*img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );

double hScale = 1.0;
vScale = 1.0;
lineWidth = 1;
( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,hScale, vScale, 0, lineWidth );
( img, “Hello World!”, cvPoint( 200, 400 ), &font,
( 255, 255, 0 ) );
( “My Window”, img );

return 0;


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