一、目标检测

import cv2
from ultralytics import YOLO

# 加载 YOLOv8 模型
model = YOLO('yolov8n.pt')
video_path =0 #摄像头ip地址
cap = cv2.VideoCapture(video_path)
while cap.isOpened():
    status, frame = cap.read()
    if not status:
        break
    results = model.predict(source=frame)
    result = results[0]
    anno_frame = result.plot()
    cv2.imshow("V8", anno_frame)
    # 设置延迟以减慢视频播放速度
    if cv2.waitKey(30) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

二、关键点检测

import cv2
from ultralytics import YOLO

# 加载 YOLOv8 模型
model = YOLO('yolov8n-pose.pt')
video_path =0 #摄像头ip地址
cap = cv2.VideoCapture(video_path)
while cap.isOpened():
    status, frame = cap.read()
    if not status:
        break
    results = model.predict(source=frame)
    result = results[0]
    anno_frame = result.plot()
    cv2.imshow("V8", anno_frame)
    # 设置延迟以减慢视频播放速度
    if cv2.waitKey(30) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

三、分割

import cv2
from ultralytics import YOLO

# 加载 YOLOv8 模型
model = YOLO('yolov8n-seg.pt')
video_path =0 #摄像头ip地址
cap = cv2.VideoCapture(video_path)
while cap.isOpened():
    status, frame = cap.read()
    if not status:
        break
    results = model.predict(source=frame)
    result = results[0]
    anno_frame = result.plot()
    cv2.imshow("V8", anno_frame)
    # 设置延迟以减慢视频播放速度
    if cv2.waitKey(30) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

GitHub 加速计划 / opencv31 / opencv
77.39 K
55.71 K
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:2 个月前 )
7be5181b Fixed KLEIDICV_SOURCE_PATH handling for external KleidiCV 1 天前
c3ca3f4f - 1 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