Tutorials

Pose Estimation for Real-World Applications

by Matt London |   |  Starter Apps  | 5 min read

Introduction

Pose estimation is a computer vision task that includes detecting, associating, and tracking semantic key points. It utilizes convolutional neural networks (CNNs) for regression prediction. Business use cases for pose estimation include ergonomics, sports analysis, robotics, entertainment, and more. This tutorial will demonstrate a couple of alwaysAI’s applications that utilize pose estimation to assist with posture correction.

alwaysAI CLI Instructions

Posture Corrector App Instructions

The Posture Corrector app will give you text alerts when you are slouching in your seat at your computer. To install the app:​

git clone https://github.com/alwaysai/posture-corrector.git
aai configure
aai app install
aai app start

Angle your webcam similar to the picture below:

LiftPose - alerts to bend knees while lifting The Lift post will give you text alerts when you are not bending your knees enough, while lifting objects. To install the app:

git clone git@github.com:alwaysai/LiftPose.git
aai configure
aai app install

Create an empty directory called “vids”:

mkdir vids

*Note that in line 34 of app.py, the webcam stream will be saved to vids/lifting.mp4. Change the filename to write multiple mp4’s.

aai app start

Face the webcam to the right side of your body while lifting. The app will display text when “bad posture”.​

Bad Posture:

This is an example of bad posture when lifting.

Good Posture:

This is an example of good posture when lifting.

LiftPose – writing stream to .mp4 The app has been configured to write the webcam stream to mp4. This has been accomplished by adding the following to a general webcam streaming app:

under:

pose_estimator.load(
engine=edgeiq.Engine.DNN,
accelerator=edgeiq.Accelerator.CPU)

add:

write_context = edgeiq.VideoWriter(output_path="vids/lifting.mp4")

Then, include at end of line. Try:

with edgeiq.WebcamVideoStream(cam=0) as video_stream, 
edgeiq.Streamer() as streamer, write_context as 
video_writer:

Then, under:

streamer.send_data(results.draw_poses(frame), text)

add:

video_writer.write_frame(frame)

NOTE:

Need to ensure permissions to write folder:

sudo chown -R $USER: /path/to/saved.mp4

If mp4 too fast, make half speed with ffmpeg:

ffmpeg -i /path/to/saved.mp4 -filter:v "setpts=2*PTS" /path/to/slower.mp4

Conclusion

There are many other real-world applications for pose estimation. To learn more, email us at: contact@alwaysai.co

stylized image of a computer chip

Sign up today and start your project

We can't wait to see what you'll build!