I'm using ESP32-Cam WebServer and capture the cam stream in python OpenCV+YOLOv8.
It works, but there is significant lag.
The delay is approximately 2 seconds after what the camera captures.
Here's my code:
import cv2
from ultralytics import YOLO
model = YOLO('yolov8n.pt')
cap = cv2.VideoCapture("http://ip")
while cap.isOpened():
success,frame = cap.read()
if success:
results = model(frame)
annotated_frame = results[0].plot()
cv2.imshow("YOLOv8 Inference",annotated_frame)
if cv2.waitKey(1) & 0xFF ==ord("q"):
break
else:
break
cap.release()
cv2.destroyAllWindows()
Is this due to insufficient hardware performance of the ESP32 or are there any modifications that can be made to the code?