Python jupyter notebook examples using several Mediapipe solutions with opencv for live webcam detection.
Table of Contents
The Mediapipe documentation has several examples for still image detection with python, but the live stream python examples were not fully implemented. This repo contains a few implementations that demonstrate live stream functionality of the following solutions / APIs:
Since much of the example documentation in the Medipipe docs didn't include full implemntation examples, these represent the results of my exploration.
To get a local copy up and running follow these simple example steps.
An install of Python 3.9, either from python.org, conda, or your preferred method.
- If you want to run the gesture recognizer you will need a pre-trained model.
- If you want to run the object detector you will need a pre-trained model.
Below is an example of how you can instruct your audience on installing and setting up your app. This template doesn't rely on any external dependencies or services.
- Clone the repo
cd /folder/where/you/want/the/copy
git clone https://github.com/rdarneal/mediapipe_python_examples.git
- Install packages, either via python or conda:
- python
python -m pip install requirements.txt
- conda
conda env create -n myenv -f environment.yml
- Add the pre-trained models to your project folder :
- Gesture Recognition model
wget https://storage.googleapis.com/mediapipe-tasks/gesture_recognizer/gesture_recognizer.task
- Object detector model (other options are available here)
wget -O efficientdet.tflite https://storage.googleapis.com/mediapipe-tasks/object_detector/efficientdet_lite0_uint8.tflite
- Open the file in VSCode, Jupyter, or your favorite IDE:
# VSCode example
code .
- Run the jupyter notesbook. Refer to information and instructions in the cells.
After following the installation instructions, you can open the ipynb
files and run all cells to start up a live-stream webcam detection.
face_mesh_live
: Mediapipe face mesh API example notebookgesture_recognition
: Mediapipe gesture recognition live stream example notebookholistic_model
: Mediapipe holistic model live stream example notebookobject_detection
: Mediapipe livestream object detection example notebook
For more examples, or for working with still images or pre-recorded video, check out Mediapipe's Documentation
Robert Darneal- @rdarneal
Project Link: https://github.com/rdarneal/mediapipe_python_examples