USB camera turns off while working

Platform: Jetson Orin Nano, Jetpack 5.1.1
I have app, that creates cv.VideoCapture for 1-2 minute session and then release it.
The video device is a usb-camera ELP-USBFHD01M-L180.
Pipeline for gstreamer API look like this:

v4l2src device=/dev/video0 io-mode=2 extra-controls="s,exposure_auto=1, exposure_absolute=70" ! image/jpeg, width=(int)640, height=(int)480, framerate=(fraction)61612/513 ! jpegdec ! video/x-raw ! videoconvert ! video/x-raw,format=BGR ! appsink

The error occurs sometimes rarely, but always on session startup. VideoCapture initializes successfully and I get a few frames, but then the program just freezes when trying to read the frame.
With GST_DEBUG=3 I noticed the following warnings:

0:00:01.307622934  8059 0xaaaaf3a5eb60 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 6 - ts: 0:00:00.443307921
0:03:01.053101519  8059 0xaaaaf3a5eb60 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:03:00.184851721
0:06:35.147743974  8059 0xaaaaf3a5eb60 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:06:34.283454369
0:19:51.824426270  8059 0xaaaaf3a5eb60 WARN                 v4l2src gstv4l2src.c:978:gst_v4l2src_create:<v4l2src0> lost frames detected: count = 1 - ts: 0:19:50.960118825

And when I trying to kill the procces I see this warning:

19:34:42.686163166  8059 0xaaaaf3ba6550 WARN          v4l2bufferpool gstv4l2bufferpool.c:702:gst_v4l2_buffer_pool_streamoff:<v4l2src0:pool:src> STREAMOFF failed with errno 19 (No such device)
19:34:42.686318211  8059 0xaaaaf3ba6550 WARN           v4l2allocator gstv4l2allocator.c:791:gst_v4l2_allocator_stop:<v4l2src0:pool:src:allocator> error releasing buffers buffers: No such device

I don’t understand how to cause this error.
The only thing I’ve found so far:
I launched

GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video0 extra-controls="s,exposure_auto=1, exposure_absolute=70" ! image/jpeg,width=640,height=480,framerate=61612/513 ! nvv4l2decoder mjpeg=1 ! nvvidconv ! queue ! autovideosink

After about 16 hours, the error repeated
Output of this run:
logs.txt (33.0 KB)

I checked the camera specs. Consumption 0.15A, both in documents and during measurements.
In addition to the camera, the Jetson is connected to a mouse, keyboard and monitor. But the error may appear without them.
This error occurs on different samples of the same model of the camera. I don’t need to be constantly connected to the camera. I need to ensure a short session. Considering that there are no such problems when running gst-launch (in a short period of time), I know that I can solve this problem with this camera model.
Does anyone have any ideas why this error might appear when launching VideoCapture? If the problem is somewhere in my code, then what should I pay attention to?

Possibly it is power related. The first thing to test is to disable USB autosuspend. Go to your “/boot/extlinux/extlinux.conf” file, and look for the line “APPEND ...” (this is the list of arguments passed to the kernel at boot). If you have more than one of those lines, then they are for different boot entries (you can add this to the active entry, usually the only entry, or all the entries if there is more than one). That line is a single long line with a space between words. You can go to the end, add a space, and then this (just don’t break the line):
usbcore.autosuspend=-1

An alternative way to do this is to edit file “/etc/sysctl.conf”, and add this line (by itself) at the end (the two methods are equivalent, but sysctl.conf always runs at start, while the APPEND is for just that boot entry).

If that helps, you’re done.

If that fails, then you might try an externally powered USB HUB. This would be the case if the heavy activity was consuming enough power that it was a problem for the Jetson. This shouldn’t be the case, but if it were, then switching to an external source takes over for the Jetson (plus external sources are rated to a higher output).

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