Unable to access GMSL camera feed through Python


I am trying to access the GMSL camera in python through the OpenCV library on Jetson AGX Orin. I was expecting that by using cv2.VideoCapture(index of the camera) i would be able to access the camera feed and process it further for my end application, related to ADAS, but unfortunately I am unable to do that. I am getting a error that says cant open camera by index.

Kindly guide how will I be able to access the GMSL camera feed using the OpenCV library in python.

Sorry for the late response, have you managed to get issue resolved or still need the support? Thanks

Hi @kayccc
Still need support for this

Please give more detail information like command and log.

i am trying to run this code

import cv2

#Capture video from webcam
vid_capture = cv2.VideoCapture(0)
vid_cod = cv2.VideoWriter_fourcc(*‘XVID’)
output = cv2.VideoWriter(“car1.mp4”, vid_cod, 60.0, (640,480))

# Capture each frame of webcam video
ret,frame = vid_capture.read()
cv2.imshow(“My cam video”, frame)
# Close and break the loop after pressing “x” key
if cv2.waitKey(1) &0XFF == ord(‘q’):




I get an output like this :

OpenCV: FFMPEG: tag 0x44495658/‘XVID’ is not supported with codec id 12 and format ‘mp4 / MP4 (MPEG-4 Part 14)’
OpenCV: FFMPEG: fallback to use tag 0x7634706d/‘mp4v’
Traceback (most recent call last):
File “record.py”, line 11, in
cv2.imshow(“My cam video”, frame)
cv2.error: OpenCV(4.6.0) /io/opencv/modules/highgui/src/window.cpp:967: error: (-215:Assertion failed) size.width>0 && size.height>0 in function ‘imshow’

Have reference to below link.

The above link did not help.
I tried to run a simpler code than the one I posted above. This code basically outputs the camera frame in a window. I am getting a error accessing the GMSL camera (part no. is IMX490-GMSL2), but when i connect a USB camera I am able to access through the same index no(4).

import cv2

video_capture_0 = cv2.VideoCapture(4)

while True:

ret0, frame0 = video_capture_0.read()

if (ret0):
    cv2.imshow('Cam 0', frame0)
    if cv2.waitKey(1) & 0xFF == ord('q'):


Error message : global /io/opencv/modules/videoio/src/cap_v4l.cpp (902) open VIDEOIO(V4L2:/dev/video4): can’t open camera by index

You need look into the source to check the v4l2src configuration.
Also you can use v4l2-ctl to confirm the camera if working first.

**I would like to rephrase my problem statement . **

I have the following camera part no. IMX490-GMSL2 which is connected to Jetson AGX Orin through CSI interface provided on the board. When i give the command “v4l2-ctl --list-devices”, i get the following output :

NVIDIA Tegra Video Input Device (platform:tegra-camrtc-ca):

vi-output, imx490 30-001a (platform:tegra-capture-vi:0):

vi-output, imx490 31-001a (platform:tegra-capture-vi:2):

vi-output, imx490 32-001a (platform:tegra-capture-vi:4):

vi-output, imx490 33-001a (platform:tegra-capture-vi:5):

Now, I have worked with USB cameras and python OpenCV and as per my prior experience, to access camera feeds I have been using the following piece of code :

import cv2

video_capture_0 = cv2.VideoCapture(0) #4 is the index no. of the camera which i intend to take feed from

while True:

ret0, frame0 = video_capture_0.read()

if (ret0):
    cv2.imshow('Cam 0', frame0)
    if cv2.waitKey(1) & 0xFF == ord('q'):


But if I use the index no.of the GMSL cameras connected through CSI, i get a error :

Error message : global /io/opencv/modules/videoio/src/cap_v4l.cpp (902) open VIDEOIO(V4L2:/dev/video0): can’t open camera by index

I would like to know if there is anything wrong here. Request @SimonZhu and @kayccc @ShaneCCC to also help as we are completely stuck here.

Please make sure the video0 is the USB camera. You can compare the video nodes under /Dev with and without USB camera.
Can you get video output (with guvcview) from USB camera on Jetson AGX Orin?

I am able to access camera feed from USB webcams through guvcview and python code. I am facing issues in accessing camera feeds for GMSL cameras connected through the CSI ports.

Guvcview cannot display raw stream from CSI ports. Please use Argus software to get video preview. You can also use v4l2 to capture raw data from CSI interface.

Yes, you are right.
I used the following command to access through the argus_camera application :
argus_camera --device=0

I was able to access the CSI camera feed.

Next, i would like to access the CSI camera feed through a Python code using OpenCV. Can you share a reference code for that ?

Request @ShaneCCC and @kayccc to also help

Please do some search in this Forum for OpenCv sample.


My issue is resolved.

This helped me to access single camera as well as 2 cameras simultaneously.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.