google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.76k stars 5.18k forks source link

AAR for MediaPipe Face Detection failed. #1889

Closed onuralpszr closed 3 years ago

onuralpszr commented 3 years ago

Hello, I was trying to build AAR file for learning/my project so I followed this link and it failed and has error

https://google.github.io/mediapipe/getting_started/android_archive_library.html

I checked other issues saw protobuf patches but already in there (0.8.3-2) then I looked for that other issues but didn't see something similar.

bazelisk 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/facedetectioncpu_aar:mp_face_detectioncpu_aar


DEBUG: Rule 'rules_foreign_cc' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "c2cdcf55ffaf49366725639e45dedd449b8c3fe22b54e31625eb80ce3a240f1e"
DEBUG: Repository rules_foreign_cc instantiated at:
  /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/WORKSPACE:42:13: in <toplevel>
Repository rule http_archive defined at:
  /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'com_google_absl' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'com_google_protobuf' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'com_google_googletest' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'com_github_gflags_gflags' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'rules_cc' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'build_bazel_rules_apple' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'build_bazel_rules_swift' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'build_bazel_apple_support' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'bazel_skylib' because it already exists.
DEBUG: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/org_tensorflow/third_party/repo.bzl:108:14: 
Warning: skipping import of repository 'pybind11' because it already exists.
INFO: Build options --cpu, --crosstool_top, --fat_apk_cpu, and 2 more have changed, discarding analysis cache.
DEBUG: Rule 'rules_cc' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "66af5b045d30b49a61faaf063ba5da7e47b9b393e3d64b40035f66ec1ade8f34"
DEBUG: Repository rules_cc instantiated at:
  /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/WORKSPACE:36:13: in <toplevel>
Repository rule http_archive defined at:
  /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
WARNING: API level 30 specified by android_ndk_repository 'androidndk' is not available. Using latest known API level 29
DEBUG: Rule 'android_opencv' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = "cdb0e190c3734edd4052a3535d9e4310af912a9f70a421b1621711942a1028d5"
DEBUG: Repository android_opencv instantiated at:
  /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/WORKSPACE:224:13: in <toplevel>
Repository rule http_archive defined at:
  /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:AudioDataConsumer.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:AudioDataProcessor.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:AudioDataProducer.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:CameraHelper.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:CameraXPreviewHelper.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:ExternalTextureConverter.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:FrameProcessor.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:MicrophoneHelper.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:PermissionHelper.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:TextureFrameConsumer.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:TextureFrameProcessor.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/components:TextureFrameProducer.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:AndroidAssetUtil.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:AndroidPacketCreator.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:AndroidPacketGetter.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:AppTextureFrame.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:AssetCache.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:AssetCacheDbHelper.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:Compat.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:GlSyncToken.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:Graph.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:GraphGlSyncToken.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:GraphProfiler.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:GraphService.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:GraphTextureFrame.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:MediaPipeException.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:MediaPipeRunner.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:Packet.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:PacketCallback.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:PacketCreator.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:PacketGetter.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:PacketListCallback.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:PacketWithHeaderCallback.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:ProtoUtil.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:SurfaceOutput.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:TextureFrame.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:TextureReleaseCallback.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:TypeNameRegistry.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/framework:TypeNameRegistryLite.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/glutil:CommonShaders.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/glutil:EglManager.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/glutil:ExternalTextureRenderer.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/glutil:GlThread.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/glutil:ShaderUtil.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
WARNING: /home/thunderbirdtr/Projects/MpProjects/mediapipe-0.8.3.2/mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar/BUILD:3:14: in srcs attribute of android_library rule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_android_lib: please do not import '//mediapipe/java/com/google/mediapipe/glutil:TextureRenderer.java' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'mediapipe_aar', the error might have been caused by the macro implementation
INFO: Analyzed target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar (0 packages loaded, 17819 targets configured).
INFO: Found 1 target...
INFO: From Executing genrule //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar_aar_manifest_generator:
/bin/bash: line 10: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
INFO: From Compiling com_google_protobuf/src/google/protobuf/message_lite.cc [for host]:
In file included from /usr/include/string.h:519,
                 from external/com_google_protobuf/src/google/protobuf/stubs/port.h:39,
                 from external/com_google_protobuf/src/google/protobuf/stubs/common.h:46,
                 from external/com_google_protobuf/src/google/protobuf/message_lite.h:45,
                 from external/com_google_protobuf/src/google/protobuf/message_lite.cc:36:
