Opencv 安装/卸载教程

Opencv 安装

Author: Ling Bao
Date: 星期二, 13. 六月 2017 09:18下午 

环境说明: Ubuntu16.04/gcc-5.4.1/g++-5.4.1

1 安装(OpenCV3.1.0为例)

1.1 下载Opencv源码 并解压

tar -zxvf opencv-3.1.0.zip

1.2 安装依赖库
sudo apt-get install gcc g++ cmake pkg-config build-essential
sudo apt-get install libgtk2.0-dev libavcodec-dev libavformat-dev libtiff5-dev libswscale-dev libjasper-dev
1.3 安装
cd opencv-3.1.0
mkdir release && cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j4
sudo make install -j4
1.4 配置pkg-config
sudo vim /etc/ld.so.conf
添加: /usr/local/lib
sudo ldconfig -v
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
查看配置信息: pkg-config –libs opencv
1.5 测试
cd opencv-3.1.0/samples/
cmake .
make
1.6 安装python-opencv
sudo apt-get install python-opencv
测试
python
import cv2

2 卸载(OpenCV3.1.0为例)

2.1 卸载命令(编译目录)

cd opencv-3.1.0/release/
sudo make uninstall
cd ..
sudo rm -r release
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*

2.2 卸载其它
sudo apt-get –purge remove opencv-doc opencv-data python-opencv

3 问题

3.1 unsupported GNU version

问题描述
host_config.h:115:2: error: #error – unsupported GNU version! gcc versions later than 4.9 are not supported!
error – unsupported GNU version! gcc versions later than 4.9 are not supported!
解决方法
在CMakeLists.txt中增加set(CUDA_NVCC_FLAGS “-ccbin gcc-5”)

3.2 OpenCV in Ubuntu 17.04
E: Unable to locate package libjasper-dev
解决方法
echo “deb http://us.archive.ubuntu.com/ubuntu/ yakkety universe” | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install libjasper-dev

你可能感兴趣的:(基础程序安装Blogs)