opencv3.2安装成功,但使用VideoCapture时出现链接错误

opencv3.2 已经在Ubuntu14.04安装成功了;

使用VideoCapture时出现链接出错

//usr/local/lib/libopencv_videoio.so: undefined reference to `avformat_open_input@LIBAVFORMAT_54'

 

去/usr/local/lib下搜索,ffmpeg安装的时58版本,和54 不对;

 

由于我是先安装的opencv3.2,后安装的ffmpeg4可能导致opencv没检出出来使用默认54版本号;重装opencv

Unzip opencv-3.2.0.zip

Cd opencv-3.2.0

mkdir release

cd release

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/cui/arcsoft/opencv/install/opencv_contrib-3.2.0/modules ../

 

如果遇到这样的错误:-- ICV: Downloading ippicv_linux_20151201.tgz... CMake Error at 3rdparty/ippicv/downloader.cmake:73 (file): file DOWNLOAD HASH mismatch

安装OpenCv 3.2的过程中要下载ippicv_linux_20151201,由于网络的原因,这个文件经常会下载失败。

解决的办法是手动下载:

https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz

下载ippicv_linux_20151201.tgz 并粘贴(替换)到目录opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/

重新cmake

 make编译

 

在配置时,可以看到opencv已经检测出了版本号时58;

但编译时有出错 error: ‘CODEC_FLAG_GLOBAL_HEADER’ was not declared in this scope

参考https://blog.csdn.net/guo_lei_lamant/article/details/81568346

opencv-3.2.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

编译通过;

sudo  make install

你可能感兴趣的:(OpenCV)