In function 'void* memcpy(void*, const void*, size_t)',
    inlined from 'google::protobuf::uint8* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, google::protobuf::uint8*)' at external/com_google_protobuf/src/google/protobuf/io/coded_stream.h:699:16,
    inlined from 'virtual google::protobuf::uint8* google::protobuf::internal::ImplicitWeakMessage::_InternalSerialize(google::protobuf::uint8*, google::protobuf::io::EpsCopyOutputStream*) const' at external/com_google_protobuf/src/google/protobuf/implicit_weak_message.h:87:28,
    inlined from 'bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const' at external/com_google_protobuf/src/google/protobuf/message_lite.cc:388:30:
/usr/include/bits/string_fortified.h:29:33: warning: 'void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
INFO: From ProtoCompile mediapipe/calculators/internal/callback_packet_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/gpu/gl_surface_sink_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/tool/calculator_graph_template.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/gpu/gl_context_options.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/calculator_profile.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From Generating JavaLite proto_library //mediapipe/framework:mediapipe_options_proto:
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:230] mediapipe/framework/mediapipe_options.proto: The file's outer class name, "MediapipeOptions", matches the name of one of the types declared inside it when case is ignored. This can cause compilation issues on Windows / MacOS. Please either rename the type or use the java_outer_classname option to specify a different outer class name for the .proto file to be safe.
INFO: From ProtoCompile mediapipe/framework/calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From Generating JavaLite proto_library //mediapipe/framework:mediapipe_options_proto:
[libprotobuf WARNING external/com_google_protobuf/src/google/protobuf/compiler/java/java_file.cc:230] mediapipe/framework/mediapipe_options.proto: The file's outer class name, "MediapipeOptions", matches the name of one of the types declared inside it when case is ignored. This can cause compilation issues on Windows / MacOS. Please either rename the type or use the java_outer_classname option to specify a different outer class name for the .proto file to be safe.
INFO: From ProtoCompile mediapipe/framework/calculator.pb.h:
bazel-out/android-arm64-v8a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/tensor/inference_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/gpu/gl_context_options.pb.h:
bazel-out/android-arm64-v8a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/internal/callback_packet_calculator.pb.h:
bazel-out/android-arm64-v8a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/calculator_profile.pb.h:
bazel-out/android-arm64-v8a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/tool/calculator_graph_template.pb.h:
bazel-out/android-arm64-v8a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/gpu/gl_surface_sink_calculator.pb.h:
bazel-out/android-arm64-v8a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/util/detections_to_render_data_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/tflite/ssd_anchors_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/tensor/tensors_to_detections_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/util/non_max_suppression_calculator.pb.h:
bazel-out/android-armeabi-v7a-opt/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/calculator.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/gpu/gl_context_options.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/tensor/tensors_to_detections_calculator.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/calculator_profile.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/tflite/ssd_anchors_calculator.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/internal/callback_packet_calculator.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/calculators/util/non_max_suppression_calculator.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
INFO: From ProtoCompile mediapipe/framework/tool/calculator_graph_template.pb.h [for host]:
bazel-out/host/bin/external/com_google_protobuf/src: warning: directory does not exist.
ERROR: /home/thunderbirdtr/.cache/bazel/_bazel_thunderbirdtr/47aecfbb39c3d4019351abcfc511078c/external/com_google_absl/absl/synchronization/BUILD.bazel:30:11: C++ compilation of rule '@com_google_absl//absl/synchronization:graphcycles_internal' failed (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 38 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 38 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
external/com_google_absl/absl/synchronization/internal/graphcycles.cc: In member function 'void absl::lts_2020_09_23::synchronization_internal::GraphCycles::RemoveNode(void*)':
external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:26: error: 'numeric_limits' is not a member of 'std'
  451 |   if (x->version == std::numeric_limits<uint32_t>::max()) {
      |                          ^~~~~~~~~~~~~~
external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:49: error: expected primary-expression before '>' token
  451 |   if (x->version == std::numeric_limits<uint32_t>::max()) {
      |                                                 ^
external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:52: error: '::max' has not been declared; did you mean 'std::max'?
  451 |   if (x->version == std::numeric_limits<uint32_t>::max()) {
      |                                                    ^~~
      |                                                    std::max
In file included from /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/algorithm:62,
                 from external/com_google_absl/absl/synchronization/internal/graphcycles.cc:38:
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:3467:5: note: 'std::max' declared here
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Target //mediapipe/examples/android/src/java/com/google/mediapipe/apps/facedetectioncpu_aar:mp_face_detectioncpu_aar failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 105.919s, Critical Path: 95.53s
INFO: 839 processes: 187 internal, 652 linux-sandbox.
FAILED: Build did NOT complete successfully
gcc --version
gcc (GCC) 11.0.1 20210405 (Red Hat 11.0.1-0)

python --version
Python 3.9.4

pip list | grep -E "six|numpy" 
numpy             1.20.1
six                  1.15.0

bazelisk --version
bazel 3.7.2
onuralpszr commented 3 years ago

That looks like related with this issue : https://github.com/bazelbuild/bazel/issues/12702

onuralpszr commented 3 years ago

I managed to compile with this change in WORKSPACE

http_archive(
    name = "com_google_absl",
    urls = [
        "https://github.com/abseil/abseil-cpp/archive/20210324.0.tar.gz",
    ],
    # Remove after https://github.com/abseil/abseil-cpp/issues/326 is solved.
    patches = [
        "@//third_party:com_google_absl_f863b622fe13612433fdf43f76547d5edda0c93001.diff"
    ],
    patch_args = [
        "-p1",
    ],
    strip_prefix = "abseil-cpp-20210324.0",
    sha256 = "dd7db6815204c2a62a2160e32c55e97113b0a0178b2f090d6bab5ce36111db4b"
)

But didn't tested yet. (I'll update the comment when I tested)

onuralpszr commented 3 years ago

I was able to use Kotlin with basic face detection :+1: the only issue I had "camera" didn't start normal but start with "black screen" until rotate landmark then portrait mode.


import android.graphics.SurfaceTexture
import android.os.Bundle
import android.util.Log
import android.util.Size
import android.view.SurfaceHolder
import android.view.SurfaceView
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import com.google.mediapipe.components.CameraHelper.CameraFacing
import com.google.mediapipe.components.CameraXPreviewHelper
import com.google.mediapipe.components.ExternalTextureConverter
import com.google.mediapipe.components.FrameProcessor
import com.google.mediapipe.components.PermissionHelper
import com.google.mediapipe.formats.proto.LandmarkProto.NormalizedLandmarkList
import com.google.mediapipe.framework.AndroidAssetUtil
import com.google.mediapipe.framework.Packet
import com.google.mediapipe.framework.PacketGetter
import com.google.mediapipe.glutil.EglManager
import com.google.mediapipe.framework.AndroidPacketCreator

class MainActivity : AppCompatActivity() {

    private val BINARY_GRAPH_NAME = "face_detection_mobile_gpu.binarypb"
    private val INPUT_VIDEO_STREAM_NAME = "input_video"
    private val OUTPUT_VIDEO_STREAM_NAME = "output_video"
    private val CAMERA_FACING = CameraFacing.FRONT

    // Flips the camera-preview frames vertically before sending them into FrameProcessor to be
    // processed in a MediaPipe graph, and flips the processed frames back when they are displayed.
    // This is needed because OpenGL represents images assuming the image origin is at the
    // bottom-left corner, whereas MediaPipe in general assumes the image origin is at top-left.
    private val FLIP_FRAMES_VERTICALLY = true

    companion object {
        // Used to load the 'native-lib' library on application startup.
        init {

            System.loadLibrary("mediapipe_jni")
            System.loadLibrary("opencv_java3")
        }
    }

    // {@link SurfaceTexture} where the camera-preview frames can be accessed.
    private var previewFrameTexture: SurfaceTexture? = null

    // {@link SurfaceView} that displays the camera-preview frames processed by a MediaPipe graph.
    private var previewDisplayView: SurfaceView? = null

    // Creates and manages an {@link EGLContext}.
    private var eglManager: EglManager? = null

    // Sends camera-preview frames into a MediaPipe graph for processing, and displays the processed
    // frames onto a {@link Surface}.
    private var processor: FrameProcessor? = null

    // Converts the GL_TEXTURE_EXTERNAL_OES texture from Android camera into a regular texture to be
    // consumed by {@link FrameProcessor} and the underlying MediaPipe graph.
    private var converter: ExternalTextureConverter? = null

    // Handles camera access via the {@link CameraX} Jetpack support library.
    private var cameraHelper: CameraXPreviewHelper? = null

    // Face mesh
    private val INPUT_NUM_FACES_SIDE_PACKET_NAME = "num_faces"
    private val OUTPUT_LANDMARKS_STREAM_NAME = "multi_face_landmarks"

    // Max number of faces to detect/process.
    private val NUM_FACES = 1

    private val TAG = "LLOG"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        //findViewById<TextView>(R.id.sample_text).text = stringFromJNI()

        previewDisplayView = SurfaceView(this)
        setupPreviewDisplayView()
        // Initialize asset manager so that MediaPipe native libraries can access the app assets, e.g.,
        // binary graphs.

        // Initialize asset manager so that MediaPipe native libraries can access the app assets, e.g.,
        // binary graphs.
        AndroidAssetUtil.initializeNativeAssetManager(this)
        eglManager = EglManager(null)
        processor = FrameProcessor(
            this,
            eglManager!!.nativeContext,
            BINARY_GRAPH_NAME,
            INPUT_VIDEO_STREAM_NAME,
            OUTPUT_VIDEO_STREAM_NAME
        )
        processor!!.videoSurfaceOutput.setFlipY(FLIP_FRAMES_VERTICALLY)
        PermissionHelper.checkAndRequestCameraPermissions(this)

        val packetCreator:AndroidPacketCreator = processor!!.packetCreator
        val inputSidePackets: MutableMap<String, Packet> = HashMap()
        inputSidePackets[INPUT_NUM_FACES_SIDE_PACKET_NAME] = packetCreator.createInt32(NUM_FACES)
        processor!!.setInputSidePackets(inputSidePackets)
        //logFaceLandmark()
    }

    override fun onResume() {
        super.onResume()
        converter = ExternalTextureConverter(eglManager!!.context)
        converter?.setFlipY(FLIP_FRAMES_VERTICALLY)
        converter?.setConsumer(processor)
        if (PermissionHelper.cameraPermissionsGranted(this)) {
            startCamera()
        }
    }

    override fun onPause() {
        super.onPause()
        converter!!.close()
    }

    private fun startCamera() {
        cameraHelper = CameraXPreviewHelper()
        cameraHelper!!.setOnCameraStartedListener { surfaceTexture: SurfaceTexture? ->
            previewFrameTexture = surfaceTexture
            // Make the display view visible to start showing the preview. This triggers the
            // SurfaceHolder.Callback added to (the holder of) previewDisplayView.
            previewDisplayView!!.visibility = View.VISIBLE
        }
        cameraHelper!!.startCamera(this, CAMERA_FACING,  /*surfaceTexture=*/null)
    }

    private fun setupPreviewDisplayView() {
        previewDisplayView!!.visibility = View.GONE
        val viewGroup = findViewById<ViewGroup>(R.id.preview_display_layout)
        viewGroup.addView(previewDisplayView)

        previewDisplayView!!
            .holder
            .addCallback(
                object : SurfaceHolder.Callback {
                    override fun surfaceCreated(holder: SurfaceHolder) {
                        processor!!.videoSurfaceOutput.setSurface(holder.surface)
                    }

                    override fun surfaceChanged(
                        holder: SurfaceHolder,
                        format: Int,
                        width: Int,
                        height: Int
                    ) {
                        // (Re-)Compute the ideal size of the camera-preview display (the area that the
                        // camera-preview frames get rendered onto, potentially with scaling and rotation)
                        // based on the size of the SurfaceView that contains the display.
                        val viewSize = Size(width, height)
                        val displaySize: Size =
                            cameraHelper!!.computeDisplaySizeFromViewSize(viewSize)

                        // Connect the converter to the camera-preview frames as its input (via
                        // previewFrameTexture), and configure the output width and height as the computed
                        // display size.
                        converter?.setSurfaceTextureAndAttachToGLContext(
                            previewFrameTexture, displaySize.height, displaySize.width
                        )
                    }

                    override fun surfaceDestroyed(holder: SurfaceHolder) {
                        processor!!.videoSurfaceOutput.setSurface(null)
                    }
                })
    }
    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
    }
}

I had to also change setSurfaceTextureAndAttachToGLContext

width = displaySize.height height = displaySize.width

Because there was a "stretched in width" I don't know because of layout but It was ugly.


                        converter?.setSurfaceTextureAndAttachToGLContext(
                            previewFrameTexture, displaySize.height, displaySize.width
                        )
onuralpszr commented 3 years ago

Hello, is there any updates about this ?

Thank you :)

sgowroji commented 3 years ago

Hi @thunderbirdtr, Let us know if you still are looking resolution for the above query. We also have a latest update that we released Face detection Android gradle API in our github repo. Try checking it and let us know if that works. Thanks!

google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

onuralpszr commented 3 years ago

Hi @thunderbirdtr, Let us know if you still are looking resolution for the above query. We also have a latest update that we released Face detection Android gradle API in our github repo. Try checking it and let us know if that works. Thanks!

Thank you for updates, I'll try and get back to you asap. Let me do clean test as well.

google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] commented 3 years ago

Are you satisfied with the resolution of your issue? Yes No