Select timeout error/warning when using usb camera

Hy devs, im experiencing some kind of video freezing in jetson orin nano 8gb. Initially the video plays, but after some time it freezes saying select timeout warn. I use Sony FCB EV9500L USB Camera. My code in python is like this:
def open_camera_thread(self):
global current_time
flag = 0
# print(self.camera_thread.ident)
while self.cap.isOpened():
if flag:
print(“resumed from:”, datetime.datetime.now().strftime(“%Y-%m-%d %H:%M:%S”))
flag = 0
# print(“active threads =”, threading.active_count() if threading.active_count() > 2 else ‘’)
ret, frame = self.cap.read()
if ret:
frame = cv2.resize(frame, (1280, 750)) # (640,480)
if self.helmet_on:
self.frame_queue.put(frame)
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
if self.lati is not None and self.longi is not None:
cv2.putText(image, f"LAT:{self.lati}“, (5, 40), cv2.FONT_HERSHEY_SIMPLEX, 0.5,
(0, 255, 255), 2)
cv2.putText(image, f"LON:{self.longi}”, (125, 40), cv2.FONT_HERSHEY_SIMPLEX, 0.5,
(0, 255, 255), 2)
if self.cur_speed is not None and self.cur_distance is not None:
cv2.putText(image, f"{self.cur_speed}kmph", (700, 380), cv2.FONT_HERSHEY_SIMPLEX, 0.6,
(0, 255, 0), 1)
if int(self.cur_speed) > self.maxspeed:
cv2.putText(image, f"{self.cur_speed}kmph", (680, 380), cv2.FONT_HERSHEY_SIMPLEX, 0.6,
(255, 0, 0), 1)
cv2.putText(image, f"Distance: {self.cur_distance}m", (270, 40), cv2.FONT_HERSHEY_SIMPLEX, 0.5,
(0, 255, 255), 2)
# center = (512, 275)
# radius = min(1024, 550) // 64
# cv2.circle(image, center, radius, (255, 0, 0), 1)
cv2.putText(image, ‘+’, (640, 388), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 0, 0), 2)
# cv2.rectangle(image, (499, 262), (525, 288), (255, 0, 0), 2)
# cv2.rectangle(image, (self.rect_x1, self.rect_y1), (self.rect_x2, self.rect_y2), (0, 255, 0), 2)
cv2.putText(image, f"PLACE: {self.display_location}“, (200, 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5,
(0, 255, 255), 2)
current_time = datetime.datetime.now().strftime(”%Y-%m-%d %H:%M:%S")
cv2.putText(image, current_time, (5, 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 255), 2)
percentage = self.get_battery_status()
cv2.putText(image, f"{percentage}", (1215, 735), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 9)
img = ImageTk.PhotoImage(Image.fromarray(image))
self.canvas.create_image(0, 0, anchor=tk.NW, image=img)
self.canvas.image = img
else:
print(“suspended”, current_time)
flag = 1
self.cap.release()
pipeline = “gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1920,height=1080,framerate=30/1 ! videoconvert ! appsink”
self.cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)
if self.termination_condition:
break
self.cap.release()

please tell me how to solve this freezing. Im using opencv with V4L2 as backend.

please help!!!

Hi,
Please try gst-launch-1.0 command and see if the issue persists:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=1920,height=1080,framerate=30/1 ! videoconvert !  fakesink sync=0

And please try the python sample:
V4l2src using OpenCV Gstreamer is not working in Jetson Xavier NX - #3 by DaneLLL

Hy, when I use gstreamer the video output is normal, but when I send a particular frame for number plate recognition the video output freezes. In backend, the image is sent to number plate recognition engine and also the number plate is read and printed. But in frontend the video stops. When same thing is done using V4L2 as backend, this issue is not being faced rather it freezes randomly even if I don’t send frames for any image processing. Do you have any solution for this? Thanks for your support.

Hi,
Seems like it gets blocked in OpenCV software stack. You may try appsink sync=0 drop=1

And see if it helps.

And may try this simple code for comparison:
V4l2src using OpenCV Gstreamer is not working in Jetson Xavier NX - #3 by DaneLLL

No sir, it’s still the same, video hangs after I send a frame for image processing. I have built opencv with cuda by seeing jetsonhacks YouTube video. Opencv 4.5.4 version.

Hi,
We would expect the sample works on default release. It is a bit strange you cannot run it successfully.

If your use-case is to run deep learning inference, you may consider use DeepStream SDK. Not sure why OpenCV does not work but using DeepStream SDK may be another option.

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