Skip to content

Knee bend exercise detector that counts the successful rep count only if the user bends the knee for more than 8 seconds by using Mediapipe and OpenCV . The condition for the knee to be in a bent stage is that the angle between the hip, knee, and ankle should be smaller than 140 degree.

Notifications You must be signed in to change notification settings

Jeevesh28/Knee-Bend-Counter-Mediapipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knee Bend Exercise Counter

STEPS:

  • Remove duplicate frames
  • Configuring the Media Pipe
  • Estimating poses
  • Extracting joint coordinates
  • Calculating angles between joints
  • Inserting timer, stage (bent or relaxed), rep counter, and feedback

0. Remove duplicate frames:

  • Extract the individual frames of the video using a video processing library like OpenCV.
  • Once the frames are extracted, Python's built-in hashlib module is to compute a hash value for each frame, and then compare the hash values to identify duplicate frames.

1. Configuring the Media Pipe:

  • Install and import Mediapipe, it is a cross-platform library developed by Google that provides amazing, ready-to-use ML solutions for computer vision tasks.
  • Along with Mediapipe, install and import some other dependencies such as OpenCV and NumPy.

2. Estimating poses:

  • In this step, we will be estimating all the different joints and parts within our body.
  • Capture the video feed from the video file provided.
  • Recolor our image because when we pass the image to mediapipe it should be in RGB format, which is the default BGR when we read it.
  • Use the Pose estimation model to detect the pose.
  • Recolor the image back to the default BGR format.
  • Perform detections, i.e., draw landmarks from the video feed (e.g., nose, eyes, ears, shoulders, elbows, wrists).

3. Extraction of Joint Coordinates:

  • Use the pose estimation model to extract landmarks using detected pose estimation, as we did in the previous step.
  • Extract the landmarks for the main 3 joints that we need to calculate the rep count for knee-bending exercises which are hip, knee, and ankle.

4. Calculating angles between joints:

  • Calculate the angle between the hip, knee, and ankle to identify whether the leg is straight or bent.
  • For calculate the angle, we are going to calculate the radians with the help of three parameters passed to the function calculate_angle(), which are hip, knee, and ankle, by using a trigonometric function and then converting radian to angle.

5. Inserting timer, stage (bent or relaxed), rep counter, and feedback:

  • If the calculated angle is less than or equal to 140°, then the stage of the leg will be bent, and else if the calculated angle is greater than 140° and the stage is bent, then the stage will be relaxed.
  • A timeholder is used to measure the start time in starting when the stage changes from relaxed to bent stage, and the end time is measured when the stages changes from bent to relaxed stage, duration is calculated by subtracting the end time from the start time.
  • If a user can hold the leg in the bent stage for the duration of 8 or more than 8 seconds, then the rep count is incremented.
  • Otherwise if the user is unable to stay in the bent stage for more than 8 seconds, the feedback will print keep your knee bent.

About

Knee bend exercise detector that counts the successful rep count only if the user bends the knee for more than 8 seconds by using Mediapipe and OpenCV . The condition for the knee to be in a bent stage is that the angle between the hip, knee, and ankle should be smaller than 140 degree.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages