Académique Documents
Professionnel Documents
Culture Documents
This page is devoted to information specific to the OS X build of OpenCV. Things are
changing quickly due to recent work by Willow Garage, and the transition to the CMake
build system.
For Snow Leopard users, you can build OpenCV 2.1.0 and above via MacPorts as a 64-
bit library with support of QTKit video I/O and Cocoa GUI.
to update the MacPorts base and the port tree. Then, simply:
If you encounter errors, try installing its dependents with +universal whenever
possible.
To use the libraries, include the required files with standard includes. For example:
If you use Xcode, the instructions are similar to the ones in method 2. It only differs that
/usr/local becomes /opt/local.
2. Build from source using the CMake build system
(new)
The GNU autotools methods (configure, make, make install) are being obsoleted. OpenCV
has now switched to the CMake build system.
Make sure you have subversion installed (built-in since Snow Leopard). If MacPorts is
your primary package manager, use:
Make sure you have cmake installed. This can also be installed with MacPorts:
Check out the source code into a clean directory and cd into the source directory after the
download is complete:
Note: There's a "atomic bomb commit" at r3060 which largely changed the
OpenCV directory structure. To be safe, you can specify an earlier checkout revision
to work with the instructions in this section:
You can specify many configuration options in the above command. For examples:
For the case you need the CMake GUI for other options, replace cmake with ccmake. If the
arrow keys fail, you can use the following commands instead:
To compile with Intel Threading Building blocks, use ccmake (the Cmake GUI) to specify
the lib and include paths to your installation of TBB.
After setting the build options, hit 'c' to configure. Hit 'g' to generate the config file and exit
ccmake.
Create a new Xcode project using the Command Line Utility/Standard Tool template
Select Project -> Edit Project Settings
Select the Build tab
Set Configuration to All Configurations
In the Architectures section, double-click Valid Architectures and remove all the PPC
architectures (If you built the libraries as 64-bit only, remove i386 as well)
In the Search Paths section set Header Search Paths to /usr/local/include
(/opt/local/include if you used MacPorts) and check Recursive
Close the Project Info window
Select Project -> New Group and create a group called OpenCV Frameworks
With the new group selected, select Project -> Add to Project…
Press the "/" key to get the Go to the folder prompt
Enter /usr/local/lib (/opt/local/lib if you used MacPorts)
Select libopencv_core.dylib, libopencv_highgui.dylib, and
libopencv_imgproc.dylib (perhaps more, not sure yet).
Click Add
Uncheck Copy Items… and click Add
Now you should be able to include the OpenCV libraries, compile, and run your project.
The only #include directive you should need is #include <opencv.hpp>. It, in turn, includes
the rest of the opencv header files.
Create a new XCode project using the Command Line Utility/Standard Tool template
Select Project -> Edit Project Settings
Select the Build tab
Set Configuration to All Configurations
In the Architectures section, double-click Valid Architectures and remove all the PPC
architectures
In the Search Paths section set Header Search Paths to /usr/local/include/opencv
Close the Project Info window
Select Project -> New Group and create a group called OpenCV Frameworks
With the new group selected, select Project -> Add to Project…
Press the "/" key to get the Go to the folder prompt
Enter /usr/local/lib
Select libcxcore.dylib, libcvaux.dylib, libcv.dylib, libhighgui.dylib, and
libml.dylib.
Click Add
Uncheck Copy Items… and click Add
Now you should be able to include the OpenCV libraries, compile, and run your project
Note: the CMake build system should ultimately make this obsolete, one may remove this
section when the CMake building is mature on the Mac. By the way, the
make_framework.sh script has been removed since revision 2528. The last revision
where make_framework.sh successfully builds, as I tested, is r2492.
OpenCV can now be built as a Mac OS X Framework useable with XCode. Just invoke the
'./make_frameworks.sh' script and you will obtain a Universal Framework named
"OpenCV.framework" meant as a Private Framework.
Additionally, a pre-built version (universal binary Private Framework, again together with a
demo application) is available. See the PrivateFramework wiki page or directly download it
from http://www.ient.rwth-aachen.de/~asbach/OpenCV-Private-Framework-1.1.dmg .
OpenCV 2.0 Universal Framework (tested on ppc and i386 Leopard and Snow Leopard):
Here is an universal Framework for Mac ppc/i386 built from the OpenCV 2.0 released in
September09. By the way, I also fixed some bugs and add some improvements:
http://vislab.cs.vt.edu/~vislab/wiki/images/4/44/OpenCV2.0.dmg
The following shows you how to compile OpenCV CVS for Mac OS X, using QuickTime
video I/O and Carbon windowing. Image I/O is currently done via external libraries.
External dependencies
The code relied on external libraries for image loading and saving as well as video reading /
writing. You can still enable reading JPEG, PNG and TIFF images 'the traditional way' with
external libraries installed via Fink or DarwinPorts. However, this is no longer required
nor recommended.
Unfortunately, we still have no working (i.e. native) video writer for Mac OS X. If you need
video writing, you should currently configure for ffmpeg or xine and disable QuickTime.
The downside of this is that you will lose QuickTime video input at the same time. And still
ffmpeg video writing support is as buggy on Mac OS X as it is on Linux (for OpenCV).
Volunteers?
Configuring
To configure the code for your environment, go into the source directory. It’s a good idea to
first make a special build directory:
Then run the provided configure script, giving it the location of the external libraries. For
Fink, use:
The install goes into /usr/local by default; of course you can change that with the
usual --prefix argument to configure. You might also want to run the tests with
make check.
Other Resources
Links:
Attachments:
Collected Information
As an alternative, we now have a small build script that configures and builds twice (once
for ppc, once for intel) and then merges the binaries with lipo. We can and will extend this to
more architectures whenever Mac OS X 10.5 Leopard is released, since it finally comes
with 64bit compilers for intel. In addition to those then natural 4 platforms (intel/ppc *
32/64), it might be nice to provide specially optimized variants for G5, G4, G3 (-mcpu=...)
to maximize speed on older hardware. This however requires additional testing (and
performance testing).
OpenCV OS