0% found this document useful (0 votes)
77 views

Building OpenCV On Ubuntu Hardfloat Rootfs For i.MX6Q

This document provides steps to build OpenCV on a Freescale i.MX6Q board running Ubuntu. It involves installing dependencies like CMake, downloading and building OpenCV source, and configuring options. Key steps include installing dependencies like libgtk2.0-dev, building OpenCV with NEON support enabled, and testing with OpenCV samples and own applications. The process takes a few hours and results in OpenCV being installed and available for use.

Uploaded by

vinod
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Building OpenCV On Ubuntu Hardfloat Rootfs For i.MX6Q

This document provides steps to build OpenCV on a Freescale i.MX6Q board running Ubuntu. It involves installing dependencies like CMake, downloading and building OpenCV source, and configuring options. Key steps include installing dependencies like libgtk2.0-dev, building OpenCV with NEON support enabled, and testing with OpenCV samples and own applications. The process takes a few hours and results in OpenCV being installed and available for use.

Uploaded by

vinod
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Building OpenCV on Freescale’s i.

MX6Q
Building environment:
1) Platform: Freescale i.MX6Q
2) Kernel: 3.0.35
3) RFS: linaro-alip (ubuntu hardfloat rootfs for imx6d/q)
4) Gcc: 4.6.3 ( >= 4.3 is recommended )

Step 1 – Installing dependences and CMake tools


1) Assume you already have the ubuntu(linaro-alip) running on i.MX6 sabre board and the internet
on the board is avaliable.

2) Install libgtk2.0-dev
$ sudo apt-get install libgtk2.0-dev

3) Install libv4l-dev and v4l-utils


$ sudo apt-get install libv4l-dev v4l-utils
$ sudo ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h

4) Install ffmpeg
$ sudo apt-get install libavformat-dev libswscale-dev

5) Install CMake tool. ( >=2.6 is recommended) (More about CMake please refer to
http://www.cmake.org/)
$ sudo apt-get install cmake cmake-curses-gui

Now, you have all the necessary dependences built for OpenCV 2.4.X.

Step 2 – Building and installing OpenCV

1) Download opencv-2.4.6.1.tar.gz
http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.6.1/
(Note: web camera for opencv 2.4.6 doesn’t work, don’t download this version. Detail please refer to
http://opencv.org/hot-fix-for-opencv-2-4-6.html )

2) Untar the package in home directory and create a building directory.


$ tar xzvf opencv-2.4.6.1.tar.gz
$ mkdir build_opencv
$ cd build_opencv
3) Edit the file ~/opencv-2.4.6.1/cmake/OpenCVCompilerOptions.cmake to build with NEON.
change
set(OPENCV_EXTRA_FLAGS_RELEASE “”)
to
set(OPENCV_EXTRA_FLAGS_RELEASE “-O2 -mfpu=neon”)

4) Configure the opencv and generate makefile via CMake. CMake is a cross-platform build system
generator. Note that CMake supports building out of source.
$ cmake ../opencv-2.4.6.1
$ ccmake . (Note: ccmake is the curses interface for cmake)

