python调用yolo11实现视频目标监测识别示例代码

代码语言:python

所属分类:其他

代码描述:python调用yolo11实现视频目标监测识别示例代码

代码标签: python 调用 yolo11 视频 目标 监测 识别 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#!/usr/local/python3/bin/python3
# -*- coding: utf-8 -*
from ultralytics import YOLO
import cv2

# Load the YOLOv11 model
model = YOLO('yolov11n.pt')

# Open the video file
video_name = "path_to_your_video.mp4"
cap = cv2.VideoCapture(video_name)

while cap.isOpened():
    # Read a frame from the video
    success, frame = cap.read()

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

        # Visualize the results .........完整代码请登录后点击上方下载按钮下载查看

网友评论0