2017-05-05 172 views
1

我試圖開發一個應用程序,它應該分析來自MIPI攝像機(500萬像素)的視頻流。因此,我正在使用gstreamer使用OpenCV獲取視頻供稿。我嘗試了以下的管道,它的工作:使用OpenCV訪問攝像機(通過GStreamer)

imxv4l2videosrc device="/dev/video0" ! autovideosink 

但是,當我嘗試使用OpenCV的使用它,它給了一些錯誤。

VideoCapture cap("imxv4l2videosrc device=\"/dev/video0\" ! autovideosink"); 

OpenCV Error: Unspecified error (GStreamer: cannot find appsink in manual pipeline 
) in cvCaptureFromCAM_GStreamer, file /root/OpenCV/opencv/modules/videoio/src/cap_gstreamer.cpp, line 759 
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception: 

/root/OpenCV/opencv/modules/videoio/src/cap_gstreamer.cpp:759: error: (-2) GStreamer: cannot find appsink in manual pipeline 
in function cvCaptureFromCAM_GStreamer 

然後我試着用下面的管道,它不工作,以及:

VideoCapture cap("imxv4l2videosrc device=\"/dev/video0\" ! appsink"); 

ERROR: unrecognized std! 0 (PAL=ff, NTSC=b000 
ERROR: v4l2 capture: unsupported ioctrl! 
GStreamer Plugin: Embedded video playback halted; module imxv4l2videosrc0 reported: Internal data flow error. 
ERROR: v4l2 capture: unsupported ioctrl! 
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline 
) in cvCaptureFromCAM_GStreamer, file /root/OpenCV/opencv/modules/videoio/src/cap_gstreamer.cpp, line 832 
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception: 

/root/OpenCV/opencv/modules/videoio/src/cap_gstreamer.cpp:832: error: (-2) GStreamer: unable to start pipeline 
in function cvCaptureFromCAM_GStreamer 

的GStreamer版本:1.0 OpenCV的版本:3.2

什麼是一塊,我很在這裏失蹤? 或者我的方法是錯誤的?

+0

可能重複和解決方案爲:http://stackoverflow.com/questions/23570572/using-custom-camera-in-opencv-via-gstreamer – GroovyDotCom

+0

@GroovyDotCom,我已經嘗試過你在這裏提到的帖子。但mfw_v4lsrc不起作用。它說:警告:錯誤的管道:沒有元素「mfw_v4lsrc」。 – KTB

+0

你可以用'videoconvert'元素來試試嗎? :'VideoCapture cap(「imxv4l2videosrc device = \」/ dev/video0 \「!videoconvert!appsink」);' –

回答

1

這裏是回答我的問題(與@Alper Kucukkomurler的幫助)

您可以通過OpenCV的(在GStreamer)與

VideoCapture cap("imxv4l2videosrc device=\"/dev/video0\" ! videoconvert ! appsink"); 

也獲得了MIPI攝像機如果要更改分辨率的輸入,可以使用imx-capture-mode參數,該參數爲imxv4l2videosrc元素。 例如,

imxv4l2videosrc imx-capture-mode=5 ! <other elements>