如何准备环境以便在Ubuntu 11.10上正确编译OpenCV 2.3.1?
我正在关注OpenCV install guide,但它的说明令人沮丧地复杂。
但是,我把它提炼成以下脚本:
sudo apt-get install --yes cmake libjpeg62 libjpeg62-dev libtiff4 libtiff4-dev libjasper1 libjasper-dev libpng12-0 libpng12-dev libavformat-dev libswscale-dev openexr zlibc zlib1g zlib1g-dev python2.7-dev libgtk-3-dev gcc g++ libtbb-dev
cd /tmp
wget --output-document=OpenCV-2.3.1a.tar.bz2 http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2/download?use_mirror=iweb
tar -xvjf OpenCV-2.3.1a.tar.bz2
cd OpenCV-2.3.1
mkdir release
cd release
time cmake -D WITH_TBB=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
time make
所有内容都成功运行,当然make
退出时出现错误:
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1339:41: error: ‘guess_format’ was not declared in this scope
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1367:31: error: ‘av_alloc_format_context’ was not declared in this scope
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1411:9: warning: ‘int av_set_parameters(AVFormatContext*, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1363) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1411:35: warning: ‘int av_set_parameters(AVFormatContext*, AVFormatParameters*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1363) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1415:5: warning: ‘void dump_format(AVFormatContext*, int, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1485) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1415:35: warning: ‘void dump_format(AVFormatContext*, int, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1485) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1442:15: warning: ‘int avcodec_open(AVCodecContext*, AVCodec*)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3650) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1442:36: warning: ‘int avcodec_open(AVCodecContext*, AVCodec*)’ is deprecated (declared at /usr/include/libavcodec/avcodec.h:3650) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1479:13: warning: ‘int url_fopen(AVIOContext**, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avio.h:278) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1479:52: warning: ‘int url_fopen(AVIOContext**, const char*, int)’ is deprecated (declared at /usr/include/libavformat/avio.h:278) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1485:5: warning: ‘int av_write_header(AVFormatContext*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1421) [-Wdeprecated-declarations]
/tmp/OpenCV-2.3.1/modules/highgui/src/cap_ffmpeg_impl.hpp:1485:25: warning: ‘int av_write_header(AVFormatContext*)’ is deprecated (declared at /usr/include/libavformat/avformat.h:1421) [-Wdeprecated-declarations]
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o] Error 1
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make: *** [all] Error 2
如何解决此错误?
答案 0 :(得分:2)
我认为你没有好的ffmpeg库。至少有两种解决方案。 如果您需要ffmpeg,请尝试安装它,这要归功于:
sudo apt-get install libavformat-dev libswscale-dev
如果您不需要在openCV应用程序中使用ffmpeg,可以尝试禁用它添加:
WITH_FFMPEG=OFF WITH_GSTREAMER=OFF
到您的cmake配置行。
干杯,