How to change the resolution of a usb camera when running live detection?

I run the following command on jetson nano:

python3 detect.py --source 0 --weights yolov5s.pt

As you can see from the image above, the webcam has an input resolution of 2304*1536 and an fps of only 2. But normally the fps should be around 10. So I think the webcam’s input resolution is too high, which causes the inference speed to slow down. So how can I reduce the input resolution of the webcam?

And the webcam is Logitech C920 Pro Webcam.

I’m not sure of what the source of the detect.py script you are running is, but you would need to add your desired input resolution to the GStreamer pipeline. It looks like the script is using OpenCV cv2.VideoCapture for the camera capture (which in turn calls GStreamer).

You could try setting your desired video resolution on the VideoCapture instance like is shown here: