没有opencv库的Ubuntu就好像没有珍珠的皇冠
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 python3-dev python3-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
在两个网址分别下载source cide(zip)并解压缩
https://github.com/opencv/opencv/releases/tag/4.5.3
https://github.com/opencv/opencv_contrib/releases/tag/4.5.3
将opencv_contrib-4.5.3 放入opencv文件里并改名为opencv_contrib
进入opencv文件夹
mkdir build
cd build/
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4 -D OPENCV_EXTRA_MODULES_PATH=~/opencv-4.5.3/opencv_contrib/modules/ -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_ENABLE_NONFREE=True ..
cmake指令解释如下
编译中可能会因为两个问题卡住,问题和解决方案如下
问题原因:这个包被墙了,网络不好下载不下来
解决办法:提前下载好再改路径解决
问题原因:未知
解决办法:下载好拷贝到目录下
问题处理后重新cmake
然后查看CPU线程数
grep 'processor' /proc/cpuinfo | sort -u | wc -l
查到是48就用 -j48
sudo make -j48
sudo make install