OpenCV exception with GStreamer, MIPI camera and JetPack

I’m trying to capture video from my MIPI CSI IMX219 camera (verified working).
I want to open the video feed with opencv for processing, but I am new to OpenCV and the Jetson platform in general, so I don’t really know what I’m doing.

The following code:

pipeline = 'nvarguscamerasrc sensor-id=1' # never mind the filters 
cam = cv2.VideoCapture(pipeline)

fails with exceptioni

ERROR global /tmp/…/cap.cpp (160) open VIDEOIO(CV_IMAGES): raised OpenCV exception:
/tmp/…/cap_images.cpp:253:error: (-5:Bad argument) CAP_IMAGES Can’t find starting number (in the name of file) nvarguscamerasrc… in function 'icvExtractPattern.

I’ve seen a lot of similar threads but none of the solutions worked for me. I have not yet tried building openCV because I’m not sure about what build parameters I’m supposed to use.

However I have noticed that cv2.getBuildInformation() says GStreamer NO\n.
Why is GStreamer not included in JetPack builds of OpenCV? It would seem natural that the onboard cam ports would be supported out of the box?

Running Xavier NX
JetPack 4.6-b197
OpenCV 4.5.3
Python 3.6.9

Could you check this link.

Hi Shane,
the blog suggests using OpenCV-4.1.1, so is there a compatability issue between GStreamer and version 4.5.3?
I would rather not downgrade unless it is necessary

I saw the comment in the blog with a link to inferences with a raspberry camera on Jetson · Issue #362 · jkjung-avt/tensorrt_demos · GitHub
so I will try that. But that is unrelated to OpenCV so that does not help me.

Have a reference to below link for OpenCv 4.5

Also do you connect two camera? how about sensor-id=0