源码安装opencv3.4.16+opencv_contrib-3.4.16及卸载
1.下载opencv-3.4.16和opencv_contrib-3.4.16
opencv官网下载链接: opencv
点击 Sources 下载压缩包
在GitHub中下载opencv_contrib-3.4.16:opencv_contrib-3.4.16
选择与opencv相同版本的opencv_contrib
2.解压 opencv-3.4.16和opencv_contrib-3.4.16
unzip opencv-3.4.16.zip
unzip opencv_contrib-3.4.16.zip
将opencv_contrib-3.4.16文件夹移入opencv-3.4.16:
mv opencv_contrib-3.4.16/ opencv-3.4.16/
3.安装opencv依赖包
#更新源
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt install cmake-qt-gui
4.安装opencv
在opencv-3.4.16文件夹中新建build文件夹
cd opencv-3.4.16
mkdir build && cd build
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.16/modules ..
make -j8
sudo make install
5.验证opencv安装成功
#在build文件夹下
cd ../samples/cpp/example_cmake/
cmake .
make
./opencv_example
6.卸载opencv-3.4.16和opencv_contrib-3.4.16
#在opencv-3.4.16文件夹下
cd build
sudo make uninstall
cd ..
sudo rm -r build
#手动删除
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv
/usr/include/opencv2 /usr/local/share/OpenCV
/usr/local/bin/opencv* /usr/local/lib/libopencv*
检查是否删除干净:
pkg-config opencv --libs
pkg-config opencv --modversion