ubuntu 18.04安装opencv-2.4.10遇错解决

安装opencv-2.4.10,执行make -j7时报如下错误:

问题1: ffmpeg错误

[ 17%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/grfmt_exr.cpp.o
In file included from /home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/cap_ffmpeg_impl.hpp:60:0,
                 from /home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/cap_ffmpeg.cpp:45:
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/ffmpeg_codecs.hpp:104:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
       ^~~~~~~~~~~~~
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/ffmpeg_codecs.hpp:104:7: note: suggested alternative: ‘AV_CODEC_ID_H264’
     { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
       ^~~~~~~~~~~~~
       AV_CODEC_ID_H264
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/ffmpeg_codecs.hpp:105:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
       ^~~~~~~~~~~~~
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/ffmpeg_codecs.hpp:105:7: note: suggested alternative: ‘AV_CODEC_ID_H264’
     { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
       ^~~~~~~~~~~~~
       AV_CODEC_ID_H264
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/highgui/src/ffmpeg_codecs.hpp:106:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
       ^~~~~~~~~~~~~
......

临时解决办法:

在cmake时,将ffmpeg设置为OFF,即:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/hri/MyInstallSoftware/opencv-2.4.10/build/ -D INSTALL_PYTHON_EXAMPLES=ON -D ENABLE_PRECOMPILED_HEADERS=OFF -D WITH_FFMPEG=OFF ..

[注意:] 上述指令指定opencv安装在/home/hri/MyInstallSoftware/opencv-2.4.10/build/路径上

问题2: contrib模块错误

[ 96%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/colortracker.cpp.o
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
             if (&annotate_img!=NULL) {
                              ^
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp:1016:34: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
                 if (&annotate_img!=NULL) {
                                  ^
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp: In member function ‘cv::ChamferMatcher::Match* cv::ChamferMatcher::Matching::localChamferDistance(cv::Point, cv::Mat&, cv::Mat&, cv::ChamferMatcher::Template*, float)’:
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp:1111:25: error: the compiler can assume that the address of ‘orientation_img’ will never be NULL [-Werror=address]
     if (&orientation_img!=NULL) {
                         ^
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp:1111:5: warning: nonnull argument ‘orientation_img’ compared to NULL [-Wnonnull-compare]
     if (&orientation_img!=NULL) {
     ^~
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp: In member function ‘void cv::ChamferMatcher::Matching::computeDistanceTransform(cv::Mat&, cv::Mat&, cv::Mat&, float, float, float)’:
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp:1016:17: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
                 if (&annotate_img!=NULL) {
                 ^~
/home/hri/MyInstallSoftware/opencv-2.4.10/modules/contrib/src/chamfermatching.cpp:969:13: warning: nonnull argument ‘annotate_img’ compared to NULL [-Wnonnull-compare]
             if (&annotate_img!=NULL) {
             ^~

解决办法:

找到opencv-2.4.10/build/modules/contrib/CMakeFiles/opencv_contrib.dir/flags.make文件,删掉-Werror=address,然后重新 make -j7

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值