0

How can I cross compile OpenCV on my ubuntu for arm where it takes a path of python3 include headers and python3 binary automatically by just passing arm Linux root file system path, so it can fetches all required modules automatically like it is doing for x86 machine.

using below cmake configuration, if I pass python3 interpreter it doesn't recognize python3 library, if I remove python3 interpreter from cmake config, it recognizes python3 library and takes python3 interpreter of x86 machine.

cmake \
-DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake \
-DCMAKE_AR=~/Downloads/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar 
-DWITH_CUDA=OFF \
-DBUILD_TIFF=ON \
-DBUILD_opencv_java=ON \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \OFF
-DWITH_EIGEN=ON \
-DWITH_FFMPEG=ON \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-DWITH_GSTREAMER=ON \
-DWITH_FFMPEG=ON \
-DBUILD_opencv_python3=ON \
-DWITH_V4L=ON \
-DWITH_VTK=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DBUILD_opencv_python2=OFF \
-DPYTHON3_EXECUTABLE=~/rootfs/usr/bin/python3.5 \
-DPYTHON3_LIBRARY=~/rootfs/usr/lib/libpython3.5m.so.1.0 \
-DPYTHON3_INCLUDE_DIR=~/rootfs/usr/include/python3.5m/ \
-DPYTHON3_PACKAGES_PATH=~/rootfs/usr/lib/python3.5/site-packages \
-DPYTHON3_NUMPY_INCLUDE_DIRS=~/rootfs/usr/lib/python3.5/site-packages/numpy/core/include/ \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DINSTALL_C_EXAMPLES=OFF  \
-DBUILD_EXAMPLES=ON  \
-DBUILD_SAMPLES=OFF \
-DCMAKE_BUILD_TYPE=RELEASE .. && make -j 16

Thanks,

Akash Gajjar
  • 94
  • 2
  • 8

1 Answers1

0

If you can live with a unofficial version of the OpenCV

You can create virtual environment in python then using pip install OpenCV saved a lot of time for me.

use pip install opencv-python== to select the version you want.

Here's the link

  • yeah, That's temporary solution and will not work in case of arm board has a no network connectivity. yocto sumo build has an opencv3.3 recipes can solve this problem. but I wanted to do it manually cross compiling. – Akash Gajjar Jun 15 '18 at 10:02
  • [Install OpenCV-Python in Ubuntu](https://docs.opencv.org/3.4.1/d2/de6/tutorial_py_setup_in_ubuntu.html) or [Python3 module is named incorrectly when cross-compiling](https://github.com/opencv/opencv/issues/5887) might be of some use – Santhosh Dhaipule Chandrakanth Jun 16 '18 at 04:49