1.由于opencv3.4.1编译成pkgconfig文件opencv.pc后,opencv.pc默认安装在 /usr/local/lib64/pkgconfig/opencv.pc下 ,可以在shell编译脚本中加入:
if [ ! `grep -l "/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig" /etc/profile` ]; then
`echo export "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig" >> /etc/profile` fi
opencv 3.4.1默认安装目录在/usr/local/lib64下,所以将shell编译脚本加入LD_LIBRARY_PATH变量中
if [ ! `grep -l "export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64" /etc/profile` ]; then
`echo export "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64" >> /etc/profile` fi. /etc/profile
2. 由于ffmpeg 4.0的configure文件中有 --enable-libopencv编译选项,其支持--enable-libopencv,但是 默认是不编译的:
--enable-libopencv enable video filtering via libopencv [no]
opencv 3.4.1先编译成库和头文件后,ffmpeg 4.0 configure --enable-libopencv编译的话,会报:
ERROR: libopencv not found
查看ffbuild/config.log,是由于其 /usr/local/include/opencv2/core/cvdef.h 最后的地方定义c++的命名空间namespace cv, 由于其在命名空间中重新定义基础类型和c中的stdint.h一致,顾将其改为:
#ifdef __cplusplus
// Integer types portatibility
#ifdef OPENCV_STDINT_HEADER #include OPENCV_STDINT_HEADER #else #if defined(_MSC_VER) && _MSC_VER < 1600 /* MSVS 2010 */ namespace cv {......
#include <stdint.h>
namespace cv { typedef ::int8_t int8_t; typedef ::uint8_t uint8_t; typedef ::int16_t int16_t; typedef ::uint16_t uint16_t; typedef ::int32_t int32_t; typedef ::uint32_t uint32_t; typedef ::int64_t int64_t; typedef ::uint64_t uint64_t; } #endif #endif#else
#include <stdint.h> #endif这样再编译ffmpeg用configure --enable-libopencv就可以编译通过。
编译完成安装后,可以用ffmpeg/ffplay查看其是否包含opencv:
红箭头标注的地方就是包含opencv了。