测试发现原有的OPenCV有问题,决定删掉原系统OPenCV,装新的。
卸载:(删除所有可能存在的文件夹)
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
安装:
1.准备工作
编译环境安装:
sudo apt-get install build-essential
必需包安装:
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
可选包安装:
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
现安装最新的Opencv3.4.1以及Contrib包,以免以后需要
opencv3.4.1链接如下图点击Sources下载得到opencv-3.4.1.zip
或者直接
sudo git clone https://github.com/opencv/opencv/tree/3.4.1
解压之后将opencv_contrib-3.4.1放入opencv-3.4.1文件夹下,在opencv-3.4.1文件夹下打开终端依次输入
mkdirbuild
cd build
cmake-D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.1/modules ..
有可能出现网络不好的情况导致一些包下载不下来,可上网自行下载之后继续安装
编译配置完成之后进行编译:
make -j4
但是遇到报错: fatal error: opencv2/xfeature2d/cuda.hpp:没有那个文件或者目录
找不到比较合适的方法,只好重新编译配置,不加上额外包Contrib
cmake ..
make -j8
make install
安装成功,先跑通程序,Contrib的问题之后再解决。