Yolov5 detect.py camera issue

When I type nvgstcapture-1.0 into the terminal, the camera opens. Jetson detects the raspberry pi HQ camera. But when I run detect.py I get the following error. How can this be solved ?

YOLOv5 :rocket: v7.0-215-ga6659d0 Python-3.8.10 torch-2.1.1 CPU

Fusing layers…
Model summary: 322 layers, 86180143 parameters, 0 gradients, 203.8 GFLOPs
[ WARN:0@9.055] global cap_v4l.cpp:2060 getProperty VIDEOIO(V4L2:/dev/video0): Unable to get camera FPS
[ WARN:0@19.102] global cap_v4l.cpp:1119 tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.
1/1: 0… success (inf frames 3280x2464 at 99.00 FPS)

Traceback (most recent call last):
File “detect.py”, line 387, in
detect_model.obj_detection()
File “detect.py”, line 177, in obj_detection
dataset = LoadStreams(source, img_size=imgsz, stride=stride)
File “/home/lagari/Desktop/YOLOV5/utils/datasets.py”, line 313, in init
s = np.stack([letterbox(x, self.img_size, stride=self.stride)[0].shape for x in self.imgs], 0) # shapes
File “/home/lagari/Desktop/YOLOV5/utils/datasets.py”, line 313, in
s = np.stack([letterbox(x, self.img_size, stride=self.stride)[0].shape for x in self.imgs], 0) # shapes
File “/home/lagari/Desktop/YOLOV5/utils/augmentations.py”, line 113, in letterbox
shape = im.shape[:2] # current shape [height, width]
AttributeError: ‘NoneType’ object has no attribute ‘shape’

it’s not a V4L2 device or it’s broken?

not an OpenCV problem or a yolov5 problem but a raspberry pi problem.

investigate your issue to determine the root cause. MRE helps guide you.

replicate this with guvcview or straight up ffplay/ffmpeg.