-
Clone the repository, remember to initialize the submodules.
git submodule update --init --recursive [--depth=1] -
Install Bazelisk or Bazel version that meets MediaPipe requirement.
-
Run
setup.pyto generate the godot-cpp bindings as well as apply/setup source code to themediapipeworkspace. Runsetup.py --helpto view the various options.
Example:
./setup.py --godot-binary path/to/godot/binary
- Copy
addonsto your Godot project's root directory. - (Optional) Add calculator dependencies in
GDMP/GDMP.bzlif you have additional calculators to compile into GDMP.
build.py is a wrapper script that invoke Bazel build commands in mediapipe workspace to build GDMP libraries.
Common usage:
./build.py [target] --type [debug/release] --output [output-dir]
Run build.py --help to see all options.
Windows users: Cross-compiling Android library on Windows is currently not supported, please set up WSL or Linux VM before proceed to the instructions below.
-
Install Android NDK, then setting
ANDROID_NDK_HOMEenvironment variable that point to your install location.Refer to MediaPipe docs for more details.
-
Run
build.py androidto build Android native libraries.Use
--archto specify the architecture. For example, run:build.py android --arch arm64-v8ato build library for
arm64-v8aarchitecture.
Linking prebuilt OpenCV: GDMP builds OpenCV from source on Android by default, if you want to use pre-built OpenCV libraries, you will need to:
- Comment out
--define=OPENCV=sourcefrombuild.pyto make Bazel using prebuilt OpenCV rules. - Make sure to add
libopencv_java4.soto the dependencies list of Android targets inaddons/GDMP/GDMP.gdextensionfor your project.
-
Install Xcode, then switch to installed Xcode by using
xcode-select -
Run
build.py iosto build iOS libraryBy default, GDMP build arm64 architecture for iOS device, and both arm64 and x86_64 for iOS simulator. If you would like to customize which platform or architecture to build, modify
iosattribute inGDMP/ios/BUILD.
Flatpak environment: If you intend to distribute the library, you might want to use an environment isolated from host before you proceed. You can use scripts/flatpak_env.sh to enable Flatpak environment.
- Run
build.py desktopto build desktop library.
Linking prebuilt OpenCV: GDMP builds OpenCV from source on Linux by default, if you want to use pre-compiled OpenCV libraries, you will need to:
- Modify
mediapipe/third_party/opencv_linux.BUILDto make OpenCV installed on your host visible to Bazel. - Comment out
--define=OPENCV=sourcefrombuild.pyto make Bazel using binary OpenCV rules.
When linking prebuilt OpenCV libraries, build script will not copy required libraries to output destination, make sure they can be found by dynamic linker.
- Install Xcode, then switch to installed Xcode by using
xcode-select - Run
build.py desktopto build desktop library.
-
Install MSVC compiler and Windows SDK, then setting
BAZEL_VCenvironment variable pointing to your VC installation.Refer to Bazel documentation for more details.
-
Bash is required for building MediaPipe, make sure
bashis inPATHor settingBAZEL_SHenvironment variable pointing to it.Bash can be installed from Git for Windows or MSYS2
Refer to MediaPipe documentation for more details.
-
Run
build.py desktopto build desktop library.
Linking prebuilt OpenCV: GDMP builds OpenCV from source on Windows by default, if you want to use pre-compiled OpenCV libraries, you will need to:
- Modify
mediapipe/WORKSPACEforpathunderwindows_opencvif OpenCV is not installed onC:\opencv - Modify
OPENCV_VERSIONinmediapipe/third_party/opencv_windows.BUILDif OpenCV version is not3.4.10 - Comment out
--define=OPENCV=sourcefrombuild.pyto make Bazel using binary OpenCV rules.