Push-up Counter Application using python

junaid ali
5 min readMay 13, 2023

--

The Push-up Counter application is a computer vision-based program developed using Python. As the name suggests we have implemented the logic for counting the number of push ups done by a real person using machine vision. We have used the OpenCV library,tkinter,PIL and mediapipe for video capture and processing, building a graphical user interface (GUI), for image manipulation and for pose estimation respectively.

Front pose for push-up counting

We have used a video file in this particular application as an input to capture number of push ups. It implements this task by using computer vision technique that is specifically capturing the body position and utilizing it for number of counts . The user can choose between using the webcam or selecting a video file to track and count push-ups.

Theoretical Background of Push up counter algorithm

Pose estimation techniques is used by the Counter algorithm to track and count the number of pushes in real-time. The theoretical background of this algorithm is following.

1. Pose Estimation:
It is a technique used for tracking the position and orientation of the person during the movement. Pose estimation uses the information collected from the web camera or video source as input by capturing key body landmarks or joints to track the movement performed by the person.

2. Body Landmarks:

A person, s body pose can be detected by using body landmarks, to be more precise body joints . These landmarks includes key the following points that we have used in the code such as

1.Shoulders

2.Elbows

3.Wrists

The algorithm can be used to judge the pose of the person performing push-ups tracking with the help of the movements and positions of the above landmarks.

3. Mediapipe:
The mediapipe library, containing two items in particular, is used for this task.i.e., pose determination techniques and machine learning models that have already been trained. In order to connect to these models and carry out pose estimation activities, API is required. The result makes it possible for the algorithm to identify and follow body features in live video frames.

4. Key Point Detection:
The pose determine model supplied by mediapipe is used by the algorithm to process each video frame. It examines the image and locates the important bodily landmarks. These landmarks serve in for the wrists and elbows that are used when accomplishing push-ups.

5. Push-up Counting Logic:
The algorithm then monitors the movement of the subject’s body to assess whether a push-up is being completed once the landmarks have been identified. By evaluating the relative placements of the important landmarks, including the elbows and wrists, it achieves this. For instance, during a repetition of a push-up, the elbow landmark will shift closer the wrist landmark as the body is dropped.

The method calculates push-ups using a straightforward logic. It keeps track of the body’s upward and downward motions and increases the number of push-ups accomplished each time the whole push-up action is finished. For instance, one complete push-up is when the body moves from a depressed position (downward phase) to a totally extended position (upward phase).

The application can exactly count the number of push-ups the user performs in real-time by processing video frames continually, identifying body landmarks, and evaluating the movements of these landmarks.

For the purpose of to track and count push-ups during an exercise session, the Push-up Counter algorithm integrates pose estimate techniques, key point identification, and a push-up counting logic. It uses the media-pipe library to calculate present pose calculation, making it an effective tool for tracking and keeping track of fitness levels.

Implementation in Python

Following are the screenshots of the main logic for push up application.

Arguments we need to know using push up counter code:

One must be aware of a few arguments or variables while using the Push-up Counter code. To alter how the application behaves, these arguments can be changed. The key arguments are as follows:

min_detection_confidence: When establishing the md_pose, this argument is implemented with the object assuming a pose. It indicates the minimal confidence level necessary for a body part detection to be accepted as genuine. A larger number guarantees more precise detections but could produce fewer detections. You can change it to suit your demands if the default value of 0.7 doesn’t work for you.Example:

pose = md_pose.Pose(min_detection_confidence=0.7

min_tracking_confidence: The initialization of the md_pose additionally makes use of this argument. It specifies the minimal confidence level that must be attained for body part tracking to be accepted. When a body part is being monitored, the algorithm must be able to recognise it in different frames. A more significant value guarantees more exact following, but it may also be more susceptible to subtle changes. The default value is 0.7, however you can change it as necessary.Example:

pose = md_pose.Pose(min_tracking_confidence=0.7)

The pose estimation algorithm’s responsiveness and accuracy are governed by these factors. Based on the particular demands of your environment or the user’s movements, adjusting them may help adjust your detection and tracking capabilities.

Conclusion

The Push-up Counter software presents users with a fun and interactive way to keep track of their push-up progress. It is an efficient tool for fitness enthusiasts and people who adhere to specific workout programmes because it eliminates the need for manual counting and offers real-time feedback.

--

--