0

I have been trying to run YOLOv5 (https://github.com/ultralytics/yolov5) in Github codespaces. All the packages in the requirements.txt have been installed. I attached to real.pt model (https://github.com/Team4169/objectdetection/blob/main/yolov5/real.pt) I am using. It detects cones and cubes for FRC. It works on windows and linux (raspberry pi os w/ ui) but doesn't work on linux (codespace and raspberry pi os w/o ui). When I try to run the python detect.py --weights real.pt --source 0 command the following error occurs:

Traceback (most recent call last):
  File "/workspaces/objectdetection/yolov5/detect.py", line 45, in <module>
    from models.common import DetectMultiBackend
  File "/workspaces/objectdetection/yolov5/models/common.py", line 18, in <module>
    import cv2
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/usr/local/python/3.10.4/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Note running sudo doesn't fix this.

Sean Mabli
  • 37
  • 8

1 Answers1

0

Writing some of my own Python that interfaces with RPi camera using Picamera2 and wanted to start using OpenCV. I installed the headless version to avoid installing X dependencies.

pip install opencv-python-headless

OpenCV Python Headless documentation

Not sure if you are running in to a similar issue. The YOLOv5 does have opencv-python in the requirements.txt. Maybe try replacing opencv-python with opencv-pthon-headless. But the application might be dependant on X or other UI libraries, and use those libraries.

The code I am writing, I want to avoid GUIs altogether to save resource usage.

Rancorm
  • 11
  • 2