Ubuntu 14.04编译opencv_videoio.dir/src/cap_gstreamer.cpp报错

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/LEON1741/article/details/85038381

今天在研究AR_ToolKit,它需要搭建OpenCV的环境。于是下载了OpenCV的源码进行编译(下载方法就是直接git克隆git clone https://github.com/opencv/opencv)。

编译opencv的过程中,一开始都一帆风顺,不过后来遇到了以下问题:

[ 49%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_gstreamer.cpp.o
In file included from /usr/include/gstreamer-0.10/gst/pbutils/encoding-profile.h:29:0,
                 from /home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp:69:
/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:35:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererStreamInfoClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:83:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererContainerInfoClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:104:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererAudioInfoClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:129:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererVideoInfoClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:159:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererSubtitleInfoClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:202:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererInfoClass;
         ^
In file included from /home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp:69:0:
/usr/include/gstreamer-0.10/gst/pbutils/encoding-profile.h:47:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstEncodingProfileClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/encoding-profile.h:66:9: error: ‘GstEncodingProfileClass’ does not name a type
 typedef GstEncodingProfileClass GstEncodingContainerProfileClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/encoding-profile.h:85:9: error: ‘GstEncodingProfileClass’ does not name a type
 typedef GstEncodingProfileClass GstEncodingVideoProfileClass;
         ^
/usr/include/gstreamer-0.10/gst/pbutils/encoding-profile.h:104:9: error: ‘GstEncodingProfileClass’ does not name a type
 typedef GstEncodingProfileClass GstEncodingAudioProfileClass;
         ^
/home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp: In member function ‘virtual bool GStreamerCapture::grabFrame()’:
/home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp:268:57: error: ‘gst_app_sink_pull_sample’ was not declared in this scope
     sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
                                                         ^
/home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp: In member function ‘virtual bool CvVideoWriter_GStreamer::open(const char*, int, double, CvSize, bool)’:
/home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp:1515:25: error: ‘GST_VIDEO_FORMAT_ENCODED’ was not declared in this scope
         input_pix_fmt = GST_VIDEO_FORMAT_ENCODED;
                         ^
/home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp: In member function ‘virtual bool CvVideoWriter_GStreamer::writeFrame(const IplImage*)’:
/home/leon/open_source/opencv/modules/videoio/src/cap_gstreamer.cpp:1686:26: error: ‘GST_VIDEO_FORMAT_ENCODED’ was not declared in this scope
     if (input_pix_fmt == GST_VIDEO_FORMAT_ENCODED) {
                          ^
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_gstreamer.cpp.o] 错误 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] 错误 2
make: *** [all] 错误 2

提取其中一句来看看:

/usr/include/gstreamer-0.10/gst/pbutils/gstdiscoverer.h:202:9: error: ‘GstMiniObjectClass’ does not name a type
 typedef GstMiniObjectClass GstDiscovererInfoClass;

很明显,与gstreamer-0.10有关。再去分析下CMakeList文件,以gstreamer为关键词查找,发现有如下命令:

OCV_OPTION(WITH_FFMPEG         "Include FFMPEG support"                      ON   IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GSTREAMER      "Include Gstreamer support"                   ON   IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)"                              OFF )
OCV_OPTION(WITH_GTK            "Include GTK support"                         ON   IF (UNIX AND NOT APPLE AND NOT ANDROID) )

可以看出,这就明确表示了cmakelist必须依赖于gstreamer-0.10。这里顺便介绍一下gstreamer-0.10,根据百度百科,GStreamer是用来构建流媒体应用的开源多媒体框架(framework),其目标是要简化音/视频应用程序的开发,目前已经能够被用来处理像 MP3、Ogg、MPEG1、MPEG2、AVI、Quicktime 等多种格式的多媒体数据。在linux中,进行视频处理的时候,有时候我们需要读入各种各样格式的视频。在没有相应的解码器的时候,我们是无法正确读入数据的,所以要正确安装gstreamer才能实现各种格式视频的正确读取。

于是,乖乖的安装吧:

sudo apt-get install libgstreamer1.0-dev  libgstreamer-plugins-base1.0-dev

装完,再编译,一切OK啦!

展开阅读全文

没有更多推荐了,返回首页