Note For OpenCV version 3.0 or above, Intel® IPP provides a subset of Intel® IPP functions, the IPP-ICV libraries, which can be easily used with OpenCV. Integrating Intel® IPP with OpenCV is automatically done by OpenCV, Check the “How do I use OpenCV 3.x with Intel IPP functions” part in the article on the steps. To use the Intel® IPP with some old version of OpenCV, please follow the steps for old versions in the articles
How is Intel IPP different from OpenCV?
OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision, and Intel® IPP provides the optimized functions for the OpenCV functions.
In addition to computer vision, Intel IPP provides high performance low-level routines for imaging, cryptography, signal processing and data compression. These functions are designed maximize application performance on Intel® processor-based workstations and servers.
How do I use OpenCV 3.x with Intel IPP functions?
OpenCV 3.x supports optimization on x86 and x64 platforms with Intel® Integrated Performance Primitives, Intel® IPP offers a special subset of Intel® IPP functions for image processing and computer vision(the IPP-ICV libraries) for OpenCV. The IPP-ICV package support the optimization on AVX2, SSE4.x, SSE2 instructions sets.
The IPP-ICV package is provided with the OpenCV library, and the optimization with IPP-ICV is enabled by default on the supported platforms, and users do not need install additional standalone Intel® IPP package.
Here is example to build OpenCV 3.x with Intel® IPP optimized functions at Linux*(it use similar steps for Windows OS*):
- Go to <OpenCV DIR>
#cd <OpenCV DIR> - Create a new folder for the building script, and go to that directory:
#mkdir build
#cd build - Create the building files.Add the “-D WITH_IPP=ON” into cmake command line:
#cmake -D WITH_IPP=ON …..
Note The configuration script will automatically download Intel IPP-ICV package from the network. This takes some time, after it completes, the Intel IPP ICV files will be found at 3rdparty/ippicv/downloads/PACKAGE_HASH_VALUE folder
If it can successfully complete this step, in the configuration result, you should see Intel IPP are enabled:
Note If you build system cannot download the IPP-ICV package automatically, you can manually download the IPP-ICV package:
Linux package ippicv_linux_20151201.tgz
Window package ippicv_windows_20151201.zip
Put the put package at following OpenCV folder:
Linux: 3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e
Windows: 3rdparty/ippicv/downloads/windows-04e81ce5d0e329c3fbc606ae32cad44d
Then use “cmake -D WITH_IPP=ON” to create the building files - Build the OpenCV source code:
#make
How do I use OpenCV 2.4 with Intel IPP 9.0 and a later version?
Intel IPP 9.0 introduced a few APIs change. To use the OpenCV 2.4 with the Intel(R) IPP 9.0 or a later version, users need to get the Intel IPP legacy libraries first, then make the following change to build the library:
1. Download Intel® IPP legacy libraries.
2. Set an IPPROOT_LEGACY environment variable to the IPP legacy library folder. For example:
At Windows: > set IPPROOT_LEGACY=C:\Work\IPP_legacy
Or at Linux $ export IPPROOT_LEGACY=~/IPP_legacy
The $IPPROOT_LEGACY/include should point to IPP legacy header files.
3. Modify the following CMake files (line numbers are provided for original file):
a. <OpenCV dir>/opencv/sources/cmake/OpenCVFindIPP.cmake
Change line #166:
Before: ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
After: ${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}90lgc${IPP_SIFFIX}${IPP_LIB_SUFFIX}
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPI}90lgc${IPP_SIFFIX}${IPP_LIB_SUFFIX} )
Add a line after line #194:
Before: set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE)
After: set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE)
set(IPP_LEGACY_LIBRARY_DIRS $ENV{IPPROOT_LEGACY}/lib PARENT_SCOPE)
Change line #199:
Before: if(NOT EXISTS ${IPP_ROOT_DIR}/../em64t)
After: f(NOT EXISTS ${IPP_ROOT_DIR}/../intel64_lin)
Change line #203:
Before: if(NOT EXISTS ${IPP_ROOT_DIR}/../ia32)
After: if(NOT EXISTS ${IPP_ROOT_DIR}/../ia32_lin)
Add a line after line #218:
Before: if (APPLE)
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib)
After: if (APPLE)
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib)
set(IPP_LEGACY_LIBRARY_DIRS $ENV{IPPROOT_LEGACY}
Change line #223:
Before: endif()
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64)
After: endif()
set(IPP_LEGACY_LIBRARY_DIRS $ENV{IPPROOT_LEGACY}/lib/intel64)
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64 ${IPP_LEGACY_LIBRARY_DIRS})
Change line #228:
Before:
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../compiler/lib REALPATH)
After:
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../lib REALPATH)
Change line #237:
Before: ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
After: ${INTEL_COMPILER_LIBRARY_DIR}/intel64
${IPP_LEGACY_LIBRARY_DIRS})
Change line #239:
Before: ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
After: ${INTEL_COMPILER_LIBRARY_DIR}/intel64
${IPP_LEGACY_LIBRARY_DIRS})
Change line #246:
Before: ${INTEL_COMPILER_LIBRARY_DIR}/ia32)
After: ${INTEL_COMPILER_LIBRARY_DIR}/ia32
${IPP_LEGACY_LIBRARY_DIRS})
Add a line after line #253:
Before: set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
After: set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
set(IPP_LEGACY_LIBRARIES ${IPP_LEGACY_LIBRARY_DIRS} PARENT_SCOPE)
b. <OpenCV dir>/opencv/sources/cmake/OpenCVFindLibsPerf.cmake
Add a line after line #16:
Before: ocv_include_directories(${IPP_INCLUDE_DIRS})
After: ocv_include_directories(${IPP_INCLUDE_DIRS})
ocv_include_directories($ENV{IPPROOT_LEGACY}/include)
4. Create small “ipp_legacy.h” file in <OpenCV dir>/opencv/sources/modules/core/include/opencv2/core directory
#include "ippcv90legacy.h"
#include "ippi90legacy.h"
#if defined(_WIN32)
#pragma warning( disable : 4505 4996 )
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
static void ippStaticInit()
{
legacy90ippiInit();
legacy90ippcvInit();
}
static void ippiHaarClassifierFree_32f(void* p)
{
free(p);
}
5. Modify <OpenCV dir>/opencv/sources/modules/core/include/opencv2/core/internal.hpp file, add one line to include "ipp_legacy.h"
# ifdef HAVE_IPP
# include "ipp.h"
# include "ipp_legacy.h" // Add this line
CV_INLINE IppiSize ippiSize(int width, int height)
6. Make sure IPPROOT environment variable is set to IPP library folder, and build OpenCV using standard CMake procedure with Intel® IPP support.
How do I use OpenCV 2.4 with Intel IPP 8.x?
OpenCV 2.4 use Cmake configuration to add Intel® IPP libraries, which is different from the OpenCV 1.x release. The building scrip supports Intel® IPP 7.0 and previous IPP release. To use OpenCV 2.4 with the newer Intel® IPP 8.x release, it needs to manually change the OpenCVFindIPP.cmake file in OpenCV source and make sure it can find the correct version of Intel IPP 8.x at your system:
Here is an example to build the OpenCV 2.4 with Intel IPP 8.1. For other version, you needs to slightly change the Intel® IPP names and Intel(® IPP folders for that version:
- Open opencv-2.4.5/cmake/OpenCVFindIPP.cmake file
Line 182:
Change: if(NOT EXISTS ${IPP_ROOT_DIR}/../em64t)
To: If(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64)
Line 186:
Change: if(NOT EXISTS ${IPP_ROOT_DIR}/../ia32)
To: if(NOT EXISTS ${IPP_ROOT_DIR}/lib/ia32)
Note, if you are using IPP 7.x, or IPP 6.1, the building scrip supports that version, and it does not need to change this file. - To switch ‘ON’ IPP support, define “WITH_IPP=ON” in build command line:
> cmake-D WITH_IPP=ON /usr/opencv-2.4.x
If will report the third party libraries support information as below:
--found IPP: 8.1.1[8.1.1]
--IPP libs : libippvm_l.a; libippcc_l.a;libippcv_l.a;libipps_l.a;libippcore_l.a
......
.....
Other Third party libraries
Use IPP 8.1.1.
at : /opt/intel/ipp….
How do I use OpenCV version 1.x with Intel IPP?
OpenCV version 1.0 provides a transparent user interface to the Intel® IPP by automatically loading the Intel IPP libraries at runtime if they are available. It supports IPP version 5.1 to version IPP 6.1.
To use OpenCV 1.x with Intel IPP, users need to download Intel IPP 6.1 release. If you have a valid Intel IPP licenses, please login into the Intel Registration Center to get the package.
The following is test code small test code to detect if Intel IPP dlls are loaded by OpenCV after you install Intel 6.1 package.
#include <stdio.h>
#pragma comment( lib, "highgui.lib" )
#pragma comment( lib, "cxcore.lib" )
int main(){
int NumUploadedFunction = 0;
NumUploadedFunction = cvUseOptimized(1);
printf("\t NumUploadedFunction = %d \n\n", NumUploadedFunction);
const char* opencv_lib = 0;
const char* add_modules = 0;
cvGetModuleInfo(0, &opencv_lib,&add_modules);
printf("\t opencv_lib = %s,\n\t add_modules = %s\n\n", opencv_lib,add_modules);
return 0;
}//_end_of_file_
if IPP dll are loaded automatically, the output of detect code is like
NumUploadedFunction = 144
opencv_lib = cxcore: 1.0.0,
add_modules = ippcv-6.1.dll, ippi-6.1.dll, ipps-6.1.dll, ippvm-6.1.dll, ippcc-6.1.dll
How do I use both Intel IPP and OpenCV functions in my application?
The OpenCV source code contains examples of how Intel IPP functions are used. Intel IPP performs operations directly on image buffers so you would need to pass pointers to those buffers to the Intel IPP along with corresponding information about the buffers such as image width and height. The Intel IPP and OpenCV function calls can be easily mixed in the same application. Here is an example:
// Let A, B and C be single-channel 8-bit images.
IplImage *A, *B, *C;
// Compute C = (A+B)/2 using an Intel IPP function call
IppiSize size = { A->width, A->height };
ippiAdd_8u_C1RSfs( (Ipp8u*)A->imageData, A->widthStep, (Ipp8u*)B->imageData, B->widthStep, (Ipp8u*)C >imageData, C->widthStep, size, 1 );
For more information, please check the OpenCV project page.
How do I get support for the OpenCV library?
Please check the OpenCV FAQ for answers to common questions as well as information on where to submit bug reports.
How do I submit requests for computer vision functions to be supported in the Intel IPP?
Please submit your Intel IPP feature requests and problem reports to Intel® Premier Support. You can also participate in the Intel IPP discussion forum.
Additional Resources
Learning-Based Comuter Vision with OpenCV library