OpenCV 2.4.0 + IPP + TBB: Compilation instructions on Mac OS X (Snow Leopard)

In Computer Vision the OpenCV [WWW] framework is a well known collection of high-quality and real-time functions performing image processing, feature extraction, matrix operations, object detection and many many more ready to use routines. The framework is in active development and new functionality is added on constant basis.

The computations in Computer Vision are classically very demanding and lot of effort has been put to optimize the algorithms. Intel has two library collections that push this barrier even harder: Integrated Performance Primitives (IPP) [WWW] and Threading Building Blocks (TBB) [WWW].

The IPP provides over 10K highly optimized functions for multimedia, data processing and communications applications. For example, you can create thumbnail images in real-time or accelerate data compression tasks with this library.

The TBB provides high level functions to leverage the power of multi-core systems that are found in every even low cost machines. The bright side is that the user does not need to be an expert avoiding many common pitfalls in parallel computations. It may be seen as a replacement for the OpenMP framework [WWW].

The issue is that I could not compile the OpenCV 2.3.1 and the recent OpenCV 2.4.0 on my Mac OS X (Snow Leopard). I have a relatively recent Intel Composer XE 2011 C++ [WWW] compiler with TBB (4.0 interface 6003), IPP (7.0.205) and MKL libraries that I would like to leverage.

The standard command “cmake ..” from the build directory failed to detect the IPP and TBB libraries with errors:

CMake Error at cmake/OpenCVFindIPP.cmake:201 (message):
   IPP EM64T libraries not found
Call Stack (most recent call first):
   cmake/OpenCVFindIPP.cmake:253 (set_ipp_variables)
   CMakeLists.txt:518 (include)

Traceback (most recent call last):
   File “<string>”, line 1, in <module>
ImportError: No module named sphinx

The second error was easy to fix. First check which version of python the system uses (issue “python –version“). If it is 2.6, then using Mac Ports you can install the missing module by issuing the command “sudo port install py26-sphinx“.

The first error is bit more complex to fix. The problem lies in the file “cmake/OpenCVFindIPP.cmake” which is used by CMake to find and point the variables to the IPP library. These are include and library directories basically. You need to modify two lines in function set_ipp_variables() (I assume that you are working on 64bit system):

(1) Do the first change (old and new version)

if(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64)


(2) Do the second change (old and new version)



And you are done.

On my system I enabled the TBB and IPP with the following command from the build directory:

cmake .. -DWITH_TBB=on -DTBB_INCLUDE_DIRS=/opt/intel/tbb/include -DTBB_LIB_DIR=/opt/intel/tbb/lib -DWITH_IPP=on

Notice that I had to specify the include and lib directory for the TBB while for IPP the CMake manages to find the same directories by itself. Note that this change is needed only for IPP 7.x users.

You can download the OpenCVFindIPP.cmake file with my modifications [HERE]. Beware, I am not sure that such modification will work on Windows or Linux systems!

UPDATE: I found that you need to set also the environment variable IPPROOT. In my case it is: export IPPROOT=/opt/intel/ipp


Vladd... call me Vladd
This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

One Response to OpenCV 2.4.0 + IPP + TBB: Compilation instructions on Mac OS X (Snow Leopard)

Leave a Reply

Your email address will not be published. Required fields are marked *