flutter_mediapipe 0.0.3 flutter_mediapipe: ^0.0.3 copied to clipboard
A new flutter plugin project.
flutter_mediapipe #
Flutter plugin with mediapipe facemesh.
Devices #
Currently, it runs on below devices with "OK".
Android #
There are Mediapipe Manual Build for Android flutter plugin.
There are mobile_calculators list to run on Mobile.
Choose one. This plugin choose face_mesh.
- face_detection
- face_mesh
- object_detection
- hand_tracking
Docker #
git clone https://github.com/google/mediapipe.git
cd mediapipe
docker build --tag=mediapipe .
docker run -it --name mediapipe mediapipe:latest
When enter docker again:
docker start [your container ID]
docker exec -i -t mediapipe bash
Run below commands on the container.
Setup #
apt update
apt install vim
apt install zip
bash ./setup_android_sdk_and_ndk.sh
Prepare #
mkdir mediapipe/examples/android/src/java/com/google/mediapipe/apps/flutter_mediapipe
vi mediapipe/examples/android/src/java/com/google/mediapipe/apps/flutter_mediapipe/BUILD
- "BUILD" file content.
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
mediapipe_aar(
name = "flutter_mediapipe",
calculators = ["//mediapipe/graphs/face_mesh:mobile_calculators"],
)
Build #
- Java Library
bazel build -c opt --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --fat_apk_cpu=arm64-v8a,armeabi-v7a --strip=ALWAYS //mediapipe/examples/android/src/java/com/google/mediapipe/apps/flutter_mediapipe:BUILD --linkopt="-s"
bazel build -c opt --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --fat_apk_cpu=arm64-v8a,armeabi-v7a //mediapipe/examples/android/src/java/com/google/mediapipe/apps/flutter_mediapipe:flutter_mediapipe --linkopt="-s"
- binary graph
bazel build -c opt --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --fat_apk_cpu=arm64-v8a,armeabi-v7a --strip=ALWAYS //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facemeshgpu:BUILD
bazel build -c opt --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --fat_apk_cpu=arm64-v8a,armeabi-v7a //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facemeshgpu:facemeshgpu
mkdir #
mkdir flutter_mediapipe/
mkdir flutter_mediapipe/android
mkdir flutter_mediapipe/android/libs
mkdir flutter_mediapipe/android/src
mkdir flutter_mediapipe/android/src/main
mkdir flutter_mediapipe/android/src/main/assets
mkdir flutter_mediapipe/android/src/main/jniLibs
mkdir flutter_mediapipe/protos
libs #
cp bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/flutter_mediapipe/libflutter_mediapipe_android_lib.jar flutter_mediapipe/android/libs
assets #
cp mediapipe/modules/face_detection/face_detection_front.tflite flutter_mediapipe/android/src/main/assets
cp mediapipe/modules/face_landmark/face_landmark.tflite flutter_mediapipe/android/src/main/assets
cp bazel-out/k8-opt/bin/mediapipe/graphs/face_mesh/face_mesh_mobile_gpu.binarypb flutter_mediapipe/android/src/main/assets
jniLibs #
mkdir work
cp bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/flutter_mediapipe/flutter_mediapipe.aar work/aar.zip
cd work/
unzip aar.zip
cd ..
cp -r work/jni/* flutter_mediapipe/android/src/main/jniLibs/
protos #
cp mediapipe/framework/formats/landmark.proto flutter_mediapipe/protos/
See regenerate.md
Zip #
zip -r flutter_mediapipe.zip flutter_mediapipe
And then, exit from the container.
Copy #
Change "3730fdc4d319" to your container ID.
docker cp 3730fdc4d319:/mediapipe/flutter_mediapipe.zip .
unzip flutter_mediapipe.zip
Then copy "flutter_mediapipe" to flutter plugin projects.
APK #
flutter build apk --split-per-abi
Refferences #
- sample plugin is useful.
- sample android app without flutter
- Flutter don't support local AAR
- jniLibs size down
iOS #
Not implemented. Help me to develop.