参考
MediaPipe的编译与测试_Linda Fan的博客-CSDN博客
Ubuntu上构建Android的MediaPipe_吃骨头不吐股骨头皮的博客-CSDN博客
根据setup_android_sdk_and_ndk.sh,安装SDK、NDK
最后编译的时候出现错误
ERROR: /home/user/.cache/bazel/_bazel_djgv4b/01070679540b3cf481bcf4a10240c48d/external/XNNPACK/BUILD.bazel:7951:19: Compiling src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c failed: (Exit 1): clang failed: error executing command external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -gcc-toolchain external/androidndk/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 -target ... (remaining 86 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:77:16: error: assigning to 'uint32x2_t' (vector of 2 'uint32_t' values) from incompatible type 'int'
vnacc0 = vdot_u32(vnacc0, va_zero_point, va0x01234567);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:78:21: error: assigning to 'uint32x4_t' (vector of 4 'uint32_t' values) from incompatible type 'int'
vpacc0x0123 = vdotq_lane_u32(vpacc0x0123, vb0123x0123, va0x01234567, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:79:21: error: assigning to 'uint32x4_t' (vector of 4 'uint32_t' values) from incompatible type 'int'
vpacc0x4567 = vdotq_lane_u32(vpacc0x4567, vb0123x4567, va0x01234567, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:80:21: error: assigning to 'uint32x4_t' (vector of 4 'uint32_t' values) from incompatible type 'int'
vpacc0x0123 = vdotq_lane_u32(vpacc0x0123, vb4567x0123, va0x01234567, 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:81:21: error: assigning to 'uint32x4_t' (vector of 4 'uint32_t' values) from incompatible type 'int'
vpacc0x4567 = vdotq_lane_u32(vpacc0x4567, vb4567x4567, va0x01234567, 1);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:95:16: error: assigning to 'uint32x2_t' (vector of 2 'uint32_t' values) from incompatible type 'int'
vnacc0 = vdot_u32(vnacc0, va_zero_point, va0x01234567);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:96:21: error: assigning to 'uint32x4_t' (vector of 4 'uint32_t' values) from incompatible type 'int'
vpacc0x0123 = vdotq_lane_u32(vpacc0x0123, vb0123x0123, va0x01234567, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/XNNPACK/src/qu8-igemm/gen/1x8c4-minmax-rndnu-neondot.c:97:21: error: assigning to 'uint32x4_t' (vector of 4 'uint32_t' values) from incompatible type 'int'
vpacc0x4567 = vdotq_lane_u32(vpacc0x4567, vb0123x4567, va0x01234567, 0);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 errors generated.
Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu:facedetectioncpu failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 19.804s, Critical Path: 11.25s
INFO: 395 processes: 146 internal, 249 linux-sandbox.
FAILED: Build did NOT complete successfully
(base) djgv4b:~/DXY/MP_Project/mediapipe$
初步判断为NDK版本的问题
根据参考1的解决方案,将ndk进行升级,从r18b升级到r21e
把sudo gedit /etc/profile中r18b,改为r21e
把WORKSPACE的android_sdk_repository中的r18b,改为r21e
再次尝试编译,成功
facedetectioncpu
bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu:facedetectioncpu
#生成facedetectioncpu.apk的位置
bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu/facedetectioncpu.apk
objectdetectioncpu
bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/objectdetectioncpu:objectdetectioncpu
#生成objectdetectioncpu.apk的位置
bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/objectdetectioncpu/objectdetectioncpu.apk
faceeffect
bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/faceeffect:faceeffect
#生成faceeffect.apk的位置
bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/faceeffect/faceeffect.apk
objectdetection3d
bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/objectdetection3d:objectdetection3d
#生成objectdetection3d.apk的位置
bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/objectdetection3d/objectdetection3d.apk
instantmotiontracking
bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/instantmotiontracking:instantmotiontracking
#生成instantmotiontracking.apk的位置
bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/instantmotiontracking/instantmotiontracking.apk
templatematchingcpu
bazel build -c opt --config=android_arm64 mediapipe/examples/android/src/java/com/google/mediapipe/apps/templatematchingcpu:templatematchingcpu
#生成templatematchingcpu.apk的位置
bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/templatematchingcpu/templatematchingcpu.apk