跳至内容

Workouts Monitoring using Ultralytics YOLO11

Monitoring workouts through pose estimation with Ultralytics YOLO11 enhances exercise assessment by accurately tracking key body landmarks and joints in real-time. This technology provides instant feedback on exercise form, tracks workout routines, and measures performance metrics, optimizing training sessions for users and trainers alike.



观看: Workouts Monitoring using Ultralytics YOLO11 | Pushups, Pullups, Ab Workouts

锻炼监测的优势?

  • 优化性能:根据监测数据定制锻炼计划,以获得更好的效果。
  • 实现目标:跟踪和调整健身目标,以取得可衡量的进展。
  • 个性化:根据个人数据定制锻炼计划,提高效率。
  • 健康意识:及早发现表明存在健康问题或训练过度的模式。
  • 知情决策:以数据为依据,做出调整常规和设定现实目标的决定。

真实世界的应用

锻炼监测锻炼监测
俯卧撑计数引体向上计数
俯卧撑计数引体向上计数

锻炼监测示例

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

gym = solutions.AIGym(
    model="yolo11n-pose.pt",
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)

cv2.destroyAllWindows()
import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
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.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

gym = solutions.AIGym(
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)
    video_writer.write(im0)

cv2.destroyAllWindows()
video_writer.release()

关键点地图

keyPoints Order Ultralytics YOLO11 Pose

论据 AIGym

名称类型默认值说明
kptslistNone三个关键点索引列表,用于计算特定的锻炼,之后是关键点地图
line_widthint2绘制线条的厚度。
showboolFalse显示图像的标志。
up_anglefloat145.0向上 "姿势的角度阈值。
down_anglefloat90.0俯卧 "姿势的角度阈值。
modelstrNonePath to Ultralytics YOLO Pose Model File

论据 model.predict

