环境: opensuse opencv3.4.1 交叉编译器arm-openwrt-linux 作者:帅得不敢出门
选择右边的"clone or download"按钮进行下载,选择下载zip
我下的是opencv-3.4.1.zip, 3.4.1的版本号
下载,因为这个相对会小些,所以我选择git直接下载,大家可以下载3.4.1的zip的包,版本要与opencv的版本一致就行,下zip会快些
git clone
与opencv同一文件夹下
解压
然后cd opencv-3.4.1
编译pc端的:
mkdir build && cd build
编译
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ ../
如果要编译python3的请在cmake 后面加-D BUILD_opencv_python3=ON
make -j4
出错:
opencv-3.4.1/modules/python/src2/cv2.cpp:14:10: fatal error: numpy/ndarrayobject.h: 没有那个文件或目录
#include
compilation terminated.
出错:
-- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
-- Looking for dlerror in dl
-- Looking for dlerror in dl - found
-- Caffe: NO
-- Protobuf: NO
-- Glog: NO
CMake Error at /home/zm/下载/opencv_contrib/modules/datasets/CMakeLists.txt:5 (ocv_append_source_files_cxx_compiler_options):
Unknown CMake command "ocv_append_source_files_cxx_compiler_options".
这是因为open_contrib版本与opencv版本不一致导致,进入open_contrib源码目录,执行git checkout 3.4.1,或者官网下载open_contrib.3.4.1.zip
解决方法:
安装python2-numpy-devel
编译成功后安装
sudo make install
编译arm端 :
cp platforms/linux/arm-gnueabi.toolchain.cmake platforms/linux/arm-openwrt.toolchain.cmake
编辑platforms/linux/arm-openwrt.toolchain.cmake
因为我的交叉编译器前缀是xx
set(GNU_MACHINE "arm-linux-gnueabi" CACHE STRING "GNU compiler triple")
改成
set(GNU_MACHINE "arm-openwrt-linux" CACHE STRING "GNU compiler triple")
mkdir build_openwrt
cd build_openwrt
cmake -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_TOOLCHAIN_FILE="../platforms/linux/arm-openwrt.toolchain.cmake" -DCMAKE_CXX_FLAGS="-DTBB_USE_GCC_BUILTINS=1 -D__TBB_64BIT_ATOMICS=0 -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4" -DSOFTFP=ON -DWITH_OPENCL=OFF -DWITH_TBB=ON -DWITH_V4L=ON -DHAVE_CAMV4L2=ON -DENABLE_VFPV3=ON -DENABLE_NEON=ON -DBUILD_TESTS=OFF -DINSTALL_PYTHON_EXAMPLES=OFF -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DWITH_FFMPEG=ON -DHAVE_FFMPEG=ON ../
#-D FFMPEG_INCLUDE_DIR="/home/zengming/download/ffmpeglib/include" -D FFMPEG_LIB_DIR="/home/zengming/download/fmpeglig/lib" ../
如果不加-DSOFTFP=ON有可能会出现找不到交叉编译器的情况
-- The CXX compiler identification is GNU 7.3.1
-- The C compiler identification is GNU 7.3.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake:45 (message):
The C++ compiler
"/usr/bin/c++"
开始编译
make -j4
make install
阅读(2457) | 评论(0) | 转发(0) |