IMX219-77 camera not compatible with OpenCV on Jetson Nano

I’m trying to use a IMX219-77 camera with the Jetson Nano. The camera works perfectly if I test it in the terminal, but I can’t use it with opencv. Instead, I just get a green screen like here: How to slove opencv green screen?. I tried all the suggestions, but nothing works for me.

Hi,
Please check if you can run this gst-launch-1.0 command:

$ gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

If it works fine, please try this sample:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL

this command says WARNING: erroneous pipeline: no element "nvoverlaysink" for me and does not work.
also I’m on jetson xavier NX Jetpack5.0.1. using IMX219 camera in cam0 slot.

Hi,
The tile and category are in Jetson Nano, so the suggestion is applied to Jetson Nano. If you use Xavier NX, please create a new topic.

Thank you for the help,

the first command works. However, in the script I get the message “camera open failed” and an error from OpenCV: […] '(-5: Bad argument) CAP_IMAGES: can’t find starting number (in the name of the file) […] in function ‘icvExtractPattern’.

You would specify gstreamer backend (assuming your opencv build has support for it):

cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=(string)BGR ! appsink drop=1", cv2.CAP_GSTREAMER)

Thank you, but it still cannot open the camera.

You may get better help providing more information, such as the error you’re facing.

Is this still an issue to support? Any result can be shared? Thanks