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 🚀 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’

Hi,

cap_v4l.cpp:2060 getProperty VIDEOIO(V4L2:/dev/video0): Unable to get camera FPS

It looks like you try to open the camera located at /dev/video0 with V4L2 interface.
For CSI camera, please use our argus interface instead.

Could you try if --source 0 helps?

Thanks

I already use --source 0

Hi,

Could you verify if your camera can be opened successfully with OpenCV first?
Thanks.

I came to the conclusion that I need to build opencv with gstreamer.

Hi,

Please note that the default OpenCV in JetPack 5 is already built with GStramer support.
Thanks.

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