Access Camera using OpenCV (Via GStreamer)

c++, gstreamer, opencv, video, video-streaming

Solution

Here is the answer to my question(with @Alper Kucukkomurler's help)

You can access the MIPI camera through OpenCV (with GStreamer) with

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

Also If you want to change the resolution of the input, `imx-capture-mode` parameter can be used, which is of `imxv4l2videosrc` element. For example,

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

Problem

I'm trying to develop an application which should analyse a video stream from a MIPI camera(5MP). So I'm using gstreamer to get the video feed access it using OpenCV. I tried the following pipeline and it's working: ``` imxv4l2videosrc device="/dev/video0" ! autovideosink ``` But when I try to use it with OpenCV, it gives some errors. ``` 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 ``` Then I tried to use the following pipeline, and it's not working as well: ``` 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 version: 1.0 OpenCV version: 3.2 What is the piece i'm missing here? Or is my approach is wrong?

Original source

Related problems