1 Star 0 Fork 1

王晓鹏/cv_yolov8

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
inference_video.py 888 Bytes
一键复制 编辑 原始数据 按行查看 历史
王晓鹏 提交于 2024-10-09 18:20 +08:00 . add pose inference
import cv2
from ultralytics import YOLO
# Load the YOLOv8 model
model = YOLO("hat.pt") # pretrained YOLOv8n model
# Open the video file
video_path = "1.mp4"
cap = cv2.VideoCapture(video_path)
# Loop through the video frames
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(1) & 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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chris118/cv_yolov8.git
git@gitee.com:chris118/cv_yolov8.git
chris118
cv_yolov8
cv_yolov8
master

搜索帮助