Using Intel® IPP with OpenCV 2.1

Introduction

Intel® Integrated Performance Primitives (Intel® IPP) is an extensive library of multicore-ready, highly optimized software functions for digital media and data-processing applications. Intel® IPP offers thousands of optimized functions covering frequently-used fundamental algorithms. Intel IPP functions are designed to deliver performance beyond what optimized compilers alone can deliver. More information about IPP can be retrieved at http://www.intel.com/software/products/ipp/index.htm.

OpenCV is an acronym for Open Source Computer Vision Library. The library is a well-known software library in computer vision for both academic and commercial use.  It is free, open source software and provides developers an easy way to input, display and store video and images, and also provides over 500 routines for computer vision processing, image processing, face detection and tracking, machine learning, etc. More information about OpenCV can be found at http://opencv.willowgarage.com/wiki/FullOpenCVWiki.

In early OpenCV versions, OpenCV was automatically accelerated by taking advantage of Intel® Integrated Performance Primitives (Intel® IPP). However, the latest OpenCV version 2.1.0 doesn't incorporate Intel® IPP by default, thus the performance benefit of Intel® IPP functions which are optimized via the Streaming SIMD Extensions (SSE, SSE, SSE2, SSE3, SSSE3, SSE4, SSE4.1, SSE4.2, and Intel® AVX in latest) instructions, cannot be obtained automatically.

With the technical notes, we will show how to use Intel® IPP with latest OpenCV as well as how to integrate Intel® IPP into OpenCV.  Two test cases are provided to demonstrate the details.

  • Use Intel® IPP library and OpenCV library independently
    Test case: transpose a image via cvRemap and ippiRemap
  • Integrate Intel® IPP library into OpenCV library and use OpenCV with built-in Intel® IPP
    Test case: Measures image similarity via cvMatchTemplate() with default OpenCV library and OpenCV library with built-in-IPP
  • Compare OpenCV, OpenCV with built-in Intel® IPP,  and Intel® IPP
    Perfromance test: cvMatchTemplate() in OpenCV and in OpenCV with built-in Intel® IPP,  ippiCrossCorrValid_Norm()

    Attached the documentation and test case.
    OpenCV_ApplicationNotes.pdf,
    ImageTranspose.cpp,
    correlation_ipp_opencv.cpp,
    Sample in Microsoft Visual Studio 2008 and Intel® VTune Amplifer XE 2011
    IPP_OpenCV2.1_Sample.zip (See attached zip file)


    Summary

    Intel® IPP is a software library provided by Intel® software group. It offers over 10K highly optimized fundamental functions for multimedia, data and image processing application. OpenCV is free and open for both non-commercial and commercial use. It provides cross-platform middle-to-high level functions for popular computer vision algorithms. OpenCV can be built with Intel® Integrated Performance Primitives (IPP). This makes it fast on all the architectures supported by the library, where the optimal code for each host architecture is chosen at runtime.

    In this paper, we showed how to integrate Intel® IPP into OpenCV step by step. With the two samples, we also discovered how OpenCV library with built-in Intel® IPP works, demonstrated how to use Intel® IPP with latest OpenCV library as well as how to use OpenCV with built-in Intel® IPP. In summary, the OpenCV library supports more computer vision algorithms than the Intel IPP library. Intel IPP library provides low-level but high performance basic image and video processing functions. We can use them as two independent libraries. However, it is convenient to integrate IPP and OpenCV via OpenCV build process and the Have_IPP flag. Thus we can benefit Intel IPP integrated into the OpenCV library automatically. In regard to the performance of routines with the same functionality in Intel® IPP and OpenCV, the direct IPP function call has the best performance. It is about 5x faster than the default OpenCV library and 2.21x the OpenCV library with built-in ipp under two cores @2.13G.  Taking considering of the fact of OpenCV itself can be built in parallel and OpenCV also includes SSE2-optimized code for many of functions, we recommend using OpenCV with calls to stand alone Intel® IPP, or OpenCV with built-in Intel IPP according to the application's feature and performance requirements. 

     Postscript Notes: 

    Many developers are trying to build IPP into OpenCV and expecting to get acceleration of image processing automatically. Unfortunately, it is not true since OpenCV 2.1 and later version. In fact, the IPP-build-in only accelerate 3 domain as below,  have no effect on common image processing function. So for those developers, it is better to call IPP directly as test case 1.  

    • 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,

    Please see the details in http://software.intel.com/en-us/articles/build-intel-ipp-support-in-opencv-21

    Refer to our Optimization Notice for more information regarding performance and optimization choices in Intel software products.

Optimization Notice in English

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.