Configure the options according to your requirements, you could choose any modules
opencv_XX to build. My configuration looks as following:
ANT_EXECUTABLE ANT_EXECUTABLE-NOTFOUND
BUILD_DOCS OFF
BUILD_EXAMPLES OFF
BUILD_JASPER OFF
BUILD_JPEG OFF
BUILD_OPENEXR OFF
BUILD_PACKAGE ON
BUILD_PERF_TESTS OFF
BUILD_PNG OFF
BUILD_SHARED_LIBS ON
BUILD_TBB OFF
BUILD_TESTS OFF
BUILD_TIFF OFF
BUILD_WITH_DEBUG_INFO ON
BUILD_ZLIB OFF
BUILD_opencv_apps ON
BUILD_opencv_calib3d ON
BUILD_opencv_contrib ON
BUILD_opencv_core ON
BUILD_opencv_features2d ON
BUILD_opencv_flann ON
BUILD_opencv_gpu ON
BUILD_opencv_highgui ON
BUILD_opencv_imgproc ON
BUILD_opencv_legacy ON
BUILD_opencv_ml ON
BUILD_opencv_nonfree ON
BUILD_opencv_objdetect ON
BUILD_opencv_ocl ON
BUILD_opencv_photo ON
BUILD_opencv_stitching ON
BUILD_opencv_superres ON
BUILD_opencv_ts ON
BUILD_opencv_video ON
BUILD_opencv_videostab ON
BUILD_opencv_world OFF
BZIP2_LIBRARIES BZIP2_LIBRARIES-NOTFOUND
CLAMDBLAS_INCLUDE_DIR CLAMDBLAS_INCLUDE_DIR-NOTFOUND
CLAMDBLAS_LIBRARY CLAMDBLAS_LIBRARY-NOTFOUND
CLAMDBLAS_ROOT_DIR CLAMDBLAS_ROOT_DIR-NOTFOUND
CLAMDFFT_INCLUDE_DIR CLAMDFFT_INCLUDE_DIR-NOTFOUND
CLAMDFFT_LIBRARY CLAMDFFT_LIBRARY-NOTFOUND
CLAMDFFT_ROOT_DIR CLAMDFFT_ROOT_DIR-NOTFOUND
CMAKE_BUILD_TYPE
CMAKE_CONFIGURATION_TYPES Debug;Release
CMAKE_INSTALL_PREFIX /usr/local
CMAKE_VERBOSE OFF
CUDA_BUILD_CUBIN OFF
CUDA_BUILD_EMULATION OFF
CUDA_SDK_ROOT_DIR CUDA_SDK_ROOT_DIR-NOTFOUND
CUDA_TOOLKIT_ROOT_DIR CUDA_TOOLKIT_ROOT_DIR-NOTFOUND
CUDA_VERBOSE_BUILD OFF
EIGEN_INCLUDE_PATH EIGEN_INCLUDE_PATH-NOTFOUND
ENABLE_NOISY_WARNINGS OFF
ENABLE_OMIT_FRAME_POINTER ON
ENABLE_PRECOMPILED_HEADERS ON
ENABLE_PROFILING OFF
ENABLE_SOLUTION_FOLDERS OFF
EXECUTABLE_OUTPUT_PATH /home/linaro/build_opencv_2.4.5/bin
GIGEAPI_INCLUDE_PATH GIGEAPI_INCLUDE_PATH-NOTFOUND
GIGEAPI_LIBRARIES GIGEAPI_LIBRARIES-NOTFOUND
INSTALL_C_EXAMPLES OFF
INSTALL_PYTHON_EXAMPLES OFF
INSTALL_TO_MANGLED_PATHS OFF
OPENCL_ROOT_DIR OPENCL_ROOT_DIR-NOTFOUND
OPENCV_CONFIG_FILE_INCLUDE_DIR /home/linaro/build_opencv_2.4.5
OPENCV_WARNINGS_ARE_ERRORS OFF
OPENEXR_INCLUDE_PATH OPENEXR_INCLUDE_PATH-NOTFOUND
OpenCL_DIR OpenCL_DIR-NOTFOUND
PVAPI_INCLUDE_PATH PVAPI_INCLUDE_PATH-NOTFOUND
PYTHON_PACKAGES_PATH lib/python2.7/dist-packages
SPHINX_BUILD SPHINX_BUILD-NOTFOUND
WITH_1394 OFF
WITH_CUBLAS OFF
WITH_CUDA ON
WITH_CUFFT ON
WITH_EIGEN ON
WITH_FFMPEG ON
WITH_GIGEAPI ON
WITH_GSTREAMER ON
WITH_GTK ON
WITH_JASPER ON
WITH_JPEG ON
WITH_NVCUVID OFF
WITH_OPENCL ON
WITH_OPENCLAMDBLAS OFF
WITH_OPENCLAMDFFT OFF
WITH_OPENEXR ON
WITH_OPENGL OFF
WITH_OPENNI OFF
WITH_PNG ON
WITH_PVAPI ON
WITH_QT OFF
WITH_TBB OFF
WITH_TIFF ON
WITH_UNICAP OFF
WITH_V4L ON
WITH_XIMEA OFF
WITH_XINE OFF

Finally, press [c] to configure, then press [g] to generate a new Makefile.

5) Building and installing OpenCV


$ sudo make install

From the output configuration message, you would see some info similar to following:
-- GUI:
-- QT: NO
-- GTK+ 2.x: YES (ver 2.24.10)
-- GThread : YES (ver 2.32.1)
-- GtkGlExt: NO
-- OpenGL support: NO
-- Media I/O:
-- ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.3.4)
-- JPEG: libjpeg (ver 62)
-- PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.46)
-- TIFF: build (ver 42 - 4.0.2)
-- JPEG 2000: build (ver 1.900.1)
-- OpenEXR: build (ver 1.7.1)
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: NO
-- FFMPEG: YES
-- codec: YES (ver 53.35.0)
-- format: YES (ver 53.21.0)
-- util: YES (ver 51.22.1)
-- swscale: YES (ver 2.1.0)
-- gentoo-style: YES
-- GStreamer:
-- base: YES (ver 0.10.36)
-- app: YES (ver 0.10.36)
-- video: YES (ver 0.10.36)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: Using libv4l (ver 0.8.6)
-- XIMEA: NO
-- Xine: NO

It takes about two hours to build, so, be patient. If no errors are reported, you have the OpenCV
installed in the directory /usr/local.

6) Export the environment variance


$ export LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):/usr/local/lib
Step 4 – Make USB camera driver available

The current kernel configuration is putting the UVC camera driver as modules. Thus, to use it, it needs to
manually insert the module as the follows:
$ sudo insmod /lib/modules/3.0.35/kernel/drivers/media/video/uvc/uvcvideo.ko

Alternatively, you can add the following line at the end of the script: /etc/init.d/rc.local
insmod /lib/modules/3.0.35/kernel/drivers/media/video/uvc/uvcvideo.ko

Step 5 – Testing OpenCV on the board

1) Now, you could test OpenCV using the samples in source package.
$cd ~/opencv-2.4.6.1/samples/c (or $cd ~/opencv-2.4.6.1/samples/cpp)
$./build_all.sh

Then you could run all the executable samples in it. For example:
$./facedetect lena.jpg

2) For your own application code, you could use the following compile command to build it.
$ gcc ${SRCS} –o ${OBJ} `pkg-config --cflags --libs opencv`

You might also like