跳至内容

使用锻炼监测Ultralytics YOLO11

Colab 的开放式锻炼监控

通过姿势估算监测锻炼 Ultralytics YOLO11通过实时准确地跟踪关键的身体地标和关节,增强了运动评估功能。这项技术可提供有关锻炼姿势的即时反馈、跟踪锻炼程序并测量性能指标,从而优化用户和教练的训练课程。



观看: 使用Ultralytics YOLO11 监测锻炼情况 | 俯卧撑、引体向上、腹肌锻炼

锻炼监测的优势

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

真实世界的应用

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

使用Ultralytics YOLO监测锻炼情况

# Run a workout example
yolo solutions workout show=True

# Pass a source video
yolo solutions workout source="path/to/video.mp4"

# Use keypoints for pushups
yolo solutions workout kpts="[6, 8, 10]"
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)

    # print(results)  # access the output

    video_writer.write(results.plot_im)  # write the processed frame.

cap.release()
video_writer.release()
cv2.destroyAllWindows()  # destroy all opened windows

关键点地图

关键点顺序Ultralytics YOLO11  姿势

AIGym 论据

下面的表格显示了 AIGym 争论:

论据 类型 默认值 说明
model str None Ultralytics YOLO 模型文件的路径。
up_angle float 145.0 向上 "姿势的角度阈值。
down_angle float 90.0 俯卧 "姿势的角度阈值。
kpts list[int, int, int] [6, 8, 10] 用于监控锻炼的关键点列表。这些关键点与肩部、肘部和腕部等身体关节或部位相对应,用于俯卧撑、引体向上、深蹲、腹肌锻炼等运动。

"(《世界人权宣言》) AIGym 该解决方案还支持一系列物体跟踪参数:

论据 类型 默认值 说明
tracker str 'botsort.yaml' 指定要使用的跟踪算法,例如 bytetrack.yamlbotsort.yaml.
conf float 0.3 设置检测的置信度阈值;数值越低,跟踪的物体越多,但可能会出现误报。
iou float 0.5 设置交叉重叠 (IoU) 阈值,用于过滤重叠检测。
classes list None 按类别索引筛选结果。例如 classes=[0, 2, 3] 只跟踪指定的类别。
verbose bool True 控制跟踪结果的显示,提供被跟踪物体的可视化输出。
device str None 指定用于推理的设备(例如:......)、 cpu, cuda:00).允许用户选择CPU 、特定GPU 或其他计算设备执行模型。

此外,还可以应用以下可视化设置:

论据 类型 默认值 说明
show bool False 如果 True在一个窗口中显示注释的图像或视频。有助于在开发或测试过程中提供即时视觉反馈。
line_width None or int None 指定边界框的线宽。如果 None根据图像大小自动调整线宽。提供可视化定制,使图像更加清晰。

常见问题

如何使用Ultralytics YOLO11 监控我的锻炼?

使用Ultralytics YOLO11 监测锻炼情况时,您可以利用姿势估计功能实时跟踪和分析关键的身体地标和关节。这样,您就可以收到有关锻炼姿势、重复次数和性能指标的即时反馈。您可以先使用所提供的示例代码进行俯卧撑、引体向上或腹肌锻炼,如图所示:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.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 processing is complete.")
        break
    results = gym(im0)

cv2.destroyAllWindows()

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

使用Ultralytics YOLO11 进行锻炼监测有什么好处?

使用Ultralytics YOLO11 进行锻炼监测有几大好处:

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

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

Ultralytics YOLO11 在检测和跟踪演习方面的准确性如何?

Ultralytics YOLO11 具有最先进的姿态估计功能,能高度准确地检测和跟踪运动。它能准确跟踪关键的身体地标和关节,提供有关运动形式和性能指标的实时反馈。模型的预训练权重和稳健的架构确保了高精度和高可靠性。有关真实世界的示例,请查看文档中的真实世界应用部分,其中展示了俯卧撑和引体向上计数。

我可以使用Ultralytics YOLO11 来定制锻炼程序吗?

是的,Ultralytics YOLO11 可以改编成定制的锻炼程序。""是的。 AIGym 类支持不同的姿势类型,例如 pushup, pullupabworkout.您可以指定关键点和角度来检测特定的练习。下面是一个设置示例:

from ultralytics import solutions

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],  # For pushups - can be customized for other exercises
)

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

如何使用Ultralytics YOLO11 保存锻炼监控输出?

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

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video.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 processing is complete.")
        break
    results = gym(im0)
    video_writer.write(results.plot_im)

cap.release()
video_writer.release()
cv2.destroyAllWindows()

此设置可将监测到的视频写入输出文件,让您稍后查看锻炼表现,或与教练分享以获得更多反馈。

📅创建于 1 年前 ✏️已更新 5 天前

评论