我是靠谱客的博主 安静身影,最近开发中收集的这篇文章主要介绍Ubuntu16.04卸载opencv3.2.0并源码安装opencv4.0.1与opencv_contrib4.0.1,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1.卸载原有opencv

cd opencv-3.2.0/build
sudo make uninstall
sudo rm -r /usr/local/include/opencv2
sudo rm -r /usr/local/include/opencv
sudo rm -r /usr/include/opencv
sudo rm -r /usr/include/opencv2
sudo rm -r /usr/local/share/opencv
sudo rm -r /usr/local/share/OpenCV
sudo rm -r /usr/share/opencv
sudo rm -r /usr/share/OpenCV
sudo rm -r /usr/local/bin/opencv*
sudo rm -r /usr/local/lib/libopencv*
cd /usr
sudo find . -name "*opencv*" | xargs sudo rm -rf

2.下载opencv4.0.1与opencv_contrib4.0.1源码

 https://codeload.github.com/opencv/opencv/zip/4.0.1

https://codeload.github.com/opencv/opencv_contrib/zip/4.0.1

unzip opencv-4.0.1.zip 
unzip opencv_contrib-4.0.1.zip

解压完后两个要放在同一级目录下(不要乱改名字)

3.源码安装opencv4.0.1与opencv_contrib4.0.1

进入到opencv-4.0.1文件夹

mkdir build
cd build

注意下面cmake,把opencv_contrib-4.0.1一块编译了

cmake -D CMAKE_BUILD_TYPE=Release  -D CMAKE_INSTALL_PREFIX=/usr/local  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules  -D OPENCV_GENERATE_PKGCONFIG=YES  -D WITH_1394=OFF ..
make -j16

 一切顺利的话会是下面那个界面(这次安装出奇的顺利,一把就好了)

sudo make install
sudo ldconfig

添加环境变量PKG_CONFIG_PATH~/.bashrc

gedit ~/.bashrc

写入:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

source ~/.bashrc

4.验证安装

cd ../samples/cpp/example_cmake

为了避免电脑没有摄像头,修改写example.cpp第17行的源码

gedit example.cpp 

capture.open(0);改为capture.open("../../data/tree.avi");

cmake .
make

运行代码

./opencv_example

最后

以上就是安静身影为你收集整理的Ubuntu16.04卸载opencv3.2.0并源码安装opencv4.0.1与opencv_contrib4.0.1的全部内容,希望文章能够帮你解决Ubuntu16.04卸载opencv3.2.0并源码安装opencv4.0.1与opencv_contrib4.0.1所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部