Continuing the discussion from Select timeout error/warning when using usb camera:
Previously, I had found a workaround to almost eliminate the camera freeze issue while using orin nano jp 5.1.1. I had built opencv 4.5.4 with cuda and also modified the cap_v4l.cpp file to reduce the default select() timeout from 10s to 0.5s. This change made the video output almost undetectable when the camera freezes and I would immediately do self.cap.release() and then again self.cap.VideoCapture(‘/dev/video0’, cv2.CAP_V4L2) which was good workaround so that no one noticed the frame freeze(green color frame). The select(0 timeout issue was still present though!
Now we have procured new orin nano super with jp 6.2.1 and built opencv 4.10.0 the same way as i did for 4.5.4 in jp5.1.1 but, I’m facing the same issue(green screen) again even though the coding is same. My code continuously try to self.cap.release() and self.cap.VideoCapture(‘/dev/video0’, cv2.CAP_V4L2) when cap.read() doesnt return True.
I even tried using GSTREAMER (built with cuda in opencv 4.10.0) as :
device = “/dev/video0”
capture_width = 1920
capture_height = 1080
framerate = 30
self.pipeline = f’v4l2src device={device} ! video/x-raw, width={capture_width}, height={capture_height}, framerate={framerate}/1, format=(string)YUY2 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink’
self.cap = cv2.VideoCapture(self.pipeline, cv2.CAP_GSTREAMER)
but, even this leads to same issue. The video freezes at random times (can’t predict when or no known patterns found).
Below is the error from pycharm terminal. Im printing cap object released when i dont get frames from self.cap.read() and then reinitialise the videocapture object.
sudo dmesg:
Note: Using GSTREAMER pipeline is causing higher CPU consumption on all 6 cores than using v4l library. So, I dont want to try any workaround using GSTREAMER.
Note: Camera is connected to dev kit directly on USB port (only 1 camera we are using).
Cam details:
nvidia@nvidia-desktop:~$ v4l2-ctl --device=/dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Cam freeze video:
The error select() timeout kiran shows the opencv is my custom built from source! Not the regular one from pycharm or jetson pre-installed.
This time I need complete solution or at least a proper workaround. Else the procurement of new orin supers will be impacted for us losing our market competitions.
Please help. Happy to debug anything.
Thanks in advance.




