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()
相关推荐
HyperAI超神经11 小时前
128K长上下文+智能体强化训练!LFM2.5-2.6B解锁端侧大模型高效部署;DETR用Transformer斩断NMS与Anchor,重塑目标检测
人工智能·深度学习·目标检测·计算机视觉·数据集·transformer
浪里镖客12 小时前
zed 2i相机坐标系与内参、外参
数码相机·opencv·计算机视觉
leoZ23114 小时前
Vue3 还原一个企业级后台-11-Mock数据策略
opencv·计算机视觉·数据挖掘·语音识别·caffe
AndrewHZ1 天前
图像处理入门(第005期):颜色空间入门——RGB/HSV/CMYK/Lab
图像处理·python·opencv·hsv·rgb·色彩空间
动物园猫2 天前
狗行为目标检测数据集:6类别、近3,000张图像 | 目标检测
人工智能·目标检测·计算机视觉
极创信息2 天前
系统安全隐患全方位排查方案:标准化渗透测试全流程
java·opencv·struts·数据挖掘·eclipse·语音识别·hibernate
reset20212 天前
OpenCV 图像算法梳理分析
人工智能·opencv·算法
别动我齐刘海2 天前
机器学习基础3——C++、OpenCV、点云、Open3D
c++·人工智能·opencv·目标检测·机器学习·机器人·ros2
欧特克_Glodon2 天前
OpenCV计算机视觉开发入门与实践<七>:OpenCV 界面编程之窗口
c++·人工智能·opencv·计算机视觉
m0_617493943 天前
OpenCV cv2.circle() 坐标类型错误排查与修复指南
人工智能·opencv·计算机视觉