概述
Ultralytics提供了一系列的解决方案,利用YOLO11解决现实世界的问题,包括物体计数、模糊处理、热力图、安防系统、速度估计、物体追踪等多个方面的应用。
通过实时准确地跟踪关键的身体位置和关节,增强了运动评估功能。这项技术可提供有关锻炼姿势的即时反馈、跟踪锻炼程序并测量性能指标,从而优化用户和教练的训练课程。
演示代码
Ultralytics提供了演示代码,展示如何使用锻炼监测解决方案。
import cv2
from ultralytics import solutions
cap = cv2.VideoCapture("path/to/video.mp4")
assert cap.isOpened(), "Error reading video file"
# Video writer
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
video_writer = cv2.VideoWriter("workouts_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
# Init AIGym
gym = solutions.AIGym(
show=True, # display the frame
kpts=[6, 8, 10], # keypoints for monitoring specific exercise, by default it's for pushup
model="yolo11n-pose.pt", # path to the YOLO11 pose estimation model file
# line_width=2, # adjust the line width for bounding boxes and text display
)
# Process video
while cap.isOpened():
success, im0 = cap.read()
if not success:
print("Video frame is empty or processing is complete.")
break
results = gym(im0)