Camera capture with OpenCV (c++) and GStreamer pipeline

Hello there,

i’m working on an imx6q and i’m trying to write in c ++ my python application that acquires video from an analog camera.

The problem is that he doesn’t seem to like the pipeline. I summarize the situation in detail:

Apalis iMX6 Quad 2GB IT V1.1C
Ixora V1.2A
Customized image Yocto based on Alapis-iMX6_LXDE-Image_2.8b7

I only added python and opencv 3.3 as described here and here

IMAGE_INSTALL_append = "python opencv"

CXXFLAGS += " -Wa,-mimplicit-it=thumb"

Then i populate skd and configure it to cross compile with opencv libs ( always following this)

And this is the result:

ACA ADV7280 drivers are correclty loaded:

root@apalis-imx6:~# dmesg | grep adv
[    5.601368] adv7280 3-0021: chip found @ 0x42 (21a8000.i2c)
[    5.601399] adv7280 3-0021: no sensor pwdn pin available
[    5.665895] mxc_v4l2_master_attach: ipu0:/csi0 parallel attached adv7280:mxc_v4l2_cap0

Analog camera is detected:

root@apalis-imx6:~# v4l2-ctl --list-devices

root@apalis-imx6:~# v4l2-ctl -V -d /dev/video0
Format Video Capture:
        Width/Height      : 720/576
        Pixel Format      : 'UYVY'
        Field             : Any
        Bytes per Line    : 1440
        Size Image        : 829440
        Colorspace        : Default
        Transfer Function : Default
        YCbCr/HSV Encoding: Default
        Quantization      : Default

GStreamer pipeline works (as in documentation):

gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! imxipuvideosink use-vsync=true

Python3 application works:

 import numpy as np
 import cv2

 cap = cv2.VideoCapture("imxv4l2videosrc device=\"/dev/video0\" ! videoconvert ! appsink")
 cv2.namedWindow("frame", cv2.WINDOW_NORMAL)
 cv2.setWindowProperty("frame", cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
 while 1:
 	if cap.isOpened():
		ret, frame =			
 		if cv2.waitKey(10) & 0xFF == ord('q'):

C++ Application doesn’t work:

#include <opencv2/opencv.hpp>

using namespace cv;

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

	Mat image;
	namedWindow("frame" , CV_WINDOW_NORMAL); 
	setWindowProperty("frame" , WND_PROP_FULLSCREEN , WINDOW_FULLSCREEN);
    VideoCapture cap;"imxv4l2videosrc device=\"/dev/video0\" ! vidoeconvert ! appsink" );

	while (1)	{
		if (cap.isOpened()) {
			cap >> image;
			cv::imshow("frame" , image);
    return 0;
(frame:1604): GStreamer-CRITICAL **: gst_caps_intersect_full: assertion 'GST_IS_CAPS (caps1)' failed

(frame:1604): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /usr/src/debug/opencv/3.3+gitAUTOINC+87c27a074d_2a9d1b22ed_a62e20676a_34e4206aef_fccf7cd6a4-r0/git/modules/videoio/src/cap_gstreamer.cpp, line 881
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

/usr/src/debug/opencv/3.3+gitAUTOINC+87c27a074d_2a9d1b22ed_a62e20676a_34e4206aef_fccf7cd6a4-r0/git/modules/videoio/src/cap_gstreamer.cpp:881: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

I also say that other features of opencv seem to work. I don’t know if in c ++ I have to indicate the pipeline in another format? Or do I have to enable something or recompile the image with other flags (I don’t think since the documentation says opencv from image 2.7 already comes with gstreamer support)?

Thank you very much

Hello @franker83 ,

Could you maybe tell us what you are streaming over the Gstreamer?
Because I think it may be similar to the issue mentioned here

Best regards,