NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Building OpenCV for ARM Cortex-A8

From Texas Instruments Wiki
Jump to: navigation, search

Important Note:

The software discussed on this site is available for download, but is no longer actively developed. This wiki is in maintenance mode so the information on this wiki may not be current. The software is supported on OMAP Processors E2E forum


Introduction:[edit]

This wiki provides instructions that specify how to building OpenCV for ARM Cortex-A8 platform using Cmake in a linux environment. The instructions below have been tested for OpenCV 2.2 by cross compiling it on a Ubuntu 10.04 machine. The toolchain is Codesourcery 2010.12.

Build Instructions[edit]

OpenCV 2.2 uses cmake to build. Cmake is a meta-makefile system that generates makefiles. We need to install this first.

  • Update Ubuntu to install and setup cmake
  $ sudo apt-get install cmake cmake-curses-gui
  $ export PATH=$PATH:/opt/arm-2010.12/bin
  $ tar -jxf OpenCV-2.2.0.tar.bz2
  • Cmake supports building outside the source tree. We will use this method to build OpenCV. So, create a directory in $HOME as build
  $ mkdir ~/build && cd ~/build
  • We need to now create a toolchain.cmake file that we will pass to cmake so that it knows how to cross-compile.
  $ vi toolchain.cmake
  • Add the following to toolchain.cmake and save it. This assumes that your NFS targetfs is at ~/targetfs
  set( CMAKE_SYSTEM_NAME Linux )
  set( CMAKE_SYSTEM_PROCESSOR arm )
  set( CMAKE_C_COMPILER arm-none-linux-gnueabi-gcc )
  set( CMAKE_CXX_COMPILER arm-none-linux-gnueabi-g++ )
  set( CMAKE_FIND_ROOT_PATH ~/targetfs )

Important: The CMake build setup in OpenCV 2.2 and earlier does not have NEON ENABLE flag to to take advantage of neon accelearation. Hence please make the following modifications to the file CMakeLists.txt in OpenCV 2.2 to enable neon acceleration.

         # Other optimizations 
         if(USE_O2)    
                set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O2 -mfpu=neon")
         endif()

This may not be required in later versions of OpenCV since OpenCV 2.3 has the option to enable neon in the CMake build process.

  • Now we run cmake to process and generate makefile
  $ cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../OpenCV-2.2.0/
  • When cross compiling for ARM, I found that some items do not build. So, we need to use the cmake curses gui to customize cmake output and re-generate the makefile before we can build. Now launch the cmake curses gui to customize the make file generation
  $ ccmake .
  • 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
    • BUILD_NEW_PYTHON_SUPPORT
    • BUILD_TESTS
    • WITH_1394
    • WITH_CUDA
    • WITH_EIGEN2
    • WITH_FFMPEG
    • WITH_GSTREAMER
    • WITH_GTK
    • WITH_JASPER
    • WITH_JPEG
    • WITH_OPENEXR
    • WITH_PNG
    • WITH_PVAPI
    • WITH_QT
    • WITH_QT_OPENGL
    • WITH_TBB
    • WITH_TIFF
    • WITH_UNICAP
    • WITH_V4L
    • WITH_XINE

Note: Do not forget to keep the USE_O2 option ON in the configuration to take adavntage of neon acceleration that you added to this option

  • Now, press 'c' to configure and 'g' to generate the makefiles again.
  • Now you are ready to build OpenCV. Run make from the command line and it should generate the OpenCV libraries. You can try to customize the build by turning on the various options that we disabled earlier and see if it builds for you.
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Building OpenCV for ARM Cortex-A8 here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Building OpenCV for ARM Cortex-A8 here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Building OpenCV for ARM Cortex-A8 here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity