(没有装contrib)安装必要的环境
sudo apt-get install build-essential 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
sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
下载Opencv+解压
解压后
cd opencv-4.0.1
mkdir release
cd release
运行cmake 生成makefile
cmake -DCMAKE_BUILD_TYPE=Release \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local ..
make 和install
make -j8
sudo make install
之后就是配置c++了,先在/etc/ld.so.conf.d/文件夹下新建一个opencv4.conf,里面写入/usr/local/lib。
cd /etc/ld.so.conf.d/
sudo touch opencv4.conf
sudo sh -c 'echo "/usr/local/lib" > opencv4.conf'
更新pkg-config:
sudo ldconfig
之后可以在终端输入pkg-config --libs opencv4和pkg-config --cflags opencv4检验一下,我的输出如下:(报错)
解决措施:https://blog.csdn.net/PecoHe/article/details/97476135
解决后:
继续测试:
用了opencv4.0/opencv-4.1.2/samples/cpp/example_cmake 下的文件
这个 https://blog.csdn.net/PecoHe/article/details/97476135
报错的原因不知道是不是 我的电脑屏幕把摄像头关了。