Ubuntu 编译opencv出错:‘GstMiniObjectClass’ does not name a type 解决方法

在Ubuntu上进行计算机视觉项目的毕业设计时,作者尝试更新OpenCV到3.0.0-rc1,但遇到编译错误。错误与gstreamer-0.10有关。通过对比不同版本的OpenCV,作者找到了两种解决方法:在cmake时关闭WITH_GSTREAMER_0_10或安装gstreamer1.0。最后,作者选择了安装gstreamer1.0并成功解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由于毕业设计是计算机视觉项目。我选择使用Python+OpenCV的平台来完成,因为多练习Python也有利于以后研究生阶段机器学习的研究。

我有点技术洁癖:(,本来电脑已经有OpenCV了,硬是想更新成最新的3.0.0-rc1。但是发现下载下来编译不了。具体出现问题的编译报错信息如下:

[ 45%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_libv4l.cpp.o
In file included from /usr/include/gstreamer-0.10/gst/pbutils/encoding-profile.h:29:0,
                 from /opt/opencv-3.0.0-rc1/modules/videoio/src/cap_gstreamer.cpp:65:
/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 /opt/opencv-3.0.0-rc1/modules/videoio/src/cap_gstreamer.cpp:65: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;
         ^
/opt/opencv-3.0.0-rc1/modules/videoio/src/cap_gstreamer.cpp: In member function ‘virtual bool CvCapture_GStreamer::grabFrame()’:
/opt/opencv-3.0.0-rc1/modules/videoio/src/cap_gstreamer.cpp:232:57: error: ‘gst_app_sink_pull_sample’ was not declared in this scope
     sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
                                                         ^
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_gstreamer.cpp.o] 错误 1
make[2]: *** 正在等待未完成的任务....
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/npr.cpp.o
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/denoise_tvl1.cpp.o
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/seamless_cloning_impl.cpp.o
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/hdr_common.cpp.o
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/calibrate.cpp.o
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/denoising.cuda.cpp.o
[ 45%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/opencl_kernels_photo.cpp.o
Linking CXX shared library ../../lib/libopencv_photo.so
[ 45%] Built target opencv_photo
make: *** [all] 错误 2


提取其中一句来看看:

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

明显地,与gstreamer-0.10有关,于是重装libgstreamer0.10-dev 、以及libgstreamer-plugins-base0.10-dev,没用。于是下载旧版本的opencv尝试编译,但是经过3.0.0-beta以及2.4.10都不行后,只有opencv-2.4.9编译是正常的。于是尝试对比2.4.9以及3.0.0-rc1的不同。看到CMakeList有如下信息:


3.0.0-rc1的是:

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) )

2.4.9的是:

OCV_OPTION(WITH_FFMPEG         "Include FFMPEG support"                      ON   IF (NOT ANDROID AND NOT IOS))
OCV_OPTION(WITH_GSTREAMER      "Include Gstreamer support"                   ON   IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_GTK            "Include GTK support"                         ON   IF (UNIX AND NOT APPLE AND NOT ANDROID) )

也就是2.4.9还默认使用电脑中所使用的gstreamer版本,而3.0.0已经默认使用最新的gstreamer1.0了(今天是2015.5.5,最新gstreamer为1.0)。

到此,可以发现有两个解决方法:

1,在cmake时:设置WITH_GSTREAMER_0_10=OFF

2,安装最新gstreamer1.0

因此我决定安装gstreamer1.0。即:

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

希望可以帮到大家:)。


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值