GStreamer阅读相机分辨率

时间:2015-02-16 17:30:31

标签: gstreamer ubuntu-14.04 v4l2

我尝试使用GStreamer和插件camerabin2读取相机支持的分辨率。问题是我得到了NULL。

#include <gst/gst.h>
#include <stdio.h>

#define gstRef(element) { gst_object_ref(GST_OBJECT(element)); gst_object_sink(GST_OBJECT(element)); }

int main(int argc, char *argv[]) {

  gst_init (&argc, &argv);

  GstElement *m_camerabin = gst_element_factory_make("camerabin2", "camerabin2");  
  gstRef(m_camerabin);

  GstCaps *supportedCaps = 0;
   g_object_get(G_OBJECT(m_camerabin), "image-capture-supported-caps",
                 &supportedCaps, NULL);
  char *c = gst_caps_to_string(supportedCaps); 
  printf("%s\n",c); 

  return 0;
}

有更好的方法来获得支持的解决方案吗?我应该使用不同的插件吗?

感谢。

2 个答案:

答案 0 :(得分:0)

我没有使用过这个元素,但是在GStreamer中,在将元素放置在管道中并且管道被“播放”之前,分辨率通常不会对你的代码可用。然后激活元素并连接并提供信息。

讨厌链接和运行,但你可能想从这里开始。

https://gitorious.org/gstreamer-camerabin2/gst-plugins-bad/source/28540988b25f493274762d394c55a4beded5e428:tests/examples/camerabin2

答案 1 :(得分:0)

我还没有使用camerabin2,但是我强烈建议使用GstDeviceMonitor。通过启用GstDeviceMonitor,您可以访问连接到PC的所有设备。不仅是麦克风,扬声器,而且还有摄像头。此外,您可以访问相机设备的全部信息,例如分辨率,支持的格式,fps等。

您将使用:

GList* devices = gst_device_monitor_get_devices(mMonitor);

然后,您需要从GList *中提取信息。由于公司政策,我无法提供完整的代码。我只是给你一个线索。

有关GstDeviceMonitor代码的建议参考
https://gstreamer.freedesktop.org/documentation/gstreamer/gstdevicemonitor.html?gi-language=c