2014-05-09 37 views
8

我使用的是氮素6x板与ov5640相机(mipi)。在OpenCV中使用自定义相机(通过GStreamer)

相机没有使用标准的V4L /为v41,但我们可以利用的GStreamer其驱动程序(mfw_v4l)视频流:

gst-launch mfw_v4lsrc ! autovideosink 

我想通过GStreamer的调用,它可以利用OpenCV的摄像头(GStreamer的在OpenCV内部)。 我问了一个关于在OpenCV here内部调用GStreamer的问题,这是后续。

如果我启用GStreamer支持,它会检查in the source code,但OpenCV会尝试使用标准V4L/V4L2来更改GStreamer。 有关调用的GStreamer的部分是cap_gstreamer.cpp

CvCapture* cvCreateCapture_GStreamer(int type, const char* filename) 
{ 
    CvCapture_GStreamer* capture = new CvCapture_GStreamer; 

    if(capture->open(type, filename)) 
     return capture; 

    delete capture; 
    return 0; 
} 

我想这是我应该努力以某种方式指向相机的驱动程序部分。 (这里的“type”可能是与驱动程序有关的数字(在precomp.hpp中定义),但什么是“文件名”?)

有关如何通过GStreamer访问摄像机的任何建议将会有所帮助和赞赏。 谢谢!

回答

5

看起来我们可以使用适当的GStreamer管道像下面调用摄像头:

VideoCapture cap("mfw_v4lsrc ! ffmpegcolorspace ! video/x-raw-rgb ! appsink") 

为摄像机输出是YUV,我们需要将其转换成RGB的帧传递给OpenCV的。 This是OpenCV确保获得RGB色彩空间的地方。

+0

在其中的OpenCV版本的作品? –

+0

在opencv v3之前无法正常工作 –

0

仅供参考,这部作品在OpenCV的3.0:

VideoCapture cap("souphttpsrc location=http://root:[email protected]:80/mjpg/video.mjpg ! decodebin ! videoconvert ! appsink")