Build Intel® IPP Support In OpenCV 2.1

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?

 

For more complete information about compiler optimizations, see our Optimization Notice.

Comments

Gaiger Chen's picture

Hi

Could I use IPP as static library, to build the OpenCV library as dynamic linking library by EASY way?

it is, dll of OpenCV merge ipp functions as one, so using the dll of OpenCV do not need the ipp dll existing.

thank you.

Ying H (Intel)'s picture

Hi

The current OpenCV do use static IPP libraries by default, so you may follow above steps and get the wanted dlls of OpenCV, which are integrateing IPP function internally.

Regards,
Ying

Ying H (Intel)'s picture

Actually, instead of using static IPP libraries, using dynamic IPP libraries is a little complex. It may require modify the clauses in CmakeList file of OpenCV source code.

For example, modify the library name like ipp*emerged.* ipp*merged.*(static library) to ipp* (dynamic library) in CMakeList.txt.

Additionally, the current OpenCV only Support ipp v5.1 to ipp v6.1. For later version like ipp v7.0, there are more places need to modify
foreach(v "6.1" "6.0" "5.3" "5.2" "5.1")
if(IPP_FOUND AND USE_IPP)
add_definitions(-DHAVE_IPP)
include_directories("${IPP_PATH}/../include")
link_directories("${IPP_PATH}/../lib")

file(GLOB em64t_files "${IPP_PATH}/../lib/*em64t*")
set(IPP_ARCH)
if(em64t_files)
set(IPP_ARCH "em64t")
endif()

set(A ${CMAKE_STATIC_LIBRARY_PREFIX})
set(B ${IPP_ARCH}${CMAKE_STATIC_LIBRARY_SUFFIX})
if(WIN32)
set(L l)
else()
set(L)
endif()
set(IPP_LIBS ${A}ippsmerged${B} ${A}ippsemerged${B}
${A}ippimerged${B} ${A}ippiemerged${B}
${A}ippvmmerged${B} ${A}ippvmemerged${B}
${A}ippccmerged${B} ${A}ippccemerged${B}
${A}ippcvmerged${B} ${A}ippcvemerged${B}
${A}ippcore${IPP_ARCH}${L}${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()

Regards,
Ying

Yao Jianjun's picture

Hello!
if I want to execute the opencv 2.3.1 with ipp, I shoud be How to configure .
thinks !

Yao Jianjun's picture

Hello!
if I want to execute the opencv 2.3.1 with ipp in ubuntu 11.04, I shoud be How to configure .
thinks !