当前位置: 首页 > news >正文

PiscTrace应用:从 YOLO-Pose 到深蹲与引体向上计数:实时健身动作分析与实现

随着健身行业的发展,越来越多的智能应用涌现,用于帮助健身者更好地记录和分析运动情况。特别是在体能训练中,俯卧撑和引体向上是两个非常常见的动作,它们通常用来锻炼上半身力量和耐力。为了使训练更加科学和高效,实时监控和自动计数这些动作变得尤为重要。

在这篇博客中,我们将介绍如何基于 YOLO-Pose 模型来监控俯卧撑和引体向上的执行情况,并结合计算机视觉技术实现动作计数。我们将探索 YOLO-Pose 如何与人体姿势估计结合,通过检测人体关键点来判断动作的完成度,并最终实现运动计数功能。

1. YOLO-Pose 模型概述

YOLO(You Only Look Once)是一种高效的目标检测算法,以其在实时检测中的高性能而广受欢迎。随着 YOLO 系列的更新,尤其是 YOLOv8、YOLOv9、YOLOv10 和 YOLOv12,YOLO 已经不再仅仅局限于传统的目标检测任务,它还扩展到了包括人体姿势估计、实例分割、语义分割等任务。在姿势估计方面,YOLO-Pose 正是结合 YOLO 的强大检测能力,通过提取人体的关键点坐标来分析人体的运动状态。

YOLO-Pose 模型基于 YOLO 系列架构,专注于人体姿势估计,能够在视频流中实时检测人体的关键点并分析其运动。通过检测这些关键点的相对位置,我们可以判断出用户是否正在进行俯卧撑、引体向上等动作,并基于这些信息进行自动计数。

2. YOLO-Pose 在运动监控中的应用

在运动监控中,尤其是像俯卧撑和引体向上这样依赖肢体动作的训练项目中,我们通常需要对以下几个关节的姿势进行跟踪:

  • 俯卧撑监控:我们需要监控肩膀、肘部和腕部的相对位置,尤其是肘部的弯曲角度。

  • 引体向上监控:我们需要跟踪肩膀、肘部和手腕的运动,特别是手臂是否完全伸直或完全弯曲。

YOLO-Pose 提供的关节坐标(如肩膀、肘部、膝盖等)能够帮助我们精确地计算出这些动作的完成度。通过计算关键点之间的角度变化,我们可以准确判断是否完成了动作的一个循环。

2.1 俯卧撑监控

俯卧撑是一项主要锻炼上肢和胸部肌肉的动作,其标准动作包括双手撑地并弯曲肘部,直到胸部接近地面,然后恢复到初始姿势。在这种运动中,肘部角度的变化是判断动作是否完成的关键。

  • 当肘部角度小于某个阈值时,表示身体处于下压状态;

  • 当肘部角度大于阈值时,表示动作恢复到起始位置。

2.2 引体向上监控

引体向上是一项主要锻炼背部和上肢力量的运动。其标准动作是通过双手抓住横杆,弯曲肘部将身体拉起,直到下巴超过横杆位置,然后恢复到起始姿势。引体向上的关键监控点是肘部和肩膀。

  • 当肘部接近伸直时,表示动作结束;

  • 当肘部弯曲并拉升身体时,表示进入上升状态。

3. AIGym 类的实现:基于 YOLO-Pose 的实时运动监控

AIGym 类的实现中,我们使用了 YOLO-Pose 来处理实时视频流中的姿势估计。该类能够实时监控并统计不同类型的运动(如俯卧撑、引体向上等)。下面是 AIGym 类的核心代码,它实现了基于 YOLO-Pose 模型的运动监控和计数功能。

3.1 AIGym 类初始化
from ultralytics.utils.checks import check_imshow
from ultralytics.utils.plotting import Annotatorclass AIGym:"""A class to manage the gym steps of people in a real-time video stream based on their poses."""def __init__(self,kpts_to_check=None,line_thickness=2,pose_up_angle=145.0,pose_down_angle=90.0,pose_type="pullup",):"""Initializes the AIGym class with the specified parameters.Args:kpts_to_check (list, optional): Indices of keypoints to check. Defaults to [6, 8, 10].line_thickness (int, optional): Thickness of the lines drawn. Defaults to 2.pose_up_angle (float, optional): Angle threshold for the 'up' pose. Defaults to 145.0.pose_down_angle (float, optional): Angle threshold for the 'down' pose. Defaults to 90.0.pose_type (str, optional): Type of pose to detect ('pullup', 'pushup', 'abworkout', 'squat'). Defaults to "pullup"."""self.kpts_to_check = kpts_to_check or [6, 8, 10]  # Default keypointsself.tf = line_thicknessself.poseup_angle = pose_up_angleself.posedown_angle = pose_down_angleself.pose_type = pose_type# Initialize attributesself.im0 = Noneself.keypoints = Noneself.annotator = Noneself.env_check = check_imshow(warn=True)self.count = []self.angle = []self.stage = []

在初始化方法中,我们定义了以下参数:

  • kpts_to_check:关键点索引,指示需要监测的关节位置(例如,肩膀、肘部、腕部等)。

  • pose_up_anglepose_down_angle:这两个角度阈值用于判断动作的上下阶段,适用于不同的运动类型(如俯卧撑、引体向上)。

  • pose_type:指定需要监测的运动类型,如“pullup”(引体向上)、“pushup”(俯卧撑)等。

