opencv3.4.0的安装

毕业设计的需求,需要将opencv3.3.0换成opencv3.4.0,在这里记录一下。
1.下载文件
还是去官网下载方便一点
https://opencv.org/releases.html
解压
unzip opencv-3.4.0.zip
2.执行

cd opencv-3.4.0
mkdir build                                             #建立文件夹
cd build                                                  #进入文件夹
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..                                     #cmake生成makefile文件,CMAKE_INSTALL_PREFIX后为编译路径
make -j7                                                #编译
sudo make install                                  #安装

3.配置环境变量

$ sudo gedit /etc/ld.so.conf.d/opencv.conf       #末尾加入/usr/local/lib,保存退出
$ sudo ldconfig                                  #使配置生效
#打开/etc/bash.bashrc;
$ sudo gedit /etc/bash.bashrc
#末尾加入
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 
export PKG_CONFIG_PATH
#保存退出
$ sudo source /etc/bash.bashrc                    #使配置生效
$ sudo updatedb                                   #更新database

4.最后检查一下版本

pkg-config --modversion opencv

安装成功
opencv3.4.0的安装_第1张图片
5.附一段删除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

6.配置python中opencv

 pip2 install opencv-python
 pip3 install opencv-python

7.问题总结
空间不足会出现问题

参考:https://blog.csdn.net/qiaoji6073/article/details/76572801

你可能感兴趣的:(opencv3.4.0的安装)