Here are the steps I took to get the OpenCV 3.2.0 working in ARM processor (running linaro 3.14.0). The host machine is running Ubuntu 14.04.

Step 1: Setting up the cross compiler

The compiler used is arm-linux-gnueabihf-g++. It can be installed from Ubuntu software center by looking for “gcc-arm-linux-gnueabihf”.

Step 2: Install dependencies for OpenCV

OpenCV has lot of dependencies, the best way is to do the following first and fix the missing ones later.

Step 3: Download OpenCV and contrib modules (optional)

The source code for opencv and opencv_contrib can be downloaded below.

https://github.com/opencv/opencv

https://github.com/opencv/opencv_contrib

In my case, these two are cloned in the same directory.

Step 4: Build the source code

If everything works fine, it will build and install the files into build_arm/install

Step 5: Build some OpenCV application

Similarly, compile the application using arm-linux-gnueabihf-g++. Some environment variables need to be set.

 

Here are some issues I encountered during the process.

Issue 1: ZLIB

The issue arises when the cmake found the zlib installation in my machine but couldn’t find the zlib.h in the make step.

For example, in the cmake stage it reported:

But in make stage it reported:

You might tried to find the zlib.h in your machine and point to it (zlib.h in /usr/include and zconf.h in /usr/include/x86_64-linux-gnu). But the problem is that the lib file is not compiled for ARM, so it won’t pass the subsequent make stage.

The solution is to not let the cmake find the zlib installed and use the 3rdparty/zlib instead. I downloaded the zlib-1.2.11 source code from the internet and add the path to the beginning of the C_INCLUDE_PATH and CPLUS_INCLUDE_PATH.

The result is that cmake reported:

And the 3rdparty/zlib is compiled using the cross compiler.



 

How to Cross Compile OpenCV 3.2.0 to ARM processor
Tagged on:     

Please tell us what's in your mind ...

%d bloggers like this: