Professional Documents
Culture Documents
Major Project Format
Major Project Format
BACHELOR OF TECHNOLOGY
In
CSE (Artificial Intelligence & Machine Learning)
BY
XXXXXXXXXXX 20BH1AXXX
XXXXXXXXXXX 20BH1AXXX
XXXXXXXXXXX 20BH1AXXX
XXXXXXXXXXX 20BH1AXXX
EXTERNAL EXAMINER
ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of this project would be
incomplete without the mention of the people who made it possible. We consider it as a
privilege to express our gratitude and respect to all those who guided us in the completion of
the project.
We are thankful to our internal guide Mr. M. APPARAO, MTech, (Ph.D) in
Department of CSE (Artificial Intelligence & Machine Learning), St. Mary’s
Engineering College for having been of a source encouragement and for insisting vigour to
do this project work
We are obliged to Dr. K Suresh Kumar , Head of the Department of CSE
(Artificial Intelligence & Machine Learning), St. Mary’s Engineering College for
his guidance and suggestion throughout project work.
We take this opportunity to express a deep sense of gratitude to Dr. T.N. Srinivas Rao,
Principal of St. Mary’s Engineering College for allowing us to do this project and for this
affectionate encouragement in presenting this project work.
We convey our sincere thanks to Sri Rev. K.V.K RAO, Chairman of St. Mary’s
Engineering College for giving us learning environment to grow out self personally as well
as professionally.
We would like to express our thanks to all staff members who have helped us directly and
indirectly in accomplishing this project work. We also extended our sincere thanks to our
parents and friends for their moral support throughout the project work. Above all we thank
god almighty for his manifold mercies in carrying out this project work successfully.
XXXXXXXXXX -20BH1AXXXX
XXXXXXXXXX -20BH1AXXXX
XXXXXXXXXX -20BH1AXXXX
XXXXXXXXXX -20BH1AXXXX
DECLARATION
XXXXXXXXXX -20BH1AXXXX
XXXXXXXXXX -20BH1AXXXX
XXXXXXXXXX -20BH1AXXXX
XXXXXXXXXX -20BH1AXXXX
CONTENTS
CHAPTER NAME PAGE No
1. INTRODUCTION 1-2
1.1 INTRODUCTION TO PROJECT 1
1.2 FEATURES 2
3.1 INTRODUCTION 7
3.2 EXISTING SYSTEM &ITS DISADVANTAGES 7
3.3 PROPOSED SYSTEM &ITS ADVANTAGES 8
3.4 INPUT DESIGN 9
3.5 OUTPUT DESIGN 10
5. SYSTEM REQUIREMENTS 13
7.1 ANDROID 16
7.2 DOWNLOAD THE ANDROID SDK 24
7.3 ECLIPSE 33
9.1 INTRODUCTION 45
9.2 CLASS DIAGRAM 46
9.3 SEQUENCE DIAGRAM 47
9.4 USECASE DIAGRAM 48
9.5ACTIVITY DIAGRAM 49
11.1 INTRODUCTION 66
11.2 TYPES OF TESTINGS 66
11.2.1 UNIT TESTING 66
11.2.2 INTEGRATION TESTING 67
11.2.3 FUNCTIONAL TESTING 67
11.2.4 SYSTEM TESTING 68
11.2.5 WHITE BOX TESTING 68
11.2.6 BLACK BOX TESTING 68
11.2.7 ACCEPTANCE TESTING 69
13. CONCLUSION 79
LIST OF FIGURES
FIGURE
S.NO FIGURE NAME
NO
1 7.1.1 ANDROID ARCHITECTURE
SELECT ANDROID AND MAINTAIN THE INSTALLATION PATH
2 7.2.1
OF THE ANDROID SDK.
3 7.2.2 SELECT ANDROID SDK AND AVD MANAGER
4 7.2.3 SELECT ANDROID SDK AND AVD MANAGER
5 7.2.4 INSTALLING THE ADT PLUGIN FOR ECLIPSE
6 7.2.5 PACKAGES AVAILABLE FOR DOWNLOAD
7 7.2.6 CHOOSE PACKAGES TO INSTALL
8 7.2.7 INSTALLING ARCHIVES
9 7..31 SOURCE CODE
10 7.3.2 SELECT NEW VIRTUAL DEVICE
11 7.3.3 CREATE NEW ANDROID VIRTUAL DEVICE
12 7.3.4 TEST DEVICE
13 8.1.1 DATA FLOW DIAGRAM
14 9.2 CLASS DIAGRAM
15 9.3 SEQUENCE DIAGRAM
16 9.4 SEQUENCE DIAGRAM
17 9.5 ACTIVITY DIAGRAM
LIST OF PLATES
INTRODUCTION
1.1 Introduction
In the domain of Artificial Intelligence (AI) based fitness coaching, weightlifting is a flow
of body movement pack in an organized exercise to force the body muscles to contract under
tension by using weights such as barbells, dumbbells or even body weights in order to trigger
growth, strength, endurance and power. This exercise can be helpful to personal health. However,
it can also be potentially dangerous and inefficient if the exercise is performed in wrong posture
by the trainees. Performing wrong posture is a very common issue for every gymnast, either
beginner or even professional. This is because it is a big challenge for trainees to perform a series
of complex movements in weightlifting exercise. Posture issues can manifest into many different
conditions that can put trainee health in danger, such as neck pain, back pain, shoulder pain or
knee pain. Correct posture is able to minimize the strain on the human body by maintaining the
balance between muscles and skeleton. This balanced musculoskeletal state is very important
because it prevents further damage or any progressive deformation in weightlifting training and
protects the supporting structures in the body. Therefore, performing correct posture is a very
crucial aspect for proper arrangement of supporting structures, maintaining balance of the body
and effective functioning of the body.
1.2 Features
There are many fitness apps available in market which allows user to keep track of
their health and provide a workout plan to user to achieve their personal fitness goal.
These app have many functions that provide user with only data to user it does not actually
provide a space where user can do their work out without going to gym or having a personal
trainer.
These apps do not overview whether the user is actually doing the exercise and if they
Recently the number of people exercising at home has increased especially required
due to the COVID19 pandemic. Therefore, the need for no contact exercise instructions is in
great demand since physical access to the gym is limited or discouraged. To meet this demand,
many online exercise instruction videos are available. However, the systems are both passive
1
and have no real time feedback to aid the user. In this work, we propose an AI based fitness
monitoring system (AI Fitness Coach) that can offer real time guidance during exercise. The
AI Fitness Coach consists of a pose recognition unit, a fitness movement analysis unit, and a
feedback unit. The user captures their pose by a fixed camera. The pose recognition unit
processes the captured image and outputs the recognition result to the fitness movement
analysis unit. After the results are processed by the fitness movement analysis unit, advice is
output from the device through video or voice. On comparison to existing methods, the
proposed method results are at par and encouraging.
There are many fitness apps available in market which allows user to keep track of
their health and provide a workout plan to user to achieve their personal fitness goal. These
app have many functions that provide user with system monitor also provide a only data to
user does not work out without going to gym or having a personal trainer. These apps do not
overview whether the user is actually doing the exercise and if they are doing correctly. To
overcome the above disadvantage of all existed system we introduce our project AI Fitness
trainer. This project is can defined as AI which detects our human body during our workout
and gives critical feedback on our exercise form and does rep count so user can put all their
focus and energy in the doing our workout rather than keeping the count of our exercise. The
system overcome the important disadvantage of not being able to workout at home and at any
time without guidance.
2
The system provides us the opportunity to work out anywhere, anytime with guidance so
we can do effective workout. System uses computer vision technology to execute the
functions of our system. The system uses state-of-the-art pose detection tool known as “Blaze
Pose” from “Media Pipe” to detect the form of the user’s body during the workout. OpenCV
is used to mark an exoskeleton on the user body and display reps count on the screen. System
uses different videos and photos of specific exercise to create 1000 of data of landmarks key
points and save as csv file use that dataset to train the ML model of that specific exercise
using machine learning classification algorithm named random forest classifier.
3
CHAPTER 2
LITERATURE SURVEY
2.1 Chapter Overview
After discovering some introductory papers about the human posture detection, there
are few approaches to detect the human posture in weightlifting and some of them are able to
evaluate and make correction for correct posture.
An approach which named Pose Trainer has been introduced by Chen et al. (2018) for
detecting and correcting human posture by using pose estimation. This approach consists of
three parts that constructed by six components. The first part has only one component, Video
Recording and it can only be done by user. The next part is built from Pose Estimation, Key
point Normalization and Exercise Detection. A state-of-the-art pose estimation deep neural
network, Open Pose from OpenCV is used within Pose Trainer for inference. The third part
involves detecting the quality of user’s predicted pose for specific exercise, which are Posture
evaluation.
In the first component, the video must be recorded from a particular perspective such as
facing front the camera or facing side to the camera that allows the exercise to be seen
clearly. Moreover, Pose Trainer does not require distance between body and camera or type
of camera. However, Pose Trainer does require user to crop and edit the exercise video by
themselves, which explaining why segmentation of replication in one exercise does not exist
in this application.
For the next component, deep Convolutional Neural Network (CNN) to label Red
Green Blue images. Open Pose, a pre-trained model is chosen for pose detection after
comparing multiple state-of-the-art pose estimators. The output of open Pose contained
coordinate of 18 key point locations and their respective confidence levels. The predicted key
points include nose, neck, shoulder, elbows, wrists, hips, knees, and ankles.
There are two purposes in key point Normalization step.First, a parser is wrote to use
the raw key point output from open Pose.List of key points are read while 2- coordination and
confidence level are segmented into joint key point object. Obscure key point that has zero
confidence level is eliminated. A Pose object which is a full skeletal estimation of a person is
4
constructed by composing each joint key point in every video frame. Then, a Pose Sequence
is composed to chain all Pose objects from each video frame. Secondly, in order to account
distance between body and camera, different body length measurements and other potential
problem, the pose is normalised based on the torso’s length in pixels. The torso length is
calculated by average distance from neck joint to right and left hip joints.
The fourth component is Perspective Detection. In this step, the ambiguity in camera
perspective is resolved. For instance, the bicep curl exercise can be recorded from the side of
camera and could be performed by one or both arms.
For second last component Evaluation Exercise can be achieved by two approaches,
geometric algorithm, and machine learning algorithm. First, geometric heuristics are designed
from key points of interest and personal training guidelines, in order to evaluate the body
vector. Secondly, a more data-driven which is machine learning approach is introduced to
evaluate the exercise posture. Since the recorded video can be any arbitrary length, this
caused different key point vector length such as exercise speed and this is a big challenge for
many machine learning algorithms.
Therefore, Dynamic Time Warping (DTW) with K-Nearest Neighbour (KNN) classifier is
chosen and it is a metric used to measure non-linear similarity between two time series. In
DTW, key point in second sequence is dynamically identified that corresponded to given key
point in first sequence. A distance matrix that consists Euclidean distance from different key
points in two sequences is measured by iterating all points using dynamic programming.
KNN classifier can predict correct or incorrect posture based from DTW distances.
There are various advantages and disadvantages found in this paper. One of the
advantages is user of Pose Trainer only needs to download open Pose and install Anaconda to
make it workable, by choosing open Pose. Unlike TensorFlow or Caffe, which require
complex user installations such as CUDA and CUDNN GPU libraries. Another advantage is
Pose Trainer can track multiple exercises instead of one with high accuracy, which make it
has high commercial value than the other similar apps.
For the disadvantages, Pose Trainer does not design as application, which means it is not
functional on phone. In order to solve this, they should export Pose Trainer to smartphones,
building an application that allows users to record video and get feedback at any place, any time.
The next disadvantage is Pose Trainer only able to provide posture feedback with vocabulary
format. This might be confusing to user because user may interpret the feedback with different
meaning or does not even understanding the meaning of feedback.
5
CHAPTER 3
BLOCK DIAGRAM, HARDWARE & SOFTWARE
DESCRIPTION
• Software required
• Anaconda Libraries:
• Media pipe
6
• Open CV
• NumPy
• Tkinter
The Anaconda distribution comes with over 250 packages automatically installed.
Over 7500 additional open-source packages can be installed from PyPI as well as the condo
package and virtual environment manager. It also includes a GUI (graphical user interface),
Anaconda Navigator, as a graphical alternative to the command line interface. Anaconda
Navigator is included in the Anaconda distribution and allows users to launch applications
and manage conda packages, environments and channels without using command-line
commands. Navigator can search for packages, install them in an environment, run the
packages and update them.
The big difference between conda and the pip package manager is in how package
dependencies are managed, which is a significant challenge for Python data science. When
pip installs a package, it automatically installs any dependent Python packages without
checking if these conflict with previously installed packages. It will install a package and any
of its dependencies regardless of the state of the existing installation. Because of this, a user
with a working installation of, for example Tensor flow, can find that it stops working after
using pip to install a different package that requires a different version of the dependent
NumPy library than the one used by TensorFlow. In some cases, the package may appear to
work but produce different results in execution. In contrast, conda analyzes the current
environment including everything currently installed, and together with any version
limitations specified (e.g., the user may wish to have TensorFlow version 2.0 or higher),
works out how to install a compatible set of dependencies, and shows a warning if this cannot
be done.
7
Anaconda Cloud (anaconda.org), or the user’s own private repository or mirror, using the
conda
8
install command. Anaconda Inc. compiles and builds the packages available in the Anaconda
repository itself, and provides binaries for Windows 32/64-bit, Linux 64-bit and MacOS 64-
bit. Anything available on PyPI may be installed into a conda environment using pip, and
conda will keep track of what it has installed itself and what pip has installed.
Typically, image or video input data is fetched as separate streams and analysed using
neural networks such as TensorFlow, PyTorch, CNTK, or MX Net. Such models process data
in a simple and deterministic method: one input generates one output, which allows very
efficient processing execution. media Pipe, on the other hand, operates at much higher-level
semantics and allows more complex and dynamic behaviour. For example, one input can
generate zero, one, or multiple outputs, which cannot be modelled with neural networks.
Video processing and AI perception require streaming processing compared to batching
methods.
9
The main components of Media Pipe:
Packet: The basic data flow unit is called a “packet.” It consists of a numeric timestamp and
a shared pointer to an immutable payload.
Graph: Processing takes place inside a graph which defines the flow paths of packets
between nodes. A graph can have any number of input and outputs, and branch or merge data.
Nodes: Nodes are where the bulk of the graph’s work takes place. They are also called
“calculators” (for historical reasons) and produce or consume packets. Each node’s interface
defines a number of in- and output ports.
Streams: A stream is a connection between two nodes that carries a sequence of packets with
increasing timestamps.
3.2.3 Open CV
Along with well-established companies like Google, Yahoo, Microsoft, Intel, IBM,
Sony, Honda, Toyota that employ the library, there are many startups such as Applied Minds,
VideoSurf, and Zeitera, that make extensive use of OpenCV. OpenCV’s deployed uses span
the range from stitching streetview images together, detecting intrusions in surveillance video
in Israel, monitoring mine equipment in China, helping robots navigate and pick up objects at
Willow Garage, detection of swimming pool drowning accidents in Europe, running
interactive art in Spain and New York, checking runways for debris in Turkey, inspecting
labels on products in factories around the world on to rapid face detection in Japan.
It has C++, Python, Java and MATLAB interfaces and supports Windows, Linux,
Android and Mac OS. OpenCV leans mostly towards real-time vision applications and takes
advantage of MMX and SSE instructions when available. A fullfeatured CUDA and OpenCL
interfaces are being actively developed right now. There are over 500 algorithms and about
10 times as many functions that compose or support those algorithms. OpenCV is written
natively in C++ and has a templated interface that works seamlessly with STL containers.
3.2.4 NumPy
NumPy is a Python library used for working with arrays. It also has functions for
working in domain of linear algebra, Fourier transform, and matrices. NumPy was created in
2005 by Travis Oliphant. It is an open-source project and you can use it freely.
multidimensional array object, and tools for working with these arrays.
11
It is the fundamental package for scientific computing with Python. It is opensource
• Mac and Linux users can install NumPy via pip command: #pip install numpy
• Windows does not have any package manager analogous to that in linux or unix or
any mac. Please download the pre-built windows installer for NumPy from here (according
to your system configuration and Python version). And then install the packages manually.
3.2.5 Tkinter
Tkinter is the standard GUI library for Python. Python when combined with Tkinter
provides a fast and easy way to create GUI applications. Tkinter provides a
powerful object-oriented interface to the Tk GUI toolkit. Import the Tkinter module
Python offers multiple options for developing GUI (Graphical User Interface). Out of
all the GUI methods, tkinter is the most commonly used method. It is a standard Python
interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and
easiest way to create the GUI applications.
As mentioned, Tkinter is Python's default GUI library, which is nothing but a wrapper
12
Tkinter is based upon the Tk toolkit, and which was originally designed for the Tool
GUI development portability and flexibility of Tk makes it the right tool which can be used to
design and implement a wide variety of commercial-quality GUI applications. Python with
Tkinter provides us a faster and efficient way in order to build useful applications that would
have taken much time if you had to program directly in C/C++ with the help of native OS
system libraries.
Once we have Tkinter up and running, we'll use basic building blocks known as widgets to
create a variety of desktop applications.
Operating system:
Windows 8 or newer, 64-bit macOS 10.13+, or Linux, including Ubuntu, RedHat, CentOS
7+, and others. If your operating system is older than what is currently supported, you can
find older versions of the Anaconda installers in our archive that might work for you.
System architecture:
Windows- 64-bit x86; MacOS- 64-bit x86 & M1; Linux- 64bit x86, 64-bit aarch64 (AWS
Graviton2), 64-bit Power8/Power9, s390x (Linux on IBM Z & LinuxONE).
Minimum 5 GB disk space to download and install. On Windows, macOS, and Linux, it
is best to install Anaconda for the local user, which does not require administrator
permissions and is the most robust type of installation. However, with administrator
permissions, you can install Anaconda system wide
13
Add packages to the Anaconda environment using the pip command
Open Anaconda Command prompt as administrator Use cd\ to come out of the set directory or
path.
Run pip install command. pip install NumPy pip install pandas pip install picklemixin pip
install Requests
The above image shows the command prompt to install the libraries required to set up the
Anaconda IDE and also to perform the experiment to get the accurate output
2. RAM – 256 MB
5. Monitor- SVGA
One of the most frequently touted measures of processor is given chip's speed in
gigahertz. Processors with higher GHz ratings can, theoretically, do more in a given unit of
time than processors with lower GHz ratings. However, the processor's speed rating is just
one of many factors that impact how fast it actually processes data. Given that some
specialized applications can be very computationally demanding, choosing the fastest
computer is more important than buying a machine with the highest clock speed.
System Clocks
Processors work according to a clock that beats a set number of times per second,
usually measured in gigahertz. For instance, a 3.1-GHz processor has a clock that beats 3.1
billion times per second , also 1.1 Ghz processor has a clock that beats 1.1 billion times per
second. Each clock beat represents an opportunity for the processor to manipulate a number
of bits equivalent to its capacity - 64-bit processors can work on 64 bits at a time, while 32-bit
processors work on 32 bits at a time.
The amount of RAM needed all depends on what the user is doing. When video editing, for
example, it's recommended that a system have at least 16 GB RAM, though more is desirable.
For photo editing using Photoshop, Adobe recommends a system have at least 3GB of RAM
to
15
run Photoshop CC on a Mac. However, if the user is working with other applications at the
same time, even 8GB of RAM can slow things down.
A keyboard is one of the primary input devices that allows users to input text into a
computer or any other electronic machinery. It is a peripheral device that is the most basic
way for the user to communicate with a computer. It consists of multiple buttons, which
create numbers, symbols, and letters, and special keys like the Windows and Alt key,
including performing other functions. The design of the keyboard comes from the typewriter
keyboards, and numbers and letters are arranged on the keyboard in that way, which helps to
type quickly.
The above keyboard design is called Qwerty design because of its first six letters
across in the upper-left-hand corner of the keyboard. Although the keyboard design is derived
from the typewrites, nowadays, it also includes many other keys as well as Alt/Option,
Control, and Windows key can be used as shortcuts to perform the particular operation by
combination with other keys. For example, if you press Control + S while working on a
document in Microsoft word, it will save the document you are working on. Furthermore,
most of the keyboards have function keys (F1 to F12 or F16) at the top of the keyboard and
arranged arrow keys in the downside used to perform numerous functions.
A mouse is a small device that a computer user pushes across a desk surface in order
to point to a place on a display screen and to select one or more actions to take from that
position. The mouse first became a widely-used computer tool when Apple Computer made it
a standard part of the Apple Macintosh. Today, the mouse is an integral part of the graphical
16
user interface GUI of any personal computer. The mouse apparently got its name by being
about the same size and colour as a toy mouse.
Figure.3.3.4 Mouse
A mouse consists of a metal or plastic housing or casing, a ball that sticks out of the
bottom of the casing and is rolled on a flat surface, one or more buttons on the top of the
casing, and a cable that connects the mouse to the computer. As the ball is moved over the
surface in any direction, a sensor sends impulses to the computer that causes a mouse-
responsive program to reposition a visible indicator (called a cursor) on the display screen.
The positioning is relative to some variable starting place. Viewing the cursor's present
position, the user readjusts the position by moving the mouse.
Originally, it was just an extension to the VGA standard, which was a purely IBM
defined standard also known as ultra video graphics array (UVGA).
17
CHAPTER 4
DESIGN AND IMPLEMENTATION
4.1 DESIGN PROCESS
This chapter will explain the general methodologies and list down technologies used
in the methodologies step.
This project follows standard machine learning pipeline process.
Data Collection
Before started to collect the dataset, we need to define the data that we need to collect.
Therefore, a short interview is conducted with Mr Seong, a certified workout trainer that currently
works in FEEX Fitness Ideal Sdn Bhd. A lot of data has been gathered during the interview
included examples of incorrect posture performed by trainee. A list of common improper postures
was listed down and will be recognised and evaluated by the trained model. Mr Seong also
demonstrated the improper and proper postures to make sure the dataset contains correct proper
and improper posture workout video.
After I defined the list of class, I need to collect dataset in order to train tthe model, therefore
several workout videos are recorded and will be used in Model Training stage. The system
requires trainees to upload their exercise videos with any common format such as MP4,
MOA, AVI and etc. A total workout dataset is recorded in MP4 format with 2.19GB that
consists of three different workouts (Figure 3.2). There are total 845 repetitions with 265
repetitions in Bicep Curl class, 280 in Front Raise class and 300 repetitions in Shoulder Press
class.
There are totally seven classes including six improper postures and one proper posture in
Bicep Curl class, six classes including five improper postures and one proper posture in Front
raise class and six classes including five improper postures and one proper posture in
Shoulder Press class.
18
Figure 4.1.2:Fitness video process
Data Preparation
After the collection of dataset, I have performed some operations in Data Preparation Stage
(Figure 4.1.3).
First, I realised OpenCV is having problem in orienting video in correct angle. Some
videos that captured in portrait by phone will view as landscape in OpenCV (Figure 3.4).
19
Figure 4.1.4: Showing in Landscape Instead of Portrait
Open Pose has a flaw which it does not work well in disoriented frame. As shown in
Figure 4.1.4, OpenPose was unable to locate correct keypoints and identifying correct
keypoints is the important step for workout recognition.
To solve this challenge, the system must read the metadata that name rotation, this
metadata tells the video player to rotate the video for how many angles. Therefore, moviepy
is deployed to read the value of rotation metadata is rotate the video according to the value
(Figure 4.1.5).
20
Open Pose model will apply on these videos to identify the joint keypoints. A total of
eighteen keypoints will be identified in every video if a human object is detected (Figure
3.7). To be specific, the output of OpenPose model is a list of geometric position of 18
human keypoints and these geometric positions are still considered as raw data that do not
provide a lot of useful information for Model Training stage.
The next problem will be standardising the video perspective. For example, Figure
3.8 is showing two different perspectives even both users are facing same side to the camera.
4.2 IMPLEMENTATION
Conda is an open-source package and environment management system that runs
on Windows, macOS, and Linux. Conda quickly installs, runs, and updates packages and
their dependencies. It also easily creates, saves, loads, and switches between environments
on your local computer. It was created for Python programs, but it can package and distribute
software for any language.
Step 1 :
Click and Start All Programs Anaconda Command Prompt. A command
prompt window will open. Type idle to run the Python interpreter. A new window
titled Python Shell will open and you will see the Python >>> command prompt.
Step 2:
After running the command prompt of anaconda we will be able to get python IDLE
shell and now open the app file which is in the PC containing python program of GUI fitness
trainer.
21
Figure.4.2.2: command prompt
shell
Step 3:
Run the program and we will be able to get the output such as GUI containing the
commands or the exercises what we required to do and the output will be displayed as
followed by next step.
Step 4:
Media Pipe is an open-source framework for building pipelines to perform computer vision
inference over arbitrary sensory data such as video or audio. Using MediaPipe, such a
perception pipeline can be built as a graph of modular components. In computer vision
22
pipelines, those components include model inference, media processing algorithms, data
transformations, etc. Sensory data such as video streams enter the graph, and perceived
descriptions such as object-localization or face-keypoint streams exit the graph.
Tkinter is the standard GUI library for Python. Python when combined with Tkinter
provides a fast and easy way to create GUI applications. Tkinter provides a powerful object-
oriented interface to the Tk GUI toolkit and with the help of Tkinter a GUI will be displayed
where we can see a person is doing a particular exercise on the screen.
23
CHAPTER-5
ADVANTAGES, LIMITATIONS AND APPLICATIONS
5.1 ADVANTAGES:
Individuals of all fitness levels and abilities can create fitness objectives that are
tailored to their individual goals based on the devices they are using. In order for artificial
intelligence to provide meaningful insights, several characteristics will often need to be taken
into consideration, such as height, age and weight.
Artificial Intelligence-based diet planning ;
In many cases, diet and meal planning can be made more effective by utilising fitness
applications powered by artificial intelligence. When you're trying to achieve a certain
weight loss or fitness goal, you're likely to be able to benefit from a tool like this.
With the right food, you can achieve pretty much any realistic fitness dream. In fact,
nutrition has been shown to be more important than exercise when it comes to our health.
Thus, many of the best AI-based home training programs provide users with individualised
diet plans.
There are also different diet plans you can choose from, whether it's a vegetarian or rich
in protein, allowing you to further fine-tune the application to your needs.
General benefits of using AI in your fitness routine
Overall, there are several ways that individuals are likely to see their fitness routine improve
thanks to the use of smart technology. For one, it's often far more accessible than a personal
trainer, which simply makes it easier to get the information you need without having to rely
on another human being or keep up with the sometimes extortionate payments.
5.2 LIMITATIONS
5.3 APPLICATIONS
25
CHAPTER-6
RESULT ANALYSIS
The use of AI in personal training has become increasingly popular, allowing for
customizable and tailored workouts that can be tailored to the individual. However, it is
important to acknowledge the potential drawbacks that come with this technology. AI
technology can also customize fitness plans according to individual goals, providing detailed
insights down to a granular level which was previously not possible taking into account the
user’s medical history, biological makeup, lifestyle, and even environmental factors.
Step-1:Giving Input:
Here we are able to see the window of exercises also we need to select the exercise.
And the another window will be displayed to record the exercise.
26
Figure.6.2:AI Fitness trainer using Mediapipe
The final stage displays the output that shows to count the exercise and the exercise is
displayed with the node points of human on a monitor.
SIT UP:
WALK:
27
PULL UP:
SQUAT:
28
FUTURE SCOPE
AI revolutionizes fitness through fitness equipment that makes home workouts
smarter and better. In addition to the smart wearable (Apple Watch, Fitbit, and more)
which may help you track your fitness, personal AI trainers are also gaining in popularity
at an unparalleled rate.
Those who use AI personal trainers would know this new notion in the field of fitness,
but those who are amateur must be intrigued about it.
29
CONCLUSION
As a conclusion, the workout recognition and evaluation system had been successful
developed to achieve the project objectives. The system with the function of detect and
recognize the workout type from the input video had been tested with multiple workout type
under different environments and achieved around 98% accuracy. On the other hand, the
system is also able to classify different types of improper posture with the accuracy of
80.69% for Bicep Curl class, 65.35% for Front
Raise class and 89.75% for Shoulder Press class.
The problem of this project is the OpenPose model may tend to miss out some of the
joint keypoints. This may due to some factors such as complex background or dark
environment. It is essential to get the video which has better resolution or quality for the
detection and recognition. The another problem caused by OpenPose model is the time taken
for it to retrieve the keypoints location. Perhaps in future there are other alternative ways to
retrieve body keypoints location in shorter time, maybe within one second for one frame. The
problem restraints me for deploying the model in real-life scenario. There is actually another
interesting problem which is the complexity of human body movement. It is impossible to
list out every possible posture that made by human. Therefore, the improper postures that
predicted in this project are actually just the few most common postures.
There are actually few novelties and contributions from this project. The first one will
be creating new benchmark for this workout dataset. The reason I create my own workout
dataset is because I couldn’t find any public workout dataset. Therefore, I have uploaded the
workout dataset to Kaggle so that other people can access to my dataset for free and all the
annotations have been made. My approach that shown in this project can be a benchmark
approach for this dataset. Hopefully by making this dataset public to CV community can
raise the attention to the evaluation of quality in performing an activity field.
30
BIBLIOGRAPHY
Barbara, M 2014, Are you too Embarrassed to Exercise? Available from:
<https://www.psychologytoday.com/intl/blog/shyness-is-nice/201401/areyou-
tooembarrassed-exercise>. [05 August 2019].
Bonaros, B 2019, K-Means Elbow Method Code For Python Available from:
<https://predictivehacks.com/k-means-elbow-method-code-for-python/>. [22
April 2020].
Chen, S & Yang, R 2018, Pose Trainer: Correcting Exercise Posture using Pose Estimation.
Department of Computer Science Stanford University, California:
Stanford.
Imran, V, 2015, How to Choose the Value of K in KNN Algorithm. Available from:
<https://discuss.analyticsvidhya.com/t/how-to-choose-the-value-of-k-inknnalgorithm/2606>.
[22 April 2020].
Jason, B 2019, A Gentle Introduction to Object Recognition With Deep Learning. <Available
from: https://machinelearningmastery.com/object-recognitionwith-deeplearning/>. [28 July
2019].
Kim, D, Cho, M, Park, Y, & Yang, Y 2015. Effect of an exercise program for posture
correction on musculoskeletal pain. Journal of physical therapy science, vol.
27, no. 6, pp. 1791–1794. doi:10.1589/jpts.27.1791
Novatchkov, H & Baca, A 2012, Machine Learning Methods For The Automatic
th
Evaluation Of Exercises On Sensor-Equipped Weight Training Machines. 9
Conference of the International Sports Engineering Association, vol. 34, pp.
562–567.
31
Qian, H, Mao, Y, Xiang, W & Wang, Z 2010, Recognition of Human Activities Using
SVM Multiclass Classifier. Pattern Recognition Letters, vol. 31, no. 2, pp.
100-111.
Timo, R, 2018, Python Vs. C++ for Machine Learning – Language Comparison. Available
from: <https://www.netguru.com/blog/python-vs.-c-for-machinelearninglanguage-
comparison>. [12 August 2018].
32
GLOSSARY
AI
Artificial intelligence Graphical- user interface Machine learning
MLwrapping
time -
GPU - Toolkit
TK - Operating system
SSD -
IDLE -
ANN -
33
APPENDIX
GUI FITNESS TRAINER.py
import sys
import os
from tkinter
import *
window=Tk()
window.title("AI FITNESS
TRAINER")
window.geometry('320x320')
def walkai():
os.system('python main.py -t
walk')
def squatai():
os.system('python main.py -t
squat')
def pushupai():
os.system('python main.py -t
push-up')
def pullupai():
os.system('python main.py -t
pull-up')
34
def situpai():
os.system('python main.py -t
sit-up')
window.mainloop()
main.py
import cv2
import argparse
from utils
import * import
mediapipe as
mp
from body_part_angle import BodyPartAngle
35
from types_of_exercise import TypeOfExercise
ap =
argparse.ArgumentParser()
ap.add_argument("-t",
"--exercise_type",
type=str,
help='Type of activity to
do', required=True)
ap.add_argument("-vs",
"--video_source",
type=str, help='Type
of activity to do',
required=False)
args = vars(ap.parse_args())
args = vars(ap.parse_args())
mp_drawing = mp.solutions.drawing_utils
mp_pose = mp.solutions.pose
counter = 0 # movement of
exercise status = True #
state of move while
cap.isOpened(): ret,
frame = cap.read()
# result_screen = np.zeros((250, 400, 3), np.uint8)
36
# recolor frame to RGB
37
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame.flags.writeable = False
# make detection
results =
pose.process(frame) #
recolor back to BGR
frame.flags.writeable = True frame =
cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
t
r
y
:
landmarks = results.pose_landmarks.landmark
counter, status =
TypeOfExercise(landmarks).calculate_exercise( args["exercise
_type"], counter, status) except: pass
cv2.imshow('Video', frame)
if cv2.waitKey(10) & 0xFF ==
ord('q'): break
cap.release()
cv2.destroyAllWindows()
38
39