opencv-yolov8-目标检测

复制代码
import cv2
from ultralytics import YOLO

# 模型加载权重

model = YOLO('yolov8n.pt')

# 视频路径

cap = cv2.VideoCapture(0)

# 对视频中检测到目标画框标出来
while cap.isOpened():
    # Read a frame from the video
    success, frame = cap.read()

    if success:
        # Run YOLOv8 inference on the frame
        results = model(frame)

        # Visualize the results on the frame
        annotated_frame = results[0].plot()

        # Display the annotated frame
        cv2.imshow("YOLOv8 Inference", annotated_frame)

        # Break the loop if 'q' is pressed
        if cv2.waitKey(5) & 0xFF == ord("q"):
            break
    else:
        # Break the loop if the end of the video is reached
        break

# Release the video capture object and close the display window
cap.release()
cv2.destroyAllWindows()
相关推荐
gorgeous(๑>؂<๑)3 小时前
【北理工-AAAI26】MODA:首个无人机多光谱目标检测数据集
人工智能·目标检测·计算机视觉·目标跟踪·无人机
极智视界5 小时前
目标检测数据集 - 穿着服饰检测数据集下载
yolo·目标检测·数据集·voc·coco·算法训练·穿着服饰检测数据集
音沐mu.6 小时前
【34】犬类品种数据集(有v5/v8模型)/YOLO犬类品种检测
人工智能·yolo·目标检测·犬类品种数据集·犬类品种检测
AI浩8 小时前
ROD-MLLM:迈向多模态大语言模型中更可靠的目标检测
目标检测·目标跟踪·语言模型
TOYOAUTOMATON9 小时前
GTH系列模组介绍
前端·目标检测·自动化
AI浩11 小时前
SemOD:基于语义增强的多天气条件目标检测网络
网络·人工智能·目标检测
AI视觉网奇13 小时前
live2d 抠人脸
人工智能·opencv·计算机视觉
paradoxjun15 小时前
训练一个通用且高效的YOLO-pose人体关键点检测模型
目标检测·计算机视觉·人体姿态估计·人体关键点检测·yolo-pose
牙牙要健康15 小时前
【YOLOv8-Ultralytics】 【目标检测】【v8.3.235版本】 模型专用验证器代码val.py解析
人工智能·yolo·目标检测