hi everyone, anis again
i'm trying to run this object detection script:
on my raspberry pi zero 2w. Crazy right, hhh
p.s: i'm using os lite
i installed all the required libraries & packages, when i run the script, i get this error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
please i need help!
thanks!
(Mod edit for code tags)
i'm trying to run this object detection script:
Code:
import cv2from picamera2 import Picamera2from ultralytics import YOLO# Set up the camera with Picampicam2 = Picamera2()picam2.preview_configuration.main.size = (1280, 1280)picam2.preview_configuration.main.format = "RGB888"picam2.preview_configuration.align()picam2.configure("preview")picam2.start()# Load YOLOv8model = YOLO("yolov8n.pt")while True: # Capture a frame from the camera frame = picam2.capture_array() # Run YOLO model on the captured frame and store the results results = model(frame) # Output the visual detection data, we will draw this on our camera preview window annotated_frame = results[0].plot() # Get inference time inference_time = results[0].speed['inference'] fps = 1000 / inference_time # Convert to milliseconds text = f'FPS: {fps:.1f}' # Define font and position font = cv2.FONT_HERSHEY_SIMPLEX text_size = cv2.getTextSize(text, font, 1, 2)[0] text_x = annotated_frame.shape[1] - text_size[0] - 10 # 10 pixels from the right text_y = text_size[1] + 10 # 10 pixels from the top # Draw the text on the annotated frame cv2.putText(annotated_frame, text, (text_x, text_y), font, 1, (255, 255, 255), 2, cv2.LINE_AA) # Display the resulting frame cv2.imshow("Camera", annotated_frame) # Exit the program if q is pressed if cv2.waitKey(1) == ord("q"): break# Close all windowscv2.destroyAllWindows()
p.s: i'm using os lite
i installed all the required libraries & packages, when i run the script, i get this error: ImportError: libGL.so.1: cannot open shared object file: No such file or directory
please i need help!
thanks!
(Mod edit for code tags)
Statistics: Posted by anis_ghabarou — Mon Apr 14, 2025 9:43 am