1、安装依赖包
sudo apt install build-essential
sudo apt install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
2、编译
mkdir build_dir
cd build_dir
cmake ../opencv-3.3.0 -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local/opencv-3.3.0
sudo make
sudo make install
3、可能碰到的问题
make的时候报类似的错误:
error: 'CODEC_FLAG_GLOBAL_HEADER' was not declared in this scope
方法:
进入opencv源码文件夹,打开文件
opencv-3.3.0/modules/videoio/src/cap_ffmpeg_impl.hpp ,再文件最顶端添加以下内容
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
#define AVFMT_RAWPICTURE 0x0020
然后再重新make 即可
附:
opencv-3.3.0 下载链接
链接: 提取码: 51e6
阅读(1290) | 评论(0) | 转发(0) |