Linux

10.ubuntu安装opencv

2018-01-15  本文已影响0人  扶桑啊啊

前提:cmake安装成功,cmake安装参考上一篇文章

1.下载opencv压缩包(下载链接:https://github.com/opencv/opencv/releases/tag/3.0.0,或者直接搜官网进行下载),解压

tar -zxvf opencv-3.0.0.tar.gz

2.进入opencv的目录,在此目录下新建release目录,使用cmake-gui命令打开cmake

cd opencv-3.0.0

mkdir release

cmake-gui

3.cmake配置,上面源代码行选择opencv解压文件,下面选择刚刚新建的elease目录,configure—>generate,完成后关闭cmake-gui。

4.在命令行进入release目录,此时make配置

cd release

make

5.配置完成后,make install编译opencv

make  install(若失败报错CMake Error at cmake_install.cmake:36 (FILE):,则可能是当前用户没有权限,请登录到root进行)

6.编译结束后将opencv的库加入路径

进入目录/etc/ld.so.conf.d,找到opencv.conf,若没有,则新建

cd  /etc/ld.so.conf.d

ls

vim  opencv.conf  #进入后 输入/usr/local/lib,:wq保存退出

7.安装依赖文件python-opencv

apt-get install python-opencv

6 测试OpenCV3.0,切换到OpenCV3.0的samples目录下面,并编译samples程序

cd opencv/samples/  

sudo cmake .    #不要忘了这个.(点)

sudo make -j $(nproc)  

7.然后切换到cpp目录下,拷贝一张带头像的照片命名为girl.jpg

cd cpp/  

./cpp-example-facedetect girl.jpg 

这时候果然又出现了错误,我就知道我装个东西没那么容易成功的!!!

观察报错,需要装libgtk2.0-dev和pkg-config,那么重新开始吧!!

apt install libgtk2.0-dev

apt install  pkg-config

重复步骤1-步骤7

终于打开了!!!

参考文章:http://lanbing510.info/2014/12/03/Linux-Opencv.html

http://blog.csdn.net/luoming1994130/article/details/62039241


附opencv卸载过程

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

出现了图上的错误,观察错误的第一句

/bin/sh: 1: cd: can't cd to /home/jixiaofeng/opencv-3.0.0/release

想起来是之前安装在/home/jixiaofeng下的,后来我为了方便统一挪到了/usr下,所以没办法卸载,于是

1.切换到超级用户

2.将整个opencv的文件夹移动到/home/jixiaofeng下

3.重复以上卸载过程

上一篇下一篇

猜你喜欢

热点阅读