环境:
- ubuntu 16.04
- OpenCV + contrib 3.2.0 (文中附下载链接)
- Python 3.5
基于其他环境的配置应该大同小异。
没时间解释了,直接上车。
更新下系统:
- sudo apt-get update
- sudo apt-get upgrade
安装依赖项:
- sudo apt-get install build-essential cmake pkg-config
- sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
- sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
- sudo apt-get install libxvidcore-dev libx264-dev
- sudo apt-get install libgtk-3-dev
- sudo apt-get install libatlas-base-dev gfortran
- sudo apt-get install python3.5-dev
下载opencv + contrib
- wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
- wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip
开始正式安装
- cd ~/opencv-3.2.0/
- mkdir build
- cd build
- cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_EXECUTABLE=/usr/bin/python3 \
-D PYTHON_INCLUDE_DIR=/usr/include/python3.5 \
-D PYTHON_LIBRARY=/usr/lib/x86_64-Linux-gnu/libpython3.5m.so \
-D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \
-D PYTHON_EXECUTABLE=/usr/lib/python3 \
-D BUILD_EXAMPLES=ON .. - 确保有红框里的内容,如果有,就成功了一半。
- make -j4 (4 代表处理器的核数)
- make clean
- make
- sudo make install
- sudo ldconfig
最后这一步,如果出现:
/sbin/ldconfig.real: /usr/lib/nvidia-375/libEGL.so.1 is not a symbolic link
/sbin/ldconfig.real: /usr/lib32/nvidia-375/libEGL.so.1 is not a symbolic link
如此这般就可以解决:
sudo mv /usr/lib/nvidia-375/libEGL.so.1 /usr/lib/nvidia-375/libEGL.so.1.org
sudo mv /usr/lib32/nvidia-375/libEGL.so.1 /usr/lib32/nvidia-375/libEGL.so.1.org
sudo ln -s /usr/lib/nvidia-375/libEGL.so.375.39 /usr/lib/nvidia-375/libEGL.so.1
sudo ln -s /usr/lib32/nvidia-375/libEGL.so.375.39 /usr/lib32/nvidia-375/libEGL.so.1
http://blog.csdn.net/vola9527/article/details/69487845?locationNum=14&fps=1
时间: 2024-11-03 15:19:31