Closed superalino closed 2 years ago
@superalino streaming uses OpenCV, which has many dependencies that vary by environment. If you are having issues you may want to ensure that cv2 streaming itself works in your environment before attempting to run YOLOv5 inference on those streams.
Streaming only works correctly if I run the detect.py script from xfce. In the same pc if I run the same command outside of xfce I get the error.
Also if I run detect.py with the option "view_img = False" from xfce the preview appears anyway.
I doubt it's an OpenCV problem but I'm not an expert so I don't have any valid ideas at the moment.
Thanks for the quick answer.
I found the problem on detect.py script.
If I change this part of code I can launch detection from CLI without problems.
if webcam:
#view_img = check_imshow()
view_img = False
cudnn.benchmark = True # set True to speed up constant image size inference
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt)
bs = len(dataset) # batch_size
else:
dataset = LoadImages(source, img_size=imgsz, stride=stride, auto=pt)
bs = 1 # batch_size
vid_path, vid_writer = [None] * bs, [None] * bs
@superalino hi, thank you for your feature suggestion on how to improve YOLOv5 🚀!
The fastest and easiest way to incorporate your ideas into the official codebase is to submit a Pull Request (PR) implementing your idea, and if applicable providing before and after profiling/inference/training results to help us understand the improvement your feature provides. This allows us to directly see the changes in the code and to understand how they affect workflows and performance.
Please see our ✅ Contributing Guide to get started.
I don't understand if detect.py is working as expected or if it's a bug.
Reading the documentation I realized that if the --view-img option is not explicit in the command it should automatically be "false" but it isn't.
What I would like to know is if the script is able to connect to rtsp streams in a machine with no screen and no X installed and at the same time is able to save all images where objects have been detected.
The only way I've figured out to be able to make the script work without X is to force this parameter in the code:
view_img = False
but doing this it would be impossible to make it work with the preview window and it doesn't save the images anyway.
The modification I suggested is only a workaround and not a "feature"
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.
Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!
Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!
Search before asking
YOLOv5 Component
Detection
Bug
If I try to run a detection on a stream from the command line I get the following error:
root@zoneminder136:/scripts/yolov5# python3 detect.py --weights weights/yolov5n.pt --classes 0 --conf-thre 0.60 --source sorgente.txt --project /dev/shm/test/ detect: weights=['weights/yolov5n.pt'], source=sorgente.txt, imgsz=[640, 640], conf_thres=0.6, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=[0], agnostic_nms=False, augment=False, visualize=False, update=False, project=/dev/shm/test/, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False YOLOv5 🚀 v6.0-139-g8f35436 torch 1.9.0+cu102 CUDA:0 (NVIDIA GeForce GTX 1650, 3912MiB)
Fusing layers... Model Summary: 213 layers, 1867405 parameters, 0 gradients qt.qpa.xcb: could not connect to display qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.9/dist-packages/cv2/qt/plugins" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
Annullato
If instead I launch the detection from xfce terminal everything works correctly and the preview window appears even with the option "view_img = False"
Environment
YOLOv5 🚀 v6.0-139-g8f35436 torch 1.9.0+cu102 CUDA:0 (NVIDIA GeForce GTX 1650, 3912MiB) Debian 11 Python 3.9.2
Minimal Reproducible Example
Launch from CLI:
python3 detect.py --weights weights/yolov5n.pt --classes 0 --source "rtspstream"
Additional
No response
Are you willing to submit a PR?