树莓派3B-编译安装opencv 3.1.0 for Python3.5

sd卡最好先拓展容量:http://www.jianshu.com/p/d8f4f928e2df

编译安装opencv教程见(我没有使用沙箱),http://blog.csdn.net/talkxin/article/details/50471986

我没有使用沙箱,但我用了pyenv,注意一点,使用pyenv安装python时,记得添加生成动态库选项(想了解的看参考链接),opencv的库链接时要用。

compile command for python3.5:

cmake -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
    -D PYTHON3_EXCUTABLE=/usr/bin/python3 \
    -D PYTHON_INCLUDE_DIR=/usr/include/python3.5 \
    -D PYTHON_LIBRARY=/usr/lib/python3.5/config-3.5m-arm-linux-gnueabihf/libpython3.5.so \
    -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/lib/python3/dist-packages/numpy/core/include \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON ..

after install python3.4.5 through pyenv, the cmake commands:

cmake -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
    -D PYTHON3_EXCUTABLE=~/.pyenv/versions/3.4.5/bin/python3 \
    -D PYTHON_INCLUDE_DIR=~/.pyenv/versions/3.4.5/include/python3.4m \
    -D PYTHON_LIBRARY=~/.pyenv/versions/3.4.5/lib/libpython3.4m.so \
    -D PYTHON3_NUMPY_INCLUDE_DIRS=~/.pyenv/versions/3.4.5/lib/python3.4/site-packages/numpy/core/include \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON ..

注意,由于cmake中设置的安装目录是/usr/local/,故安装后记得链接.so file:

cd ~/.pyenv/versions/3.4.5/lib/python3.4/site-packages
ln -s /usr/local/lib/python3.4/site-packages/cv2.cpython-34m.so

Reference:

官方安装教程:http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html
pyenv: http://www.jianshu.com/p/acdb01b1f8a5

你可能感兴趣的:(树莓派3B-编译安装opencv 3.1.0 for Python3.5)