您的位置:首页 > 运维架构

OpenCV2.3.1在Ubuntu11.10上编译错误解决方法

2011-11-26 21:53 302 查看
经过上次介绍Ubuntu
全新编译安装 OpenCV 2.3之后,很快,新的2.3.1又出来了,经不住诱惑,马上试试但是,不知道大家在编译最新的2.3.1的时候出现错误没,反正我出现错误了,具体编译错误如下:
[ 35%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o
In file included from /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::reopen()’:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:486:5: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:486:52: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:494:5: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:494:50: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::open(const char*)’:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:524:15: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:524:63: warning: ‘int av_open_input_file(AVFormatContext**, const char*, AVInputFormat*, int, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1050) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:541:9: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:541:54: warning: ‘int avcodec_thread_init(AVCodecContext*, int)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3611) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:547:13: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::grabFrame()’:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:640:34: error: ‘avcodec_decode_video’ was not declared in this scope
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘const char* icvFFMPEGErrStr(int)’:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:917:10: error: ‘AVERROR_NUMEXPECTED’ was not declared in this scope
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:921:10: error: ‘AVERROR_NOFMT’ was not declared in this scope
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:923:10: error: ‘AVERROR_IO’ was not declared in this scope
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:925:10: error: ‘AVERROR_NOMEM’ was not declared in this scope
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In function ‘AVStream* icv_add_video_stream_FFMPEG(AVFormatContext*, CodecID, int, int, int, double, int)’:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:1012:70: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
In file included from /home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘void CvVideoWriter_FFMPEG::close()’:
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:1298:3: warning: ‘int url_fclose(AVIOContext*)’ is deprecated (declared at /usr/include/libavformat/avio.h:279) [-Wdeprecated-declarations]
/home/xizhibei/OpenCV2.3.1/release/CMakeExternals/Source/OpenCV/modules/highgui/src/cap_ffmpeg_impl.hpp:1298:20: warning: ‘int url_fclose(AVIOContext*)’ is deprecated (declared at /usr/include/libavformat/avio.h:279) [-Wdeprecated-declarations]
很明显,是ffmpeg的问题,在目前的Ubuntu下版本不够高,所以,我就开始一番查找,终于让我找到了一篇好文章:以下开始抄袭,抄袭地址在这:http://ozbots.org/opencv-installation/删掉这些旧的ffmpeg x264 libx264-dev:
sudo apt-get remove ffmpeg x264 libx264-dev
下载x264和ffmpeg所有的依赖:
sudo apt-get update

sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html
yasm zlib1g-dev
安装 gstreamer:
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good
gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg
下载并安装x264.到ftp://ftp.videolan.org/pub/videolan/x264/snapshots/下载个最近的稳定版本snapshot of x264 .
配置下 x264 libraries:
./configure --enable-static

make

sudo make install
下载安装 ffmpeg.到http://ffmpeg.org/download.html下载 ffmpeg version 0.8.x .(实际上,需要Git下载:git clonegit://source.ffmpeg.org/ffmpeg.git,这个好像比较快)注意:
OpenCV2.3.1 以及之前的版本需要 ffmpeg 0.7.x.
配置编译 ffmpeg:
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis
--enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab

make

sudo make install
安装 gtk:
sudo apt-get install libgtk2.0-0 libgtk2.0-dev
安装 libjpeg:
sudo apt-get install libjpeg62 libjpeg62-dev
下载安装 v4l (video for linux).从http://www.linuxtv.org/downloads/v4l-utils/下载 v4l-utils-0.8.5.tar.bz2
编译v4l:
make

sudo make install

抄袭结束,由于编译OpenCV差不多,所以就不抄了。。。具体可参考我的Ubuntu
全新编译安装 OpenCV 2.3

或者上面提到的神级人物的http://ozbots.org/opencv-installation/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: