Build Intel® IPP Support In OpenCV 2.1

Submit New Article

May 10, 2010 8:00 AM PDT


The model of IPP support has been changed since OpenCV 2.0.  Unlike the earier OpenCV version (OpenCV 1.0), which dynamically detect IPP libraries and load them automatically (see Intel® Ipp - Open Source Computer Vision Library (OpenCV) FAQ ), the current OpenCV link with IPP static libraries. The default build of OpenCV which available from sourceforge does not include IPP libraries.  So for who still want to use both, IPP and OpenCV, if you has IPP installed, you should be able to configure and rebuild OpenCV to enable the linking to IPP.

The article discribles the steps to how to enable link with IPP static library based on OpenCV 2.1 (the latest release when the artice was publihsed).

Prerequisites

  • Latest OpenCV version
  • C/C++ compiler (OpenCV is known to work with VS2005, VS2008. We recommand to use VS2008 and above)
    • CMake 2.6 or later. CMake is now the only method of building OpenCV SVN snapshots
    • IPP 6.x, download by following the instruction in IPP Downloads, Registration and Licensing
      Or have IPP installed as a part of Intel Parallel Studio or Intel Compiler Professional Version

    Please note, the lastest IPP version that OpenCV is 6.x.  If you have IPP 7.x used, you may need modify the CMakeLists.txt file in OpenCV source  to make sure the IPP 7.x is found and used. Please refer to the discussion  

    Building OpenCV Solution From Source Using CMake
    There is build guide in InstallGuide in OpenCV wiki website. User can enable a build with IPP support by Cmake Command line or CMake GUI.  We recommend to use CMake GUI, so we can adjust any options freely. See the details as below

    Step 1. Have OpenCV 2.1, Microsoft C Compiler, IPP, CMake installed( or extracted) on the develop machine  

    Step 2. Open CMake GUI by Start Menu  ( or go CMake install directory, double click cmake-gui)

    Step 3. Enter the OpenCV source directory in Box "Where is the source code" and enter a directory to Box " Where to build the binaries". Click the "Configure" Button to do the initial configuration.

    Please note: The second directory is the one you want to put the generated Makefiles, VisualStudio, Xcode or Eclipse etc. project files as well the object files and output binaries. If the directory is not exist, the Cmake Gui will help you to create it.  We denote the directory as OpenCV_IPP_BUILDOpenCV.bmpimage
    Step 4. Check IPP in CMake_Gui interface
    If you have IPP installed on your machine and want to build OpenCV with IPP support, check if IPP is turned on in CMake configuration options and if it was detected.
    First, look at the CMake  USE_IPP,   if it  is NO. It means that IPP was not turned on or it was not detected. In this case turn it on (USE_IPP=ON)
    Second, look at the IPP_PATH and enter the correct path to IPP shared libraries (IPP_PATH=<...>). 

    Please note: If you have several IPP versions installed on the machine and want to use one of them to build OpenCV, you can click the path and specify the particular path you needed. Like above figure, USE_IPP is on and IPP_PATH are pointed to C:/Program File/Intel/Parallel Studio/Composer/ipp/ia32/bin

    Please note OpenCV currently uses static IPP libraries, it derives their path from the supplied path to the shared/dynamic IPP libraries

    Click "Configure" again and then press "Generate" (or OK). Close the Cmake-Gui

    Step 5. Browse to the OpenCV_IPP_BUILD directory. Some project/solution/workspace will be generated there.  Open top-level project:OpenCV.sln in Microsoft Visual Studio and build it.  Then all related cv,cxcore,highhui library and binary file will produced in OpenCV_IPP_BUILD/ bin and /lib directory

    OpenCV_IPP_2008.JPG

    Verify IPP used in OpenCV

    OpenCV 2.1.0 call IPP function explictly when the Macro "HAVE_IPP" is defined during the process of build cxcore and cv library.  The used IPP functions mainly include

    • Color Conversion in cv =>cvcolor.cpp
    • Harr classifier training functions in cv => cvharr.cpp
    • ippsDFT function in cxcore=>cxdxt.cpp

      For example, in cvcolor.cpp,
      #ifdef HAVE_IPP
      CvStatus status = icvBGRx2ABC_IPP_8u_CnC3R( src, srcstep, dst, dststep, size,
      src_cn, blue_idx, (CvColorCvtFunc0)ippiRGBToHSV_8u_C3R );

    in cvhaar.cpp,

     

    #ifdef HAVE_IPP
    if( cascade->hid_cascade->ipp_stages )
    {
    IppiRect iequRect = {equRect.x, equRect.y, equRect.width, equRect.height};
    ippiRectStdDev_32f_C1R(sum1.ptr<float>(y1), sum1.step,
    sqsum1.ptr<double>(y1), sqsum1.step,
    norm1->ptr<float>(y1), norm1->step,
    ippiSize(ssz.width, ssz.height), iequRect );
    in cxdxt.cpp,
    #ifdef HAVE_IPP
    static void ippsDFTFwd_CToC( const Complex<float>* src, Complex<float>* dst,
    const void* spec, uchar* buf)
    {
    ippsDFTFwd_CToC_32fc( (const Ipp32fc*)src, (Ipp32fc*)dst,
    (const IppsDFTSpec_C_32fc*)spec, buf);
    }

    Please see other resource at: http://opencv.willowgarage.com/wiki/InstallGuide and the thread discussion in IPP doesn't work with OpenCV 2.0.

    Note: IPP is one of components of Intel Parallel Studio. The method on the article also apply to the IPP component in Parallel Composer. See more in Getting Intel® IPP from stand-alone version or bundled products?

     



    Do you need more help?


    This article applies to: Intel® Integrated Performance Primitives Knowledge Base,   Intel® Parallel Composer Knowledge Base