This wiki will walk you through the process of cross compiling the latest (bleeding edge) OpenCV library with SIMD optimization for the dual core ARM cortex-a9 based Pandaboard ES (OMAP 4460).
The host computer is assumed to be running linux (especially Ubuntu).
Obtain the cross compilation tools for the Pandaboard ES
Refer to theÂ Setting-up-a-cross-compiling-environment-to-build-linux-applications-for-embedded-targets using scratchbox2 Â ORÂ Setting up an environment using chroot for developing applications for embedded targetsÂ wiki for more details on how to do this.
OR simply proceed with :
sudo apt-get install gcc-arm-linux-gnueabihf
Requirements for building OpenCV
The following packages are needed for cross compiling OpenCV on the host computer.
- Cmake 2.6+
- python 2.6
In case you don’t have any of these, install these first before proceeding.
- Get opencv source and prepare to build
mkdir opencv cd opencv git clone https://github.com/Itseez/opencv.git cd opencv-master mkdir build cd build
- Edit Cmake variables to tell it to use the cross compiler.
add these lines at appropriate place in the file:
<code>set( CMAKE_C_COMPILER gcc-arm-linux-gnueabihf) set( CMAKE_CXX_COMPILER g++-arm-linux-gnueabihf)
NOTE:in case you installed a different tool chain like the codesourcery’s toolchain, replace the compiler with your correct compiler prefixes)
Set additional C_FLAGS for utilizing the hardware to the fullest:
set(CMAKE_C_FLAGS "-mcpu=cortex-a9 -O3 -mfloat-abi=hard -ftree-vectorize -ftree-vectorizer-verbose=9" CACHE STRING "c flags")
cmake -DUSE_NEON=ON -DWITH_TBB=ON -DBUILD_TBB=ON -DBUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake ../ |& tee LOG_OF_CMAKE_OUTPUT.txt
** flags need explanation? (To be added on request) **
Look at the LOG_OF_CMAKE_OUTPUT.txt to see what exactly happend.
Run Cmake curses GUI to enable/disable OpenCV related configurations:
You can install Cmake curses GUI by using
sudo apt-get install ccmake
Now run Cmake curses GUI
(Don’t forget the dot !)
This will bring up a screen full of options that can be edited. Make sure that the following items areÂ OFF. If it is ON, you can toggle it by scrolling to the option and hitting Enter
Make sure you runÂ
ccmake .Â and turnÂ OFFÂ these parameters otherwise you may get some build errors.
Now go ahead and run make by entering:
make |& tee log_of_make.txt
The log_of_make.txt will be use full for future reference or in case of errors. Since theÂ
ftree-vetorizer-verbose=9Â (Value is from 1 to 9. 9 being the most verbose level) flag was used, the output contains detail information about what was vectorized by the compiler (for SIMD) like how many loops were vectorized in a functions etc…
To build OpenCV 2.4.0 with libjpeg-turbo you need:
build libjpeg-turbo as static library
configure OpenCV with the following command:
cmake -DWITH_JPEG=ON -DBUILD_JPEG=OFF -DJPEG_INCLUDE_DIR=/path/to/libjepeg-turbo/include/ -DJPEG_LIBRARY=/path/to/libjpeg-turbo/lib/libjpeg.a /path/to/OpenCV
If you followed theÂ Installing libjpeg turbo on pandaboard with vectorization for SIMD utilizing the neon co processorÂ wiki to install libjepg-turbo, you can install openCV with libjepg-turbo by using the following cmake command from the build directory:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_EXAMPLES=ON -DWITH_JPEG=ON -DBUILD_JPEG=OFF -DJPEG_INCLUDE_DIR=/opt/libjpeg-turbo/include/ -DJPEG_LIBRARY=/opt/libjpeg-turbo/lib/libjpeg.a -DUSE_NEON=ON -DWITH_TBB=ON ../ |& tee log_of_cmake.txt