Last active
August 29, 2024 11:09
-
-
Save g40/8418653791110858ce8b9d8c183099f1 to your computer and use it in GitHub Desktop.
How to configure OpenCV with Python3/numpy support in an aarch64 (ARM64) chroot for QEMU compilation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# configure OpenCV with Python/numpy support in an Arm64 chroot on an Intel host. | |
# | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D BUILD_PYTHON3=ON \ | |
-D BUILD_OPENCV_PYTHON2=OFF \ | |
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.1/modules | |
-D WITH_NEON=ON \ | |
-D BUILD_JAVA=OFF \ | |
-D WITH_LAPACK=OFF \ | |
-D BUILD_TESTS=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D BUILD_EXAMPLES=ON \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D WITH_CAROTENE=OFF \ | |
-D WITH_TBB=OFF \ | |
-D WITH_OPENCL=OFF \ | |
-D WITH_NVCUVID=OFF \ | |
-D WITH_OPENCL_SVM=OFF \ | |
-D WITH_OPENCLAMDFFT=OFF \ | |
-D WITH_OPENCLAMDBLAS=OFF \ | |
-D WITH_OPENEXR=OFF \ | |
-D WITH_MATLAB=OFF \ | |
-D WITH_GTK=OFF \ | |
-D WITH_GSTREAMER=OFF \ | |
-D WITH_GPHOTO2=OFF \ | |
-D WITH_FFMPEG=OFF \ | |
-D WITH_CUBLAS=OFF \ | |
-D WITH_CUDA=OFF \ | |
-D WITH_CUFFT=OFF \ | |
-D WITH_EIGEN=OFF \ | |
-D WITH_VTK=OFF \ | |
-D WITH_JASPER=OFF \ | |
-D WITH_WEBP=OFF \ | |
-D WITH_1394=OFF \ | |
-D BUILD_SHARED_LIBS=ON \ | |
-DCMAKE_INSTALL_PREFIX=/usr/local \ | |
-D PYTHON3_LIBRARIES=usr/lib/aarch64-linux-gnu/libpython3.5m.so \ | |
-D PYTHON3_LIBRARY=usr/lib/aarch64-linux-gnu/libpython3.5m.so \ | |
-D PYTHON_INCLUDE_DIRS=/usr/include/python3.5m \ | |
-D PYTHON3_INCLUDE_PATH=/usr/include/python3.5m \ | |
-D PYTHON3_INCLUDE_DIR=/usr/include/python3.5m \ | |
-D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include \ | |
-D PYTHON3_NUMPY_VERSION="1.15.0" \ | |
-DPYTHON_DEFAULT_EXECUTABLE=$(which python3) \ | |
-D CMAKE_TOOLCHAIN_FILE=../opencv-3.4.1/platforms/linux/aarch64-gnu.toolchain.cmake \ | |
../opencv-3.4.1 2>&1 | tee config.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I needed a minimal footprint OpenCV cross-compiled with Python3/numpy support for an Arm64 (aarch64) board with limited resources. i.e. compiling on the target prohibitive in terms of time and awkward to set up (required build artefacts to be on an NFS connected server) so not good for automation.
The chroot in this case was based off a Devuan Arm64 base install. Make sure
qemu-aarch64-static
is installed and thatupdate-binfmts --enable qemu-aarch64
has been run. Running the cmake spell below should then complete successfully with the following options enabled.The critical element here is to specify the numpy version manually. Without it CMake gets into a twist, unable to complete the mission itself, an echo of which still shows up in the configuration process:
and here is the final configuration report: