卸载
首先进入有安装路径配置文件install_manifest.txt(是关于OpenCV配置的路径),我的是在home目录下的opencv:
cd /home/hy/opencv/build
make uninstall//卸载掉配置路径中的文件
sudo rm -r build//删除build文件
//删除掉环境中有关的其余包
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*
cd /home/hy
chmod a+x opencv//给opencv权限
rm -r opencv//如果删除还是有文件权限不够,可以继续给相应文件权限,chomd a+x 文件名
使用此方法,本人成功卸载掉安装错误的opencv
重新安装
(opencv下载官网:http://opencv.org/downloads.html)
这里下载安装opencv3.0.2.zip
unzip opencv-3.2.0.zip #解压
sudo cp ./opencv-3.2.0 /home #将文件复制到home目录下
sudo mv opencv-3.2.0 opencv #更名
//创建编译文件夹
cd opencv
mkdir build#创建build文件夹
cd build
//配置
sudo apt install cmake
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
//编译
make -j16 #如果机器性能不太好,可以直接make
编译成功
//编译成功后,开始安装opencv
sudo make install
安装好的opencv版本查看
pkg-config --modversion opencv