import cv2 from ultralytics import YOLO model = YOLO(r"F:\迅雷下载\yolo26n.pt") source = "rtmp://175.27.168.120:6019/live/88888" results = model(source, stream=True, show=False) # 关闭YOLO内置显示 # 遍历结果 for result in results: # 获取带注释的帧 annotated_frame = result.plot() # 使用OpenCV显示 cv2.imshow('YOLO Detection', annotated_frame) # 按'q'键退出 if cv2.waitKey(1) & 0xFF == ord('q'): break cv2.destroyAllWindows()