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

健身动作AI识别,仰卧起坐计数(含UI界面)

用Python和Mediapipe打造,让你的运动效果一目了然!
【技术揭秘】



利用Mediapipe的人体姿态估计,实时捕捉关键点,精确识别动作。
每一帧的关键点坐标和角度都被详细记录,为动作分析提供数据支持。
支持自定义动作训练,让AI更懂你的运动习惯。
【健身动作】

俯卧撑、引体向上、深蹲等常见健身动作,AI都能准确计数,帮你记录每一次进步。
界面友好,操作简单,让健身更加科学高效。
️【自定义功能】

可以根据自己的需求,训练或自定义动作,让AI成为你的私人健身教练。

opencv-python, mediapipe(用于人体姿态估计), 和 tkinter(用于GUI)

安装必要的库:

import cv2
import mediapipe as mp
import tkinter as tk
from PIL import Image, ImageTk# 初始化Mediapipe的Pose检测
mp_drawing = mp.solutions.drawing_utils
mp_pose = mp.solutions.pose
pose = mp_pose.Pose(min_detection_confidence=0.5, min_tracking_confidence=0.5)# 定义一个函数来检测仰卧起坐
def detect_sit_up(frame):image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)image.flags.writeable = Falseresults = pose.process(image)image.flags.writeable = Trueimage = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)if results.pose_landmarks:# 获取关键点landmarks = results.pose_landmarks.landmarkhip = landmarks[mp_pose.PoseLandmark.LEFT_HIP].yknee = landmarks[mp_pose.PoseLandmark.LEFT_KNEE].yankle = landmarks[mp_pose.PoseLandmark.LEFT_ANKLE].y# 判断是否完成一次仰卧起坐if hip < knee and hip < ankle:return Truereturn False# 定义一个函数来更新UI中的计数器
def update_counter(count):count_label.config(text=f"Count: {count}")# 主程序
def main():global rootcap = cv2.VideoCapture(0)sit_up_count = 0while True:ret, frame = cap.read()if not ret:break# 检测仰卧起坐is_sit_up = detect_sit_up(frame)# 如果检测到完成一次仰卧起坐,则增加计数if is_sit_up:sit_up_count += 1update_counter(sit_up_count)# 显示视频帧frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)img = Image.fromarray(frame)img_tk = ImageTk.PhotoImage(image=img)video_label.imgtk = img_tkvideo_label.configure(image=img_tk)root.update_idletasks()root.update()# UI界面
root = tk.Tk()
root.title("Sit-Up Counter")video_label = tk.Label(root)
video_label.pack()count_label = tk.Label(root, text="Count: 0")
count_label.pack()main()

此外,为了使代码运行,你需要确保你的环境中安装了所有必需的库,并且摄像头可以正常工作。

http://www.lryc.cn/news/419460.html

相关文章:

  • GitHub开源金融系统:Actual
  • 【学习笔记】Day 7
  • 网络中特殊的 IP 地址
  • ASP 表单处理入门指南
  • 极米RS10Plus性价比高吗?7款4-6K价位投影仪测评哪款最好
  • RocketMQ怎么对文件进行读写的?
  • 智慧宠物护理:智能听诊器引领健康监测新潮流
  • SRE工程师第2天:我只要截图功能 而不是打开微信
  • 【RunnerGo】离线安装成功版本
  • AI 手机的技术展望
  • 实战 Springboot2 集成Redis 哨兵模式、集群模式、缓存管理、Lettuce拓扑刷新
  • MYSQL--binlog和redo log
  • R语言医疗数据分析笔记
  • SpringBoot使用Jackson-XML裁剪多余的根节点
  • vue路由学习
  • Kubernetes基于helm部署Kafka_Kraft集群并取消SASL认证且开启数据持久化
  • kotlin -- Flow和Rxjava 对比
  • 【JVM篇】自动内存管理——HotSpot虚拟机对象探秘
  • 代谢组数据分析(十七):基于structToolbox代谢组分析流程讲解
  • 科普课堂走起 | 什么是网络安全和数据安全?
  • C语言中常用的函数
  • 如何在SpringBoot中进行单元测试?
  • 分布式事务学习整理
  • Conda配置瘦身术:精通conda config --remove命令
  • Windows下编译安装PETSc
  • phpstudy搭建sqlilabs本地靶场
  • Linux 实验基础环境准备(外网篇)
  • centos8 安装mysql 制作备份数据库脚本
  • Parsing error: The keyword ‘interface‘ is reserved配置优化
  • C语言指针详解-包过系列(二)目录版