一、完全卸载opencv
1. 先到opencv编译安装的目录下
sudo make uninstall
cd ..
sudo rm -r build
2.上面最后一行命令有的文件夹不存在会有提示,但是不影响,只要把已安装的opencv的include和lib删掉就行,也可以手动删除,总之删除干净即可。
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*
3.检查是否删除完
pkg-config opencv --libs
pkg-config opencv --modversion文章来源:https://www.toymoban.com/news/detail-470810.html
4.清除干净
sudo apt-get autoremove opencv-doc opencv-data libopencv-dev libopencv2.4-java
libopencv2.4-jni python-opencv libopencv-core2.4 libopencv-gpu2.4 libopencv-ts2.4
libopencv-photo2.4 libopencv-contrib2.4 libopencv-imgproc2.4 libopencv-superres2.4
libopencv-stitching2.4 libopencv-ocl2.4 libopencv-legacy2.4 libopencv-ml2.4 libopencv-
video2.4 libopencv-videostab2.4 libopencv-objdetect2.4 libopencv-calib3d2.4
二、重新安装opencv
安装方法见:OpenCV: Installation in Linux
三、配置环境变量
将opencv的库加入路径
sudo gedit /etc/ld.so.conf/opencv.conf
此时在打开的文件中加入/usr/locall/lib,保存退出
sudo ldconfig
sudo gedit /etc/bash.bashrc
此时在打开的文件末尾加入PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH,保存退出
source /etc/bash.bashrc
四.检验
pkg-config opencv --libs
pkg-config opencv --modversion
至此opencv的安装就完成了文章来源地址https://www.toymoban.com/news/detail-470810.html
到了这里,关于ubuntu下搭建opencv环境的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!