Week 1: Setting Up MediaPipe on My Mac
March 1, 2024
Welcome back to my senior project blog! This week, I’m excited to dive into how I’ve set up the MediaPipe framework on macOS for my app. Developed by Google, MediaPipe stands out for several reasons that align with the goals of my project. It is optimized for real-time performance, which is compatible with my app’s goal as it must give real-time feedback on repetitions as a personal trainer would. Moreover, this framework’s pre-built models coupled with its flexible architecture allowing customization make MediaPipe an ideal choice as this trait is beneficial to refining the model to enhance accuracy for specific exercises. Lastly, MediaPipe has a growing community of developers keeping it up-to-date, ensuring its accuracy.
To effectively run MediaPipe, I first had to set up the environment. Homebrew was key for this as it enables efficient dependency management, simplifying installation, updates, and removal of my project’s dependencies.
Step 1: Homebrew and Xcode
The first step was installing Homebrew, the package manager that would make it considerably easier to manage software installations on macOS. With a simple command in the Terminal:
(/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”)
Homebrew was ready for use.
I proceeded to download Xcode, Apple’s IDE with high compatibility for macOS, with the command:
xcode-select –install
Step 2: Installing Dependencies
With Homebrew installed, it was time to address the dependencies critical for running MediaPipe: TensorFlow and OpenCV. TensorFlow is a cornerstone for many machine learning applications, including the pose detection technology I plan to utilize, while OpenCV will enable me to process the video inputs.
For TensorFlow: brew install tensorflow
For OpenCV: brew install opencv
Step 3: Running with Bazel
The final step in the setup process involved using Bazel, a build tool required by MediaPipe for compiling its applications. Bazel ensures that dependencies are correctly managed and that builds are reproducible, a crucial aspect of developing a reliable app. Install Bazel:
brew install bazel
Ensure Python >= 3 is installed, if not you can install with:
brew install python
sudo ln -s -f /usr/local/bin/python3.7 /usr/local/bin/python
Install the python ‘six’ library with:
pip3 install –user six
Test Mediapipe by running this command with bazel:
bazel run –define MEDIAPIPE_DISABLE_GPU=1 \
mediapipe/examples/desktop/hello_world:hello_world
This should print out:
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
Hello World!
I will link some MediaPipe resources below:
Official repository:
https://github.com/google/mediapipe
Troubleshooting:
https://developers.google.com/mediapipe/framework/getting_started/troubleshooting.md
Reflections and Next Steps
Setting up the environment can take time, especially as troubleshooting can be unique on a case-by-case basis. If you run into errors when executing the test, ensure your directory is set up correctly by viewing the contents with ‘ls’ or going into File Explorer/Finder. Try and check the troubleshooting site linked above as well to see if you can find a solution there. With MediaPipe now running on my Mac, the next stage is to dive into experimenting and tailoring the model to fit the needs of our virtual personal trainer app. I will need to find a large quantity of data to train for each exercise, so I plan to start to get the squat working first, as this is a fundamental exercise that requires both full-body and depth recognition from my model.
Thank you for reading! Hope to see you next week for my week 2 blog.
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.
unknown says
Hey, you forgot a – before define