To Download this article :
Building OpenCV using Intel System Studio.pdf(344.97 KB)
Introduction
We describe how to use Intel® System Studio to build the OpenCV* based embedded application on Intel platforms. In this paper, we have considered a sample code that is part of OpenCV, how to use different components of Intel® System Studio to build OpenCV sample code.
OpenCV is the most prominent computer vision library and many embedded applications are built using features of OpenCV. It is filled with a lot of features for performing tasks like image registration, tracking, classification and much more. An easy way to improve OpenCV application performance on Intel Architecture is to re build using components of Intel® System Studio like Intel® C++ compiler and Intel® IPP.
Intel® System Studio
Intel® System Studio a new comprehensive integrated tool suite provides developers with advanced system tools and technologies that help accelerate the delivery of the next generation power efficient, high performance, and reliable embedded and mobile devices.
To get more information about Intel® System Studio – http://software.intel.com/en-us/intel-system-studio
Intel® C++ Compiler:
Intel® C++ Compiler delivers outstanding performance for your applications as they run on systems using Intel® Atom or Intel® Core™ or Xeon® processors and IA-compatible processors. The Intel® C++ Compiler can generate code for IA-32, Intel® 64, and Intel® Many Integrated Core Architecture (Intel® MIC Architecture) applications on Intel®-based Linux* system. IA-32 architecture applications (32-bit) can run on all Intel®-based Linux systems. Intel® 64 architecture applications can run only on Intel® 64 architecture-based Linux systems. You can use the compiler on the command line or in the Eclipse* integrated development environment.
Some of important key features are
- Parallel C/C++ language extension support
- Auto-vectorization taking advantage of Intel® AVX instruction
- SSSE3 for Intel® Atom™ Processor targeted applications
- Compatibility with existing GNU* Compiler generated code base
- Cross-build support for 1.2, and CE Linux* PR28
Refer to Intel C++ compiler 13.0 reference manual for more information about new features.
http://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/index.htm
Intel® Integrated Performance Primitives (Intel® IPP)
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. Intel® IPP software building blocks are highly optimized using SSE and Intel® AVX instruction sets so your application will perform faster than what an optimized compiler can produce alone. More information about Intel® IPP can be retrieved at http://software.intel.com/en-us/intel-ipp
Building OpenCV based application using Intel® System Studio
To take benefit of Intel® System Studio components, step by step approach will be used.
![]()
- Download and install Intel® System Studio
- Configure Intel® Compiler and Intel® IPP
- Build OpenCv application with Intel® C++ Compiler
- Modify 'cmake' file to enable Intel® IPP
- Build OpenCV with Intel® Compiler and Intel® IPP
- Use Intel® Inspector 2013 for Systems to find any memory and threading issues
- Power analysis using Intel® VTune Amplifier 2013 for Systems
In the paper we will be focusing on only building OpenCV sample with Intel® compiler and Intel® IPP (up to step 5).
Step 1: Download and install Intel® System Studio
Download Intel® System Studio from – http://software.intel.com/en-us/intel-system-studio
The default installation directory:
/opt/intel/ system_studio_2013.0.xxxx /
Step 2: Configure Intel® C++ Compiler and Intel® IPP
Set the environment variables for a terminal window using one of the following (replace "intel64" with "ia32" if you are using a 32-bit platform).
For csh/tcsh:
$ source /opt/intel/system_studio_2013.0.xxxx/bin/iccvars.csh intel64
For bash:
$ source /opt/intel/Intel_system_studio_2013.0.xxxx/bin/iccvars.sh intel64
To invoke the installed compilers:
For C++: icpc
For C: icc
Step 3: Build OpenCv sample with Intel® C++ Compiler
icc morophology2.cpp `pkg-config --cflags --libs opencv` -lm -lstdc++
Step 4: Modify 'OpenCVFindIPP.cmake' file to enable Intel® IPP
Original file:
if (IPP_X64)
if(NOT EXISTS ${IPP_ROOT_DIR}/../intel64)
message(SEND_ERROR "IPP EM64T libraries not found")
endif()
else()
if(NOT EXISTS ${IPP_ROOT_DIR}../ia32)
message(SEND_ERROR "IPP IA32 libraries not found")
endif()
endif()
Modified file:
if (IPP_X64)
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64)
message(SEND_ERROR "IPP EM64T libraries not found")
endif()
else()
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/ia32)
message(SEND_ERROR "IPP IA32 libraries not found")
endif()
endif()
Run 'cmake' command as follows to verify Intel® IPP support
$ cmake -D CMAKE_BUILD_TYPE=RELEASE /usr/OpenCv-2.4.3
You will get third party libraries support information as below
Other third-party libraries:
Use IPP NO
Use TBB NO
Use Cuda NO
Use OpenCL NO
Use Eigen NO
To switch 'ON' IPP support, run following command
$ cmake -D WITH_IPP=ON
You will get third party libraries support information as below
![]()
Finally type "make" and it should start compiling with IPP.
Future work
Using Intel® Inspector 2013 for Systems and Intel® VTune Amplifier 2013 for Systems to analyze Intel® IPP integrated OpenCV based samples (steps which are mentioned in Building OpenCV based application using Intel® System Studio)
Step 6: Use Intel® Inspector 2013 for Systems to find any memory and threading issues
Step 7: Power analysis using Intel® VTune Amplifier 2013 for Systems
Summary
Intel® System Studio is a comprehensive and integrated tool suite that provides developers with advanced system tools and technologies to help accelerate the delivery of the next generation power efficient, high performance, and reliable embedded and mobile devices.
In this paper, we showed how to build OpenCV based sample using Intel® Compiler and Intel® IPP.
Intel® C++ compiler supports vectorization, which can generate Streaming SIMD Extensions (SSE) instructions. Use of such instructions through the compiler can lead to improved application performance on Intel architectures. Intel IPP library provides low-level, but high performance basic image and video processing functions. It is better to integrate Intel® 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 Intel® IPP function call has the best performance.
Reference
http://software.intel.com/en-us/blogs/2010/12/29/using-the-intel-ipp-library-in-an-embedded-system-on-non-standard-operating-systems