论据类型默认值说明
sourcestr'ultralytics/assets'Specifies the data source for inference. Can be an image path, video file, directory, URL, or device ID for live feeds. Supports a wide range of formats and sources, enabling flexible application across different types of input.
conffloat0.25设置检测的最小置信度阈值。如果检测到的对象置信度低于此阈值,则将不予考虑。调整该值有助于减少误报。
ioufloat0.7Intersection Over Union (IoU) threshold for Non-Maximum Suppression (NMS). Lower values result in fewer detections by eliminating overlapping boxes, useful for reducing duplicates.
imgszint or tuple640定义用于推理的图像大小。可以是一个整数 640 for square resizing or a (height, width) tuple. Proper sizing can improve detection accuracy and processing speed.
halfboolFalseEnables half-precision (FP16) inference, which can speed up model inference on supported GPUs with minimal impact on accuracy.
devicestrNone指定用于推理的设备(例如:......)、 cpu, cuda:00).允许用户选择CPU 、特定GPU 或其他计算设备执行模型。
max_detint300每幅图像允许的最大检测次数。限制模型在单次推理中可检测到的物体总数,防止在密集场景中产生过多输出。
vid_strideint1视频输入的帧间距。允许跳过视频中的帧,以加快处理速度,但会牺牲时间分辨率。值为 1 时处理每一帧,值越大跳帧越多。
stream_bufferboolFalseDetermines whether to queue incoming frames for video streams. If False, old frames get dropped to accomodate new frames (optimized for real-time applications). If `True', queues new frames in a buffer, ensuring no frames get skipped, but will cause latency if inference FPS is lower than stream FPS.
visualizeboolFalse在推理过程中激活模型特征的可视化,从而深入了解模型 "看到 "了什么。这对调试和模型解释非常有用。
augmentboolFalse可对预测进行测试时间增强(TTA),从而在牺牲推理速度的情况下提高检测的鲁棒性。
agnostic_nmsboolFalse启用与类别无关的非最大抑制 (NMS),可合并不同类别的重叠方框。这在多类检测场景中非常有用,因为在这种场景中,类的重叠很常见。
classeslist[int]None根据一组类别 ID 过滤预测结果。只返回属于指定类别的检测结果。在多类检测任务中,该功能有助于集中检测相关对象。
retina_masksboolFalse如果模型中存在高分辨率的分割掩膜,则使用高分辨率的分割掩膜。这可以提高分割任务的掩膜质量,提供更精细的细节。
embedlist[int]NoneSpecifies the layers from which to extract feature vectors or embeddings. Useful for downstream tasks like clustering or similarity search.
projectstrNoneName of the project directory where prediction outputs are saved if save is enabled.
namestrNoneName of the prediction run. Used for creating a subdirectory within the project folder, where prediction outputs are stored if save is enabled.

论据 model.track

论据类型默认值说明
sourcestrNoneSpecifies the source directory for images or videos. Supports file paths and URLs.
persistboolFalseEnables persistent tracking of objects between frames, maintaining IDs across video sequences.
trackerstrbotsort.yamlSpecifies the tracking algorithm to use, e.g., bytetrack.yamlbotsort.yaml.
conffloat0.3Sets the confidence threshold for detections; lower values allow more objects to be tracked but may include false positives.
ioufloat0.5Sets the Intersection over Union (IoU) threshold for filtering overlapping detections.
classeslistNoneFilters results by class index. For example, classes=[0, 2, 3] only tracks the specified classes.
verboseboolTrueControls the display of tracking results, providing a visual output of tracked objects.

常见问题

How do I monitor my workouts using Ultralytics YOLO11?

To monitor your workouts using Ultralytics YOLO11, you can utilize the pose estimation capabilities to track and analyze key body landmarks and joints in real-time. This allows you to receive instant feedback on your exercise form, count repetitions, and measure performance metrics. You can start by using the provided example code for pushups, pullups, or ab workouts as shown:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)

cv2.destroyAllWindows()

有关进一步的自定义和设置,请参阅文档中的AIGym部分。

What are the benefits of using Ultralytics YOLO11 for workout monitoring?

Using Ultralytics YOLO11 for workout monitoring provides several key benefits:

  • 优化性能:根据监测数据定制锻炼计划,可以取得更好的效果。
  • 实现目标:轻松跟踪和调整健身目标,取得可衡量的进展。
  • 个性化:根据个人数据定制锻炼计划,达到最佳效果。
  • 健康意识:及早发现表明潜在健康问题或过度训练的模式。
  • 知情决策:以数据为依据做出决策,调整常规工作,制定切实可行的目标。

您可以观看YouTube 视频演示,了解这些优势的实际效果。

How accurate is Ultralytics YOLO11 in detecting and tracking exercises?

Ultralytics YOLO11 is highly accurate in detecting and tracking exercises due to its state-of-the-art pose estimation capabilities. It can accurately track key body landmarks and joints, providing real-time feedback on exercise form and performance metrics. The model's pretrained weights and robust architecture ensure high precision and reliability. For real-world examples, check out the real-world applications section in the documentation, which showcases pushups and pullups counting.

Can I use Ultralytics YOLO11 for custom workout routines?

Yes, Ultralytics YOLO11 can be adapted for custom workout routines. The AIGym 类支持不同的姿势类型,如 "俯卧撑"、"引体向上 "和 "腹肌锻炼"。您可以指定关键点和角度来检测特定的练习。下面是一个设置示例:

from ultralytics import solutions

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],
)

有关设置参数的更多详情,请参阅 论据 AIGym 部分。这种灵活性使您可以监控各种练习,并根据自己的需要定制例程。

How can I save the workout monitoring output using Ultralytics YOLO11?

要保存运动监控输出,可以修改代码,加入一个视频写入器,保存处理过的帧。下面是一个例子:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
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.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)
    video_writer.write(im0)

cv2.destroyAllWindows()
video_writer.release()

此设置可将监控视频写入输出文件。有关详情,请参阅 "使用保存输出进行锻炼监控"部分。

📅 Created 10 months ago ✏️ Updated 10 days ago

评论