ubuntu下搭建opencv环境

一、完全卸载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

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的安装就完成了

你可能感兴趣的:(图形&UI,linux构架,ubuntu,opencv,python)