3.2 obj_exe 方法:实时处理视频帧
def obj_exe(self, im0, results):"""Function used to count the gym steps.Args:im0 (ndarray): Current frame from the video stream.results (list): Pose estimation data."""self.im0 = im0if not len(results[0]):return self.im0# Initialize annotator objectself.annotator = Annotator(self.im0, line_width=self.tf)# If there are more humans in the current frame, extend the count, angle, and stage listsif len(results[0]) > len(self.count):new_human = len(results[0]) - len(self.count)self.count.extend([0] * new_human)self.angle.extend([0] * new_human)self.stage.extend(["-"] * new_human)# Get keypoints from the pose estimation resultself.keypoints = results[0].keypoints.data# Iterate over each detected personfor ind, k in enumerate(self.keypoints):if self.pose_type in {"pushup", "pullup", "abworkout", "squat"}:# Calculate the angle between keypointsself.angle[ind] = self.annotator.estimate_pose_angle(k[int(self.kpts_to_check[0])].cpu(),k[int(self.kpts_to_check[1])].cpu(),k[int(self.kpts_to_check[2])].cpu(),)# Draw keypoints (no need to pass 'shape' argument)self.im0 = self.annotator.draw_specific_points(k, self.kpts_to_check, radius=10)# Determine the exercise stage and countif self.pose_type in {"abworkout", "pullup"}:if self.angle[ind] > self.poseup_angle:self.stage[ind] = "down"if self.angle[ind] < self.posedown_angle and self.stage[ind] == "down":self.stage[ind] = "up"self.count[ind] += 1elif self.pose_type in {"pushup", "squat"}:if self.angle[ind] > self.poseup_angle:self.stage[ind] = "up"if self.angle[ind] < self.posedown_angle and self.stage[ind] == "up":self.stage[ind] = "down"self.count[ind] += 1# Annotate the angle, count, and stage on the imageself.annotator.plot_angle_and_count_and_stage(angle_text=self.angle[ind],count_text=self.count[ind],stage_text=self.stage[ind],center_kpt=k[int(self.kpts_to_check[1])],)# Draw keypoint linesself.annotator.kpts(k, radius=1, kpt_line=True)return self.im0

obj_exe 方法中,YOLO-Pose 模型的输出结果被传递给 AIGym 类,我们利用关键点的角度变化来判断用户的动作是否完成,并更新计数。根据运动类型(如“俯卧撑”或“引体向上”),代码会判断当前动作是否已经完成一个周期(上升和下压)。

4. 总结与未来展望

基于 YOLO-Pose 模型的实时运动监控系统能够为用户提供精准的动作计数和实时反馈。无论是在家庭健身、健身房还是专业训练中,这样的智能系统都可以帮助用户更好地掌握自己的训练效果。通过跟踪关键点和计算角度,YOLO-Pose 可以实时检测各种运动姿势,帮助用户提高运动质量,防止错误动作。

随着 YOLO-Pose 技术的不断进步和计算机视觉领域的创新,未来这些技术将在更广泛的应用场景中发挥更大的作用,包括康复训练、运动科学研究等领域。通过不断优化算法,增加更多的运动姿势监测功能,未来的智能健身系统将更加精准、智能和高效。

对 PiscTrace or PiscCode感兴趣?更多精彩内容请移步官网看看~🔗 PiscTrace

引体向上效果在这里使用 YOLO 姿态模型进行动作判定和监测:如何在 PiscTrace 中实现引体向上检测_yolo 姿态监控-CSDN博客

http://www.dtcms.com/a/271312.html

相关文章:

  • 语音大模型速览(二)- cosyvoice
  • Flink-1.19.0源码详解-番外补充4-JobGraph图
  • Ubuntu 下 MySql 使用
  • qt-C++笔记之布局管理`space` 和 `margin`的区别
  • SQL注入与防御-第六章-3:利用操作系统--巩固访问
  • kbmMemTable Pro 7.82 Delphi 11 源代码
  • Spectre(幽灵漏洞)是什么?
  • Python-FAQ-单例模式
  • MyBatis之数据操作增删改查基础全解
  • Java常用设计模式大全
  • Kubernetes 存储入门
  • HTTP请求走私漏洞
  • 【Python】FastApi
  • P1009 [NOIP 1998 普及组] 阶乘之和
  • HashMap中get()、put()详解
  • 代码审计-shiro漏洞分析
  • Explain关键字
  • rt thread studio 和 KEIL对于使用rt thread 的中间件和组件,哪个更方便
  • Flask3.1打造极简CMS系统
  • VsCode 接入Continue 远程调用(持续扩展 + DeepSeek R1)— 免本地算力
  • ZECN致业:科创微光,照亮技术新征程
  • 200nl2sql
  • Linux建立本地软件仓库
  • 存储服务一NFS文件存储概述
  • 解锁HTML5页面生命周期API:前端开发的新视角
  • debug和release的区别,打印菱形,水仙花数,喝汽水问题,计算求和
  • 从互联网电脑迁移Dify到内网部署Dify方法记录
  • 语音识别核心模型的数学原理和公式
  • http get和http post的区别
  • 【软件工程】tob和toc含义理解