from ultralytics import YOLO
import os
import cv2 as cv


model = YOLO("yolov8s.pt")

os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"
cap = cv.VideoCapture('rtsp://210.99.70.120:1935/live/cctv001.stream')

while cap.isOpened():
ret, frame = cap.read()

if not ret:
print("Can't receive frame")
break

# cv.imshow('frame', frame) 영상표시
results = model.predict(source=frame, show=True, device="0") # yolo 표시

if cv.waitKey(1) == ord('q'):
break
cap.release()
cv.destroyAllWindows()

 

+ Recent posts