Smart Exercise with Streamlit And Mediapipe
Introduction
Since I didn't have access to a sports coach, I decided to make a coach :) My idea was to use pose detectoin to track my body movements during exercise to see if my movements are correct or not.
So If I do the exercises correctly, they are counted for me to reach my desired amount
How it works :
For the project, it can truck three sports movements and count them if you perform the movement correctly (Side raises, Standing cruls, Squats)
Track My Pose
I realized that there is an angle between the joints to perform sports movements, so we can use the angle between the joints to track the correct sports movements.
To get the angle of my joints, I needed a tool that can track my body and joints movements in real time. I used Mediapipe for this, an open-source cross-platform framework with solutions for live and streaming media. Developed by Google, Mediapipe allows me to recognize my pose in realtime with appropriate fps, and each of the joints in mediapipe has a unique id, which makes my work much easier.
Calculate Between Angles
After extracting the points of the joints, I needed to calculate the angle between the joints, for this I used the numpy library to solve linear algebra equations.
After acquiring the ability to calculate the angle between the joints, I needed to find the correct angle of the sports movements and since I did not have much experience in exercising, I was able to find the correct angle of the joints of the sports movements using this YouTube video and I was able to Use some simple conditions to implement them.
Implement User Interface
And now it was time to implement an environment that had a suitable user interface, although I had given opencv a visual form in realtime, but I wanted to use a web environment for this, so I used Streamlit, a very fast environment. Based on Python, which allowed me to implement my model in the fastest way in the web environment.
Working with streamlit was very easy for me because it was completely written in Python and had strong documentation and it didn't take me much time to learn it.
Setup and Run Project
1 - Clone project : -
Open Project github repository
Download project
OR
Clone project
2 - Install requirement libraries and packages : -
cd yourdir/Smart_Exercise-master
Install packages by running :
pip install -r requirements.txt
3 - Run Project
streamlit run home_page.py
And open :