一、安装python3.5+(或使用已安装版)
yum install -y python36
yum install -y python36-setuptools
yum install -y python36-pip
二、安装numpy
pip3 install numpy(==1.15.1,可选 )-i https://pypi.tuna.tsinghua.edu.cn/simple
三、其他包根据错误提供安装即可
四、编译安装opencv-python(官方不支持pip方式安装arm版opencv)
wget https://github.com/opencv/opencv_contrib/archive/3.4.10.zip
wget https://github.com/opencv/opencv/archive/3.4.10.zip
解压以上目录到/root/opencv-build,解压后有两个目录:
/root/opencv-build/opencv-3.4.10
/root/opencv-build/opencv_contrib-3.4.10
进入/root/opencv-build/opencv-3.4.10目录开始编译:
1.mkdir build & cd build
2.cmake -D BUILD_opencv_python3=YES -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4 -D OPENCV_EXTRA_MODULES=../../opencv_contrib-3.4.10/modules -D PYTHON3_LIBRARIES=/usr/lib64/libpython3.6m.so -D PYTHON3_EXECUTABLE=/usr/bin/python3 -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib64/python3.6/site-packages/numpy/core/include/ -D PYTHON3_PACKAGES_PATH=/usr/local/lib64/python3.6/site-packages ..
3.make -j8
4.make install
五、测试
python3 ,import cv2--如不报错则安装成功
六、注意事项
注意cmake过程中的各路径,cmake建议3.x以上,gcc建议5.x以上,要求支持C++11
七、遇到的坑
--没有blas,下载编译即可,最后copy文件到lib和include目录
wget http://www.netlib.org/blas/blas-3.8.0.tgz
cd BLAS-3.8.0/
make -j8
ar rv libblas.a *.o
wget http://www.netlib.org/blas/blast-forum/cblas.tgz
cd CBLAS/
cp ../BLAS-3.8.0/libblas.a ./testing/
Make -j8
--编译后cp三个文件
cp ./include/cblas.h /usr/include/
cp cblas_LINUX.a /usr/lib/
cp libblas.a /usr/lib/
来源:oschina
链接:https://my.oschina.net/farces/blog/4278705