2

I am trying to use mediapipe holistic in flutter android. I tried to follow the documentation but am still quite unsure how to write a BUILD file to build aar. I’ve also read through the documentation but unfortunately the example code provided leads to an non-existing page.

This is what I did:

  1. Wrote a BUILD file. (The calculator is from https://github.com/google/mediapipe/blob/master/mediapipe/graphs/holistic_tracking/BUILD )
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")

mediapipe_aar(
    name = "mp_holistic_tracking",
    calculators = ["//mediapipe/graphs/holistic_tracking:holistic_tracking_gpu_deps"],
)
  1. Then building aar:
bazel build -c opt --strip=ALWAYS     --host_crosstool_top=@bazel_tools//tools/cpp:toolchain     --fat_apk_cpu=arm64-v8a,armeabi-v7a     mp_holistic_tracking.aar
  1. After this, I pasted the jar file and all the assets into my project.
  2. The graph (I’ve converted it to binary file)
  3. The error:
E/native  (29489): E20220314 11:02:15.805526 29544 graph.cc:472] ValidatedGraphConfig Initialization failed.
E/native  (29489): No registered object with name: HolisticLandmarkGpu; Unable to find Calculator "HolisticLandmarkGpu"
E/native  (29489): No registered object with name: HolisticTrackingToRenderData; Unable to find Calculator "HolisticTrackingToRenderData"
D/GlThread(29489): Stopping GL thread ExternalTextureConverter
E/AndroidRuntime(29489): FATAL EXCEPTION: ExternalTextureConverter
E/AndroidRuntime(29489): Process: com.NNJ.mediapipe_holistic_example, PID: 29489
E/AndroidRuntime(29489): com.google.mediapipe.framework.MediaPipeException: not found: ValidatedGraphConfig Initialization failed.
E/AndroidRuntime(29489): No registered object with name: HolisticLandmarkGpu; Unable to find Calculator "HolisticLandmarkGpu"
E/AndroidRuntime(29489): No registered object with name: HolisticTrackingToRenderData; Unable to find Calculator "HolisticTrackingToRenderData"
E/AndroidRuntime(29489):        at com.google.mediapipe.framework.Graph.nativeStartRunningGraph(Native Method)
E/AndroidRuntime(29489):        at com.google.mediapipe.framework.Graph.startRunningGraph(Graph.java:324)
E/AndroidRuntime(29489):        at com.google.mediapipe.components.FrameProcessor.startGraph(FrameProcessor.java:553)
E/AndroidRuntime(29489):        at com.google.mediapipe.components.FrameProcessor.maybeAcceptNewFrame(FrameProcessor.java:421)
E/AndroidRuntime(29489):        at com.google.mediapipe.components.FrameProcessor.onNewFrame(FrameProcessor.java:439)
E/AndroidRuntime(29489):        at com.google.mediapipe.components.ExternalTextureConverter$RenderThread.renderNext(ExternalTextureConverter.java:403)
E/AndroidRuntime(29489):        at com.google.mediapipe.components.ExternalTextureConverter$RenderThread.lambda$onFrameAvailable$0$ExternalTextureConverter$RenderThread(ExternalTextureConverter.java:338)
E/AndroidRuntime(29489):        at com.google.mediapipe.components.-$$Lambda$ExternalTextureConverter$RenderThread$IXJjtE68JMV2CMJNQcFYhTUqhj8.run(Unknown Source:4)
E/AndroidRuntime(29489):        at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(29489):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29489):        at android.os.Looper.loop(Looper.java:236)
E/AndroidRuntime(29489):        at com.google.mediapipe.glutil.GlThread.run(GlThread.java:141)
  1. Folder structure: folder structure

Am I missing anything? Any help provided will be appreciated, thanks in advance!

jun
  • 21
  • 1

1 Answers1

1

The question is long long ago. Because other people can search it. I describe my thought. From site: https://google.github.io/mediapipe/getting_started/android_archive_library.html You can edit file

mediapipe/examples/android/src/java/com/google/mediapipe/apps/aar_example/BUILD

like this

load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")

mediapipe_aar(
    name = "mediapipe_face_detection",
    calculators = ["//mediapipe/graphs/face_detection:mobile_calculators"],
)

the name "mediapipe_face_detection" is a key, then we will use it when build, and build like this:

bazel build -c opt --strip=ALWAYS \
    --host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
    --fat_apk_cpu=arm64-v8a,armeabi-v7a \
    --legacy_whole_archive=0 \
    --features=-legacy_whole_archive \
    --copt=-fvisibility=hidden \
    --copt=-ffunction-sections \
    --copt=-fdata-sections \
    --copt=-fstack-protector \
    --copt=-Oz \
    --copt=-fomit-frame-pointer \
    --copt=-DABSL_MIN_LOG_LEVEL=2 \
    --linkopt=-Wl,--gc-sections,--strip-all \
    mediapipe/examples/android/src/java/com/google/mediapipe/apps/aar_example:mediapipe_face_detection.aar

the end line of command is a not only a relative path, you have to write like this to avoid extra effort.

I work this way success to get mediapipe_face_detection.aar file. I think other case is the same as it

yongle zhu
  • 73
  • 4