yoga guru
yoga guru is your personalized yoga trainer app based on flutter. it uses posenet, a pre-trained deep learning model, to estimate body poses in real time and predict yoga asanas.
getting started
step 1: download the project repository
open terminal and type
adityaas26/yoga-guru.git
step 2: run the app
connect your device or start the emulator and run the following code
# change directories
cd yoga-guru
# run the app
flutter run
project structure
the project structure is quite primitive right now.
let’s look at the lib folder
don’t worry, we’ll take a brief look at all the files in a minute! let’s start with main.dart
1. main.dart
main.dart loads data from shared preferences and the camera module. it also defines routes for home, login and register pages. if the user is already logged in, it sets the initial route to home.dart else login.dart.
2. login.dart
login.dart defines a login class, which is a stateful widget. it contains the textfields required to login into the app. the login button calls the _login() method which routes to home.dart. also contains a button to send the user to register.dart.
3. register.dart
register.dart defines a register class, which is a stateful widget. it contains the textfields required to login into the app. the login button calls the _register() method which routes to home.dart. also contains a button to send the user to login.dart.
4. home.dart
home.dart defines a home class, which is a stateless widget. it contains buttons which routes the user to poses.dart according to the button they press. each button (beginner, intermediate, advance) call a method _onposeselect().
this _onposeselect() method is quite important as the arguments given to this function decides which list of poses needs to be shown on the poses page.
5. poses.dart
poses.dart defines a poses class, which is a stateless widget. it shows a list of available poses as swipable cards. the code of the custom cards can be found in yoga_card.dart file. each card is clickable and calls the _onselect() method which directs the user to the inferencepage (inference.dart).
6. inference.dart
inference.dart defines a inferencepage class, which is a stateful widget. it is the class which loads the posenet model. it initializes the camera object with the camera instance and _setrecognitions() callback function. the _setrecognitions() method is responsibe for saving the predicted output of the posenet model into a list (_recognitions). this list of predicted values (_recognitions) is then passed to bndbox’s constructor.
you can read more about the implementation here.
7. camera.dart
camera.dart defines a camera class, which is a stateful widget. it contains code related to camera initialization and calls tflite.runposenetonframe() method by passing in the current cameraimage as an argument. the output (predictions) of this method is given as an argument to the _setrecognitions() method, which was passed to camera() as callback.
8. bndbox.dart
bndbox.dart defines a bndbox class, which is a stateless widget. it takes the list of predictions (_recognitions) and plot keypoints on the screen. it also prints the accuracy of the model in %.
9. profile.dart
profile.dart defines a profile class, which is a stateful widget. it contains the code for viewing and updating the user’s profile data.
Comments are closed.