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()
相关推荐
whoarethenext1 小时前
c/c++的opencv的轮廓匹配初识
c语言·c++·opencv
新手村领路人1 小时前
qt5.14.2 opencv调用摄像头显示在label
qt·opencv·命令模式
水花花花花花1 小时前
Transformer 架构在目标检测中的应用:YOLO 系列模型解析
目标检测·架构·transformer
Blossom.1184 小时前
从虚拟现实到混合现实:沉浸式体验的未来之路
人工智能·目标检测·机器学习·计算机视觉·语音识别·vr·mr
埃菲尔铁塔_CV算法6 小时前
深度学习驱动下的目标检测技术:原理、算法与应用创新
深度学习·算法·目标检测
白熊1888 小时前
【计算机视觉】OpenCV项目实战:基于face_recognition库的实时人脸识别系统深度解析
人工智能·opencv·计算机视觉
几道之旅8 小时前
mAP、AP50、AR50:目标检测中的核心评价指标解析
人工智能·目标检测·目标跟踪
白熊1889 小时前
【计算机视觉】OpenCV实战项目:GraspPicture 项目深度解析:基于图像分割的抓取点检测系统
人工智能·opencv·计算机视觉
yidaqiqi12 小时前
[目标检测] YOLO系列算法讲解
算法·yolo·目标检测
2201_7549184113 小时前
OpenCV 光流估计:从原理到实战
人工智能·opencv·计算机视觉