Mac OS X OpenCV Port

This page exists to track planning and progress on the Mac OS X OpenCV port.

Development targets Mac OS X 10.4 (Tiger) and QuickTime 7 for the Mac-specific parts. Unix-like support (libpng etc., FFmpeg, GTK+) should be kept working for older systems.

As a regular user, check out into a clean directory with:

cvs -d:pserver:anonymous@opencvlibrary.cvs.sourceforge.net:/cvsroot/opencvlibrary login

cvs -z3 -d:pserver:anonymous@opencvlibrary.cvs.sourceforge.net:/cvsroot/opencvlibrary co -P opencv

As a project developer, use:

export CVS_RSH=ssh

cvs -z3 -d:ext:developername@opencvlibrary.cvs.sourceforge.net:/cvsroot/opencvlibrary co -P opencv

Framework

OpenCV can now be built as a Mac OS X Framework useable with XCode. The steps building steps described below on this page are not necessary for building the framework, just invoke the './make_frameworks.sh' script and you will obtain a universal Framework meant as a Private Framework. A demo application and some documentation has been added to the samples directory of OpenCV. If you update from an older version via cvs, be sure to use 'cvs update -d' to get the new directories.

Additionally, a pre-built version (universal binary Private Framework, again together with a demo application) is available from http://www.ient.rwth-aachen.de/~asbach/OpenCV-Private-Framework-1.1.dmg .

Building

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:

mkdir build; cd build

Then run the provided configure script, giving it the location of the external libraries. For Fink, use:

../configure CPPFLAGS="-I/sw/include" LDFLAGS="-L/sw/lib"

For DarwinPorts users, the line reads:

../configure CPPFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib"

You can add additional tuning parameters as well, e.g. CXXFLAGS="-mcpu=G5 -mtune=G5". See also the output of ../configure --help for additional arguments.

Compiling and Installing

Finally, compile and install the code:

make
sudo make install

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.

Task List

  1. Build Environment

    1. (./) ./configure && make && make install work on OS X --without-python (MarkAsbach).

    2. (./) Added MacOS X specific switches to ./configure (should be complete) (MarkAsbach).

    3. (./) Got Python to work on OS X (with / without SWIG) (MarkAsbach).

    4. (./) There was not much to change for universal binaries. See TechNote 2137 (MarkAsbach)

    5. (./) Implement Makefile rules for frameworks

    6. (./) Find out which optimization flags to set and how to do that for universal binary builds.

    7. Double check that everything works seamlessly.

  2. Windowing system / GUI

    1. (./) Erics Carbon code has been integrated (MarkAsbach).

    2. Implement 'threaded highgui' functionality, i.e. cvStartWindowThread().

    3. Double check if eveything works seamlessly.

  3. Video I/O

    1. Implement video writer in QuickTime.

      1. (./) See VideoCodecs on which codecs and file containers to support at minimum. Compile list of standard codecs that ship with QuickTime 7 as a hint on what else could be supported. See below for the list of image compressor components on my machine. (ChristophSeibert)

      2. (./) Write frames with an uncompressed codec in a MOV container. (ChristophSeibert)

      3. (./) It's possible to write to an AVI container directly. See the attached file 'export.cpp' in 'Other Resources' below (MarkAsbach)

      4. Rewrite QuickTime video writer to use MovieExporterComponent for direct creation of AVI (see above). Write uncompressed RGB at first. (ChristophSeibert)

    2. Move cvcap_qt.cpp off of QuickDraw and onto CoreGraphics.

    3. Enable capture using libdc1394 version 2 through CvCap, now that it supports Mac OS X. This library provides DMA access to DCam/IIDC cameras, allows their parameters to be set and does not require third-party drivers, such as those by IOXperts - therefore it's fast, configurable and free! See http://damien.douxchamps.net/ieee1394/libdc1394/ for more details.

      1. Kevin Cox started this port around 3/07 and never finished (it works for my purposes (point grey firefly mv) but is not feature-complete). Please feel free to contact him at kevintcox a google's free mail service either to say WORK ON IT or to get the source in progress.

    4. Allow CvCap to capture via either libdc1394 or Quicktime (for movies and non IIDC cameras) on Mac OS X without recompiling it.

  4. (./) Drop direct useage of libpng, libtiff, etc. replace with ImageIO (Done, thanks to M. Conbere, MarkAsbach).

Other Resources

Links:

Attachments:

Collected Information

Compiling Universal Binaries

The --enable-universal-build switch has been removed again since it doesn't allow building on intel machines ... You can still try out what it did by configuring with:

./configure CFLAGS="-arch i386 -arch ppc" CXXFLAGS="-arch i386 -arch ppc" --disable-dependency-tracking

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).

See also: Compiling for Multiple Architectures in http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/

List of QuickTime codecs

List of QuickTime codecs on Mac OS X 10.4.6, PPC, QuickTime 7.1, third party 3ivx, XviD and DivX codecs installed:

Number of compressor components: 30

'3IV2'
3ivx D4 4.5.1
Compresses an image into 3ivx D4 format.

'8BPS'
Apple Planar RGB
Compresses images in the Planar RGB format.

'SVQ1'
Sorenson Video™ Compressor
Compresses video using the Sorenson Video™  V2.30.302 compressor from Sorenson™ Media, Inc.

'SVQ3'
Sorenson Video 3 Compressor
Compresses video using the Sorenson Video® 3 SE V 3.3.302 compressor from Sorenson® Media, Inc.

'WRLE'
Apple BMP
Compresses images in the BMP format.

'XVID'
XviD
Decompresses video stored in XviD format.

'avc1'
H.264 Encoder
Compresses video to the H.264 format.

'cvid'
Apple Cinepak
Compresses images using Apple Computer's Cinepak compression algorithm

'dv5n'
Apple DVCPRO50 - NTSC
Compresses an image to DVCPRO50 NTSC format.

'dv5p'
Apple DVCPRO50 - PAL
Compresses an image to DVCPRO50 PAL format.

'dvc '
Apple DV/DVCPRO - NTSC
Compresses an image to DV/DVCPRO NTSC format.

'dvcp'
Apple DV - PAL
Compresses an image to DV PAL format.

'dvpp'
Apple DVCPRO - PAL
Compresses an image to DVCPRO PAL format.

'h261'
Apple H.261
Compresses images using H.261 compression algorithm

'h263'
H.263
Compresses images using H.263 compression algorithm

'h263'
Apple VC H.263
Compresses images using H.263 compression algorithm

'jpeg'
Apple Photo - JPEG
Compresses images using the ISO standard baseline JPEG algorithm

'mjp2'
JPEG 2000 Encoder
Compresses images to the JPEG 2000 JP2 format.

'mjpa'
Apple Motion JPEG A
Compresses images compressed using Motion JPEG Format A

'mjpb'
Apple Motion JPEG B
Compresses images compressed using Motion JPEG Format B

'mp4v'
Apple MPEG4 Compressor
Compresses images using MPEG4 compression algorithm

'png '
Apple PNG
Compresses images in the PNG format.

'pxlt'
Apple Pixlet Video
Apple Pixlet Video Info

'raw '
Apple None
Stores images without any compression

'rle '
Apple Animation
Compresses images using run length encoding

'rpza'
Apple Video
Compresses images using Apple Computer's Video compression algorithm

'smc '
Apple Graphics
Compresses images using Sean's secret recipe (optimal for 8-bit dithered images)

'tga '
Apple TGA
Compresses images stored into the TGA format.

'tiff'
Apple TIFF
Compresses images in the TIFF format.

'yuv2'
Apple Component Video - YUV422
Compresses an image into YUV format.

Mac OS X OpenCV Port (last edited 2007-10-18 23:37:11 by KevinCox)

SourceForge.net Logo