Build MediapipeUnityPlugin for Android

2021-05-17

homuler/MediaPipeUnityPlugin: Unity plugin to run MediaPipe graphs

Versions

  • MediapipeUnityPlugin v0.6.0
This is a Unity (2020.3.8f1) Plugin to use MediaPipe (0.8.3.1).
  • WSL2
  • Windows10 Home
  • Ubuntu20.04
  • Python3.9
  • bazel 4.0.0
  • gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
  • NuGet Version: 5.6.0.6489
  • .NET SDK Version: 5.0.203
  • Mono 6.12.0.122
  • Android SDK Build-Tools 29.0.2
  • Android NDK (Side by side) 21.4.7075529


MediaPipeUnityPlugin

homuler/MediaPipeUnityPlugin: Unity plugin to run MediaPipe graphs

git clone https://github.com/homuler/MediaPipeUnityPlugin.git
cd MediaPipeUnityPlugin


OpenCV, FFmpeg

Installation - mediapipe

sudo apt install ffmpeg
sudo apt install libopencv-core-dev libopencv-highgui-dev \
                       libopencv-calib3d-dev libopencv-features2d-dev \
                       libopencv-imgproc-dev libopencv-video-dev

edit WORKSPACE

new_local_repository(
    name = "linux_opencv",
    build_file = "@//third_party:opencv_linux.BUILD",
    path = "/usr/local",
)

new_local_repository(
    name = "linux_ffmpeg",
    build_file = "@//third_party:ffmpeg_linux.BUILD",
    path = "/usr/local",
)


.NET

Install .NET on Ubuntu - .NET | Microsoft Docs

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install -y apt-transport-https
sudo apt update
sudo apt install -y dotnet-sdk-5.0


Mono

Download - Stable | Mono

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo  "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel


Nuget

sudo apt install nuget
nuget update -self


JDK

sudo apt install openjdk-8-jdk


Bazel

Installing Bazel using Bazelisk - Bazel

npm install -g @bazel/bazelisk


Python3.9

sudo apt install -y python3.9
python3.9 -m pip install numpy


Android SDK, NDK

Download Command line tools from Download Android Studio and SDK tools | Android Developers / Command line tools only

cd cmdline-tools
bin/sdkmanager --list --sdk_root=latest
sudo bin/sdkmanager "build-tools;29.0.2" --sdk_root=latest
sudo bin/sdkmanager "ndk;21.4.7075529" --sdk_root=latest
export ANDROID_HOME=/PATH-TO-CMDLINETOOLS/cmdline-tools/latest
export ANDROID_NDK_HOME=/PATH-TO-CMDLINETOOLS/cmdline-tools/latest/ndk/21.4.7075529


Build

cd MediaPipeUnityPlugin
python3.9 build.py build --android arm64 -v



Done!