Pose Estimation on the Raspberry Pi 4!

by ethandell in Circuits > Raspberry Pi

1585 Views, 1 Favorites, 0 Comments

Pose Estimation on the Raspberry Pi 4!

pose.gif

The goal of this project was to how well pose estimation could perform on the Raspberry Pi. Google provides code to run pose estimation on Android and IOS devices - but I wanted to write python code to interface with and test the model on the Pi.

Here's a demo if you want to try things in your browser and with JavaScript!

https://storage.googleapis.com/tfjs-models/demos/p...

Additional resources:

Supplies

  • Raspberry Pi 4 GB
  • Raspberry Pi 5MP Camera (rev 1.3)
  • LED
  • 470 Ohm Resistor
  • Small breadboard
  • GPIO push button
  • 3.5 Amp USB-C Power Supply

Clone the Repository and Change Directory

Command: git clone https://github.com/ecd1012/rpi_pose_estimation.gi...

Command: cd rpi_pose_estimation

Open Command Prompt and Make Sure Pi Is Up to Date

Command: sudo apt-get update && sudo apt-get upgrade

Install Virtual Environment

Command: sudo pip3 install virtualenv

Make Virtual Environment

Command: python3.7 -m venv TFLite-venv

Activate Environment

Command: source TFLite-venv/bin/activate

Get Script to Install Dependencies

Download the following: https://github.com/ecd1012/rpi_road_object_detection/blob/main/get_py_requirements.sh

Command: bash get_py_requirements.sh

Enable Pi Camera

Command: sudo raspi-config

Go to interface Options and make sure the Pi Camera is enabled.

Grab the Sample TensorFlow Lite Posenet Model From Google

Command: wget https://storage.googleapis.com/download.tensorflow.org/models/tflite/posenet_mobilenet_v1_100_257x257_multi_kpt_stripped.tflite

Connect Pi Camera Module to Raspberry Pi

Connecting the Camera for This Project: https://youtu.be/Zfmo3bMycUg

Connect a Push Button to GPIO Pin 17

This will be used as input to kick off the program.

Connecting Push Button for this project: https://youtu.be/Zfmo3bMycUg?t=437

Connect an LED to GPIO PIN 4

This LED will turn on to indicate when the program is running. Make sure you use a current limiting resistor with the LED!

LED Connection for This Project: https://youtu.be/Zfmo3bMycUg?t=353

Running Pose Estimation

After all your hardware and software is configured correctly run the following command:

Command: python3 TFLite_pose.py --modeldir notebooks/posenet_mobilenet_v1_100_257x257_multi_kpt_stripped.tflite --output_path pose_images

Where the --output_path you specify is where you want images saved.

The script will start running and wait for you to press the GPIO input button to start processing the video feed from the camera. Once you press the button, the green LED will turn on and the pi will start feeding and processing the video stream through the neural network. Processed images will be saved to the '--output_path' you specified over the command line, with a timestamped folder for each button press.

Test It Out for Yourself and Enjoy :)