A new MediaPipe build target has been added under /mediapipe/examples/desktop/libmp
. Using Bazel, you can build this target to create a shared library (.so
on Linux, .dll
on Windows), which you can then integrate - along with its .h
header file - into any C++ application you wish.
Compilation has been tested on Windows (VS 2022 17.6.16, MSVC 19.36.32546) and Ubuntu 20.04 (GCC 9.4.0).
Enormous thanks to @asprecic for sharing libexample
, which made LibMP possible!
- Bazel
- OpenCV
- Download pre-compiled binaries:
sudo apt-get install libopencv-core-dev libopencv-imgproc-dev libopencv-imgcodecs-dev
- Alternatively, build from source
- Download pre-compiled binaries:
- By default, this repository's Bazel build files expect OpenCV to be version 4 and installed using the
apt
package manager (i.e., at/usr
). To match build settings to your own OpenCV version and path, modify the following Bazel files:/third_party/opencv_linux.BUILD
(search for "OPENCV_VERSION")/WORKSPACE
(search for "linux_opencv")
- NOTE: If using Visual Studio, please use VS 2022 17.6 or above. There is a bug in VS 2022 17.4 and 17.5 that causes MediaPipe to fail to link/compile. See #1 for more details.
- Bazel
- OpenCV
- Download pre-compiled binaries
- Visit https://sourceforge.net/projects/opencvlibrary/files
- Click on folder of desired OpenCV version (e.g., 4.6.0)
- Download and run the installer
.exe
(e.g.,opencv-4.6.0-vc14_vc15.exe
)
- Alternatively, build from source
- Download pre-compiled binaries
- By default, this repository's Bazel build files expect OpenCV to be version
4.6.0
and installed atC:\opencv
. To match build settings to your own OpenCV version and path, modify the following Bazel files:/third_party/opencv_windows.BUILD
(search for "OPENCV_VERSION")/WORKSPACE
(search for "windows_opencv")
git clone
this repository andcd
into it- Run
bazel build -c opt --define MEDIAPIPE_DISABLE_GPU=1 mediapipe/examples/desktop/libmp:libmp.so
git clone
this repository andcd
into it- Run
build_libmp_win.sh
(Bash) orbuild_libmp_win.bat
(CMD, Powershell)- Edit the Bazel-related environmental variables defined by the script(s) as necessary
- Bazel requires a Python executable with access to NumPy
- E.g., create a new conda environment, run
conda install numpy
, then point Bazel to the environment's Python executable
- E.g., create a new conda environment, run
- The header file that goes with libmp can be found at
/mediapipe/examples/desktop/libmp/libmp.h
- The library files can be found under
/bazel-bin/mediapipe/examples/desktop/libmp
as follows:- On Linux:
- Use the
libmp.so
shared library in your project
- Use the
- On Windows:
- Copy
libmp.dll
to your binary's output location (or otherwise ensure that it is in your PATH) - Use the
libmp.dll.if.lib
import library in your project - Also copy
opencv_world###.dll
to your binary's output location (or otherwise ensure it is in your PATH)
- Copy
- On Linux:
- In your binary's output location, create a
mediapipe
directory. Copy themodules
andmodels
folders from/bazel-bin/mediapipe
into this new directory. (Be sure to copy from/bazel-bin/mediapipe
, NOT/mediapipe
, as the latter contains empty source directories.)
- Unused OpenCV libraries are disabled in
/third_party/opencv_linux.BUILD
. If you need them, you can re-enable them to get them linked in the final binary too. - One recent breaking change to MediaPipe is that models (e.g.,
.tflite
files) are no longer included in the repository itself. They are instead hosted on Google Cloud Storage (GCS). If your code is not working for some reason, you can manually clone an older version ofgoogle/mediapipe
and copy the source/mediapipe/models
and/mediapipe/modules
folders over to your binary's location. See cc6a2f7 for the last versions of these folders before deletion. - Bazel version 7.0.0 removes
apple_common.multi_arch_split
, resulting in the error'apple_common' value has no field or method 'multi_arch_split'
. Using Bazel version 6 fixes the issue. - An error related to
local_execution_config_python
may be encountered when building on Windows in CMD usingbuild_libmp_win.bat
. This has been fixed by addingBAZEL_SH
to the environmental variables and pointing it to MSYS2'sbash.exe
.
Questions, suggestions, issues, pull requests, etc. are all welcome!
layout | title | nav_order |
---|---|---|
default | home | 1 |
Attention: Thanks for your interest in MediaPipe! We have moved to https://developers.google.com/mediapipe as the primary developer documentation site for MediaPipe as of April 3, 2023.
This notice and web page will be removed on June 1, 2023.
MediaPipe offers cross-platform, customizable ML solutions for live and streaming media.
Face Detection | Face Mesh | Iris | Hands | Pose | Holistic |
---|---|---|---|---|---|
Hair Segmentation | Object Detection | Box Tracking | Instant Motion Tracking | Objectron | KNIFT |
---|---|---|---|---|---|
Android | iOS | C++ | Python | JS | Coral | |
---|---|---|---|---|---|---|
Face Detection | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Face Mesh | ✅ | ✅ | ✅ | ✅ | ✅ | |
Iris | ✅ | ✅ | ✅ | |||
Hands | ✅ | ✅ | ✅ | ✅ | ✅ | |
Pose | ✅ | ✅ | ✅ | ✅ | ✅ | |
Holistic | ✅ | ✅ | ✅ | ✅ | ✅ | |
Selfie Segmentation | ✅ | ✅ | ✅ | ✅ | ✅ | |
Hair Segmentation | ✅ | ✅ | ||||
Object Detection | ✅ | ✅ | ✅ | ✅ | ||
Box Tracking | ✅ | ✅ | ✅ | |||
Instant Motion Tracking | ✅ | |||||
Objectron | ✅ | ✅ | ✅ | ✅ | ||
KNIFT | ✅ | |||||
AutoFlip | ✅ | |||||
MediaSequence | ✅ | |||||
YouTube 8M | ✅ |
See also MediaPipe Models and Model Cards for ML models released in MediaPipe.
To start using MediaPipe solutions with only a few lines code, see example code and demos in MediaPipe in Python and MediaPipe in JavaScript.
To use MediaPipe in C++, Android and iOS, which allow further customization of the solutions as well as building your own, learn how to install MediaPipe and start building example applications in C++, Android and iOS.
The source code is hosted in the MediaPipe Github repository, and you can run code search using Google Open Source Code Search.
- Bringing artworks to life with AR in Google Developers Blog
- Prosthesis control via Mirru App using MediaPipe hand tracking in Google Developers Blog
- SignAll SDK: Sign language interface using MediaPipe is now available for developers in Google Developers Blog
- MediaPipe Holistic - Simultaneous Face, Hand and Pose Prediction, on Device in Google AI Blog
- Background Features in Google Meet, Powered by Web ML in Google AI Blog
- MediaPipe 3D Face Transform in Google Developers Blog
- Instant Motion Tracking With MediaPipe in Google Developers Blog
- BlazePose - On-device Real-time Body Pose Tracking in Google AI Blog
- MediaPipe Iris: Real-time Eye Tracking and Depth Estimation in Google AI Blog
- MediaPipe KNIFT: Template-based feature matching in Google Developers Blog
- Alfred Camera: Smart camera features using MediaPipe in Google Developers Blog
- Real-Time 3D Object Detection on Mobile Devices with MediaPipe in Google AI Blog
- AutoFlip: An Open Source Framework for Intelligent Video Reframing in Google AI Blog
- MediaPipe on the Web in Google Developers Blog
- Object Detection and Tracking using MediaPipe in Google Developers Blog
- On-Device, Real-Time Hand Tracking with MediaPipe in Google AI Blog
- MediaPipe: A Framework for Building Perception Pipelines
- MediaPipe Seattle Meetup, Google Building Waterside, 13 Feb 2020
- AI Nextcon 2020, 12-16 Feb 2020, Seattle
- MediaPipe Madrid Meetup, 16 Dec 2019
- MediaPipe London Meetup, Google 123 Building, 12 Dec 2019
- ML Conference, Berlin, 11 Dec 2019
- MediaPipe Berlin Meetup, Google Berlin, 11 Dec 2019
- The 3rd Workshop on YouTube-8M Large Scale Video Understanding Workshop, Seoul, Korea ICCV 2019
- AI DevWorld 2019, 10 Oct 2019, San Jose, CA
- Google Industry Workshop at ICIP 2019, 24 Sept 2019, Taipei, Taiwan (presentation)
- Open sourced at CVPR 2019, 17~20 June, Long Beach, CA
- Awesome MediaPipe - A curated list of awesome MediaPipe related frameworks, libraries and software
- Slack community for MediaPipe users
- Discuss - General community discussion around MediaPipe
MediaPipe is currently in alpha at v0.7. We may be still making breaking API changes and expect to get to stable APIs by v1.0.
We welcome contributions. Please follow these guidelines.
We use GitHub issues for tracking requests and bugs. Please post questions to
the MediaPipe Stack Overflow with a mediapipe
tag.