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()
相关推荐
强盛小灵通专卖员12 小时前
基于RT-DETR的电力设备过热故障红外图像检测
人工智能·目标检测·sci·研究生·小论文·大论文·延毕
gorgeous(๑>؂<๑)14 小时前
【ICLR26匿名投稿】Context-Aware ViT:让目标检测真正“看清上下文”的增强策略
人工智能·目标检测·机器学习·计算机视觉·目标跟踪
AI浩16 小时前
Cambrian-S:迈向视频中的空间超感知
人工智能·目标检测·计算机视觉·音视频
胖墩会武术19 小时前
【OpenCV图像处理】深度学习:cv2.dnn() —— 图像分类、人脸检测、目标检测
图像处理·pytorch·python·opencv
用户72278681234421 小时前
OpenCVSharp:BRISK特征检测
opencv
AI即插即用1 天前
即插即用系列 | 2025 SOTA Strip R-CNN 实战解析:用于遥感目标检测的大条带卷积
人工智能·pytorch·深度学习·目标检测·计算机视觉·cnn·智慧城市
B站_计算机毕业设计之家1 天前
python手写数字识别系统 CNN算法 卷积神经网络 OpenCV和Keras模型 计算机视觉 (建议收藏)✅
python·深度学习·opencv·机器学习·计算机视觉·cnn
Valueyou241 天前
引入基于加权 IoU 的 WiseIoU 回归损失以提升 CT 图像检测鲁棒性
人工智能·python·深度学习·目标检测
BestSongC1 天前
基于VUE和FastAPI的行人目标检测系统
vue.js·人工智能·yolo·目标检测·fastapi
王哈哈^_^1 天前
YOLO11实例分割训练任务——从构建数据集到训练的完整教程
人工智能·深度学习·算法·yolo·目标检测·机器学习·计算机视觉