This is a guide for running an basic hand tracking example of Mediapepe installed on Windows.
Notices
- This was build on April 2023.
- It is not guaranteed to run successfully on newer mediapipe versions.
- If you encounter some errors reading the official document might be helpful.
- WSL version: Ubuntu 22.04
Steps
- Install Windows Subsystem for Linux (WSL)
- Setting up Android SDK and NDK
- Build a MediaPipe Framework AAR
- Running it on Android Studio (on your Windows PC)
Install Windows Subsystem for Linux (WSL)
Open PowerShell in administrator mode by right-clicking and selecting "Run as administrator", enter the wsl –install command, then restart your machine.
Run wsl –list –online to see a list of available distros.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Run wsl –install -d Ubuntu to install Ubuntu.
Once you have installed, you will need to create a user account and password.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Update apt-get and install some necessary dependencies. This might takes few minutes.
Install adb on WSL and check what version you have installed.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Install adb on Windows
- Download the same adb version to your Windows PC from this.
- Unzip it to get adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll, then copy these 3 files to C:\Windows\System32 and C:\Windows\SysWOW64.
- Open PowerShell and execute adb version to check the adb version is same with WSL(Ubuntu).
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Install Bazel on WSL
Put alias bazel='/usr/local/bazel/3.1.0/lib/bazel/bin/bazel
to /etc/profile at the end.
If you don't know how to use vim, check this.
Install OpenCV and FFmpeg
Run the Hello World! in C++ example
Setting up Android SDK and NDK
Run setup_android_sdk_and_ndk.sh file to download sdk and ndk
Note : It might takes few hours.
Add the path to /etc/profile file at the end
New a handtrackinggpu_aar folder
New the assets and libs folder
Create a BUILD file under handtrackinggpu_aar
Modify the BUILD file
Run the Bazel build command to generate the AAR.
Copy the AAR into app/libs
Note: change the 'username' to your username
Copy the binary graph to assets
Note: change the 'username' to your username
Running it on Android Studio
Create a new project on Android Studio
Note : on Windows not on the WSL
Download jniLibs (whole directory) and copy it to your Android Studio project
Download link
Copy some files to your Android Studio project
- mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu_aar/libs —> /app
- mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu_aar/assets —> /app/src/main
- handedness.txt—> /app/src/main/assets
- All .tflite in assets—> /app/src/main/assets
- AndroidManifest.xml —> /app/src/main
- MainActivity.java —> /app/src/main/java/com/example/myapplication
- style.xml —>/app/src/main/res/values/
- activity_main.xml—>/app/src/main/res/layout/
Modify app/build.gradle
Modify the minSdk to 21
Copy it to the dependencies section
Modify MainActivity.java and AndroidManifest.xml
Change myapplication to your application name


Sync Project with Gradle Files

Connect to your phone and click run

DONE!!!
References
Mediapipe
Github Repo
mediapipe_hand-tracking