Exercising is the most important thing to live a healthy life. To be free from injuries and getting the most from our workout proper form of exercise is important. Doing too much repetition and over training can cause muscle soreness. Unendingly doing exercise incorrectly could eventually cause severe future injuries. The rest between the sets should be optimum depending on the repetition of the exercise, what muscle group is being trained and the load that is being put in the muscle. Maximum Muscle hypertrophy is achieved with the correct form of exercise. The goal of the project is to build an exercise repetition counter and form corrector in a way so the optimum growth can be achieved with the help of cutting edge technology. The whole project is written in python. Simple easy to use tkinter GUI is used, Computer vision for live video input, media pipe for building machine learning solutions and numpy for mathematical calculations. Our system is built on the most recent advancements in deep learning for build cause estimation. We tend to the area units that are able to observe and find errors in user’s activity (pose) by effectively supporting some threshold deviation between the limb angles. If a person is doing exercises with the help of this system, the user\'s form is checked (corrections in form also will be given if any) repetition’s status and count is displayed. Along with this the AI dietitian calculates the maintenance calories, BMR, etc. This will increase muscle hypertrophy and reduce the risk of injury.
Introduction
I. INTRODUCTION
We all know that exercise is a very crucial part of our life. And it is very important to exercise with correct form. Sometimes we forget to keep a track on the number of reps. Doing a lot of exercise can lead to muscle tear or serious body injuries and can even decrease muscle hypertrophy. Nowadays people prefer working out at home. It is very convenient and time saving as well. We can workout anytime we want at home. But we also know that a trainer is very important to keep a track of our exercise. So this paper is an effort to make an AI based trainer. We have designed a virtual trainer. A system which will take care of all the parameters of workout like counting sets, repetitions and further giving suggestions to maximize muscle hypertrophy using AI and it will also check the form of exercise. The person will be doing his exercise live and live results will be given as outputs. There is a counter which will count the number of reps a person is doing while performing the workout. The status of the workout will also be displayed on the screen; the system will detect the motion of the exercise by calculating the angles between different points. Our project is a very fresh idea that will help people in their real life. We are aiming to give our best in this project and provide the best to the users.
II. MATERIALS AND METHODS
A. OpenCV- python
OpenCV- python is a python library used to solve computer vision problems efficiently. It makes use of numpy which is a highly optimized library for numerical calculations which is why OpenCV is fast and can be used in real time applications. OpenCV-python is used to give video input to the mediapipe pose pipeline. Media pipe is a cross platform customizable ML solution for live output.
At the core of our human pose estimation application lies a pose estimation algorithm that receives an image of a person as an input and outputs the coordinates of the specific key points or landmarks on the human body. First thing that we do in this pipe line is geometric transformation to resize and rotate the image (i.e frame of video). Then we convert the image into tensors so that I can run an ML model on it, then the tensor is decoded into high-level metadata (metadata has the coordinates for 33 different points on the body). Then these landmarks points are rendered onto the associated images. At last this live video output is displayed. The user receives the status of workout made and counts the reps of workout.
B. Getting Coordinates
The 3d coordinates in run time of exercise of shoulder, elbow, wrist are calculated using mediapipe pose model.
C. To Calculate Angle
The shorter angle between these 3 points is calculated using calculate_angle function which uses basic trigonometric functions readily available in numpy.
To calculate angle between vectors, get coordinates of 3 points detected from the mediapipe skeleton. In the function numpy arrays are used. To calculate angle in radians we are using numpy function arctan2 (i.e numpy.arctan2() method executes element by element arc tangent of arr1/arr2 selecting the quadrant properly. The quadrant is selected such that the point (x1, x2) give us the required angle in the radian between the rays meeting at the point of origin and effectively passing through the coordinate point (1, 0), and the ray meeting at the point of the origin and passing through the given point (x2, x1)). Then it converts the angle from radian to degrees and then returns it.
D. Curl Counter Logic
If the angle is greater than 160 degrees then the stage is set to 'down'. If the angle is less than 30 degrees and the stage is set to 'down' then stage set to 'up' and Counter is incremented by 1.
The angle will change continuously as the subject is performing exercise. Here we are using a flag named stage to get the position of hand while doing biceps curls and thus the reparations are calculated.
E. Form Corrector for Bicep Curl
Mediapipe has a pose skeleton to track the movement of exercise. By default the color of the skeleton is blue i.e when the form is correct.
When the form is wrong the mediapipe pose's skeleton's color is changed to pink and a beep sound is made using a python sound module. Indicating that the form of exercise is incorrect.
F. Tkinter
Tkinter is a GUI toolkit for python. It is a very basic UI kit. Following are the components used in the project.
A label may be an appliance that displays text or pictures, usually that users can simply read however not otherwise act with. Labels square measure used to spot controls or alternative components of the computer program, offer matter feedback or results, etc.
A button, in contrast to a frame or label, is extremely much there to act with. Users press a button to perform Associate in nursing action. Like labels, they will show text or pictures, however settle for further choices to vary their behaviour.
An entry widget provides users with one line text field wherever they'll sort during a string price. These are often around anything: a username, a city, a password, unique id, etc.
In Gridding multiple widget can take up multiple cells within the grid; to try this, we'll use the column span and rowspan choices for gridding the widget. These are analogous to the "colspan" and "rowspan" attributes of HTML tables. Here is an example of making a computer program with multiple widgets, some that take up more than one cell.
III. RESULTS
In this Project the frontend gui is designed by Tkinter. It will collect basic inputs like body weight, height, body age and gender. Further it will ask about fitness goals and accordingly information will be displayed. BMR (Basal Metabolic Rate), maintenance calories with macronutrients can be calculated using buttons. An output box is present in the gui on which information will be displayed. All this functionality is coded in python. It has a clear button to clear the screen. Following that there are a few exercises added like bicycle curls, shoulder press, squats and this AI powered tool will count reparations of your set. Any number of exercises can be added just by adding a few lines in the code. In the bottom there is a quit button to close the system after using it.
IV. ACKNOWLEDGMENT
We would like to thank our guide “Prof. Sushma K.” who gave us her valuable suggestions and ideas when we were in need of them. She encouraged us to work on this project. We are also grateful to our college for giving us the opportunity to work with them and providing us the necessary resources for the project.
Conclusion
The AI Gym trainer is an automated system based on machine learning and computer vision technologies. This system is successfully able to calculate the repetitions of gym exercises and correct form of the exercises which is very important for muscle hypertrophy. Along with these features the system has a BMR calculator which calculates the macros (i.e. daily requirement of carbohydrate, fats, protein) according to users fitness goal.