Merge branch 'v0.8.11-main' into lindera-ios-api
76
.gitignore
vendored
|
@ -4,3 +4,79 @@ mediapipe/MediaPipe.tulsiproj/*.tulsiconf-user
|
|||
mediapipe/provisioning_profile.mobileprovision
|
||||
.configure.bazelrc
|
||||
.user.bazelrc
|
||||
|
||||
|
||||
# Built application files
|
||||
*.apk
|
||||
*.aar
|
||||
*.ap_
|
||||
*.aab
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
# Java class files
|
||||
*.class
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
# Uncomment the following line in case you need and you don't have the release build type files in your app
|
||||
# release/
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
# Log Files
|
||||
*.log
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/
|
||||
# .idea/workspace.xml
|
||||
# .idea/tasks.xml
|
||||
# .idea/gradle.xml
|
||||
# .idea/assetWizardSettings.xml
|
||||
# .idea/dictionaries
|
||||
.idea/libraries
|
||||
# Android Studio 3 in .gitignore file.
|
||||
.idea/caches
|
||||
.idea/modules.xml
|
||||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
|
||||
.idea/navEditor.xml
|
||||
# Keystore files
|
||||
# Uncomment the following lines if you do not want to check your keystore files in.
|
||||
*.jks
|
||||
*.keystore
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
.cxx/
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
# Freeline
|
||||
freeline.py
|
||||
freeline/
|
||||
freeline_project_description.json
|
||||
# fastlane
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
fastlane/readme.md
|
||||
# Version control
|
||||
vcs.xml
|
||||
# lint
|
||||
lint/intermediates/
|
||||
lint/generated/
|
||||
lint/outputs/
|
||||
lint/tmp/
|
||||
# lint/reports/
|
||||
# MacOS
|
||||
.DS_Store
|
||||
# App Specific cases
|
||||
app/release/output.json
|
||||
.idea/codeStyles/
|
||||
|
|
190
WORKSPACE
|
@ -10,33 +10,37 @@ bind(
|
|||
|
||||
http_archive(
|
||||
name = "bazel_skylib",
|
||||
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
|
||||
type = "tar.gz",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
|
||||
],
|
||||
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
|
||||
)
|
||||
|
||||
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
|
||||
bazel_skylib_workspace()
|
||||
|
||||
load("@bazel_skylib//lib:versions.bzl", "versions")
|
||||
|
||||
versions.check(minimum_bazel_version = "3.7.2")
|
||||
|
||||
# ABSL cpp library lts_2021_03_24, patch 2.
|
||||
http_archive(
|
||||
name = "com_google_absl",
|
||||
urls = [
|
||||
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20210324.2.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",
|
||||
],
|
||||
# Remove after https://github.com/abseil/abseil-cpp/issues/326 is solved.
|
||||
patches = [
|
||||
"@//third_party:com_google_absl_f863b622fe13612433fdf43f76547d5edda0c93001.diff",
|
||||
],
|
||||
sha256 = "59b862f50e710277f8ede96f083a5bb8d7c9595376146838b9580be90374ee1f",
|
||||
strip_prefix = "abseil-cpp-20210324.2",
|
||||
sha256 = "59b862f50e710277f8ede96f083a5bb8d7c9595376146838b9580be90374ee1f"
|
||||
urls = [
|
||||
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20210324.2.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
|
@ -63,67 +67,68 @@ all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//v
|
|||
# Last updated 2021-07-02.
|
||||
http_archive(
|
||||
name = "com_google_googletest",
|
||||
urls = ["https://github.com/google/googletest/archive/4ec4cd23f486bf70efcc5d2caa40f24368f752e3.zip"],
|
||||
strip_prefix = "googletest-4ec4cd23f486bf70efcc5d2caa40f24368f752e3",
|
||||
sha256 = "de682ea824bfffba05b4e33b67431c247397d6175962534305136aa06f92e049",
|
||||
strip_prefix = "googletest-4ec4cd23f486bf70efcc5d2caa40f24368f752e3",
|
||||
urls = ["https://github.com/google/googletest/archive/4ec4cd23f486bf70efcc5d2caa40f24368f752e3.zip"],
|
||||
)
|
||||
|
||||
# Google Benchmark library v1.6.1 released on 2022-01-10.
|
||||
http_archive(
|
||||
name = "com_google_benchmark",
|
||||
urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz"],
|
||||
strip_prefix = "benchmark-1.6.1",
|
||||
sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
|
||||
build_file = "@//third_party:benchmark.BUILD",
|
||||
sha256 = "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4",
|
||||
strip_prefix = "benchmark-1.6.1",
|
||||
urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.6.1.tar.gz"],
|
||||
)
|
||||
|
||||
# gflags needed by glog
|
||||
http_archive(
|
||||
name = "com_github_gflags_gflags",
|
||||
strip_prefix = "gflags-2.2.2",
|
||||
sha256 = "19713a36c9f32b33df59d1c79b4958434cb005b5b47dc5400a7a4b078111d9b5",
|
||||
strip_prefix = "gflags-2.2.2",
|
||||
url = "https://github.com/gflags/gflags/archive/v2.2.2.zip",
|
||||
)
|
||||
|
||||
# 2020-08-21
|
||||
http_archive(
|
||||
name = "com_github_glog_glog",
|
||||
strip_prefix = "glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6",
|
||||
sha256 = "58c9b3b6aaa4dd8b836c0fd8f65d0f941441fb95e27212c5eeb9979cfd3592ab",
|
||||
strip_prefix = "glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6",
|
||||
urls = [
|
||||
"https://github.com/google/glog/archive/0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6.zip",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "com_github_glog_glog_no_gflags",
|
||||
strip_prefix = "glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6",
|
||||
sha256 = "58c9b3b6aaa4dd8b836c0fd8f65d0f941441fb95e27212c5eeb9979cfd3592ab",
|
||||
build_file = "@//third_party:glog_no_gflags.BUILD",
|
||||
urls = [
|
||||
"https://github.com/google/glog/archive/0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6.zip",
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:com_github_glog_glog_9779e5ea6ef59562b030248947f787d1256132ae.diff",
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
sha256 = "58c9b3b6aaa4dd8b836c0fd8f65d0f941441fb95e27212c5eeb9979cfd3592ab",
|
||||
strip_prefix = "glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6",
|
||||
urls = [
|
||||
"https://github.com/google/glog/archive/0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6.zip",
|
||||
],
|
||||
)
|
||||
|
||||
# easyexif
|
||||
http_archive(
|
||||
name = "easyexif",
|
||||
url = "https://github.com/mayanklahiri/easyexif/archive/master.zip",
|
||||
strip_prefix = "easyexif-master",
|
||||
build_file = "@//third_party:easyexif.BUILD",
|
||||
strip_prefix = "easyexif-master",
|
||||
url = "https://github.com/mayanklahiri/easyexif/archive/master.zip",
|
||||
)
|
||||
|
||||
# libyuv
|
||||
http_archive(
|
||||
name = "libyuv",
|
||||
build_file = "@//third_party:libyuv.BUILD",
|
||||
# Error: operand type mismatch for `vbroadcastss' caused by commit 8a13626e42f7fdcf3a6acbb0316760ee54cda7d8.
|
||||
urls = ["https://chromium.googlesource.com/libyuv/libyuv/+archive/2525698acba9bf9b701ba6b4d9584291a1f62257.tar.gz"],
|
||||
build_file = "@//third_party:libyuv.BUILD",
|
||||
)
|
||||
|
||||
# Note: protobuf-javalite is no longer released as a separate download, it's included in the main Java download.
|
||||
|
@ -137,18 +142,19 @@ http_archive(
|
|||
|
||||
http_archive(
|
||||
name = "com_google_protobuf",
|
||||
sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422",
|
||||
strip_prefix = "protobuf-3.19.1",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz"],
|
||||
patches = [
|
||||
"@//third_party:com_google_protobuf_fixes.diff"
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:com_google_protobuf_fixes.diff",
|
||||
],
|
||||
sha256 = "87407cd28e7a9c95d9f61a098a53cf031109d451a7763e7dd1253abf8b4df422",
|
||||
strip_prefix = "protobuf-3.19.1",
|
||||
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz"],
|
||||
)
|
||||
|
||||
load("//third_party/flatbuffers:workspace.bzl", flatbuffers = "repo")
|
||||
|
||||
flatbuffers()
|
||||
|
||||
http_archive(
|
||||
|
@ -160,27 +166,27 @@ http_archive(
|
|||
# sentencepiece
|
||||
http_archive(
|
||||
name = "com_google_sentencepiece",
|
||||
strip_prefix = "sentencepiece-1.0.0",
|
||||
repo_mapping = {"@com_google_glog": "@com_github_glog_glog"},
|
||||
sha256 = "c05901f30a1d0ed64cbcf40eba08e48894e1b0e985777217b7c9036cac631346",
|
||||
strip_prefix = "sentencepiece-1.0.0",
|
||||
urls = [
|
||||
"https://github.com/google/sentencepiece/archive/1.0.0.zip",
|
||||
],
|
||||
repo_mapping = {"@com_google_glog" : "@com_github_glog_glog"},
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "org_tensorflow_text",
|
||||
patch_args = ["-p1"],
|
||||
patches = [
|
||||
"//third_party:tensorflow_text_remove_tf_deps.diff",
|
||||
"//third_party:tensorflow_text_a0f49e63.diff",
|
||||
],
|
||||
repo_mapping = {"@com_google_re2": "@com_googlesource_code_re2"},
|
||||
sha256 = "f64647276f7288d1b1fe4c89581d51404d0ce4ae97f2bcc4c19bd667549adca8",
|
||||
strip_prefix = "text-2.2.0",
|
||||
urls = [
|
||||
"https://github.com/tensorflow/text/archive/v2.2.0.zip",
|
||||
],
|
||||
patches = [
|
||||
"//third_party:tensorflow_text_remove_tf_deps.diff",
|
||||
"//third_party:tensorflow_text_a0f49e63.diff",
|
||||
],
|
||||
patch_args = ["-p1"],
|
||||
repo_mapping = {"@com_google_re2": "@com_googlesource_code_re2"},
|
||||
)
|
||||
|
||||
http_archive(
|
||||
|
@ -195,20 +201,20 @@ http_archive(
|
|||
# 2020-07-09
|
||||
http_archive(
|
||||
name = "pybind11_bazel",
|
||||
sha256 = "75922da3a1bdb417d820398eb03d4e9bd067c4905a4246d35a44c01d62154d91",
|
||||
strip_prefix = "pybind11_bazel-203508e14aab7309892a1c5f7dd05debda22d9a5",
|
||||
urls = ["https://github.com/pybind/pybind11_bazel/archive/203508e14aab7309892a1c5f7dd05debda22d9a5.zip"],
|
||||
sha256 = "75922da3a1bdb417d820398eb03d4e9bd067c4905a4246d35a44c01d62154d91",
|
||||
)
|
||||
|
||||
# Point to the commit that deprecates the usage of Eigen::MappedSparseMatrix.
|
||||
http_archive(
|
||||
name = "pybind11",
|
||||
build_file = "@pybind11_bazel//:pybind11.BUILD",
|
||||
sha256 = "b971842fab1b5b8f3815a2302331782b7d137fef0e06502422bc4bc360f4956c",
|
||||
strip_prefix = "pybind11-70a58c577eaf067748c2ec31bfd0b0a614cffba6",
|
||||
urls = [
|
||||
"https://github.com/pybind/pybind11/archive/70a58c577eaf067748c2ec31bfd0b0a614cffba6.zip",
|
||||
],
|
||||
sha256 = "b971842fab1b5b8f3815a2302331782b7d137fef0e06502422bc4bc360f4956c",
|
||||
strip_prefix = "pybind11-70a58c577eaf067748c2ec31bfd0b0a614cffba6",
|
||||
build_file = "@pybind11_bazel//:pybind11.BUILD",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
|
@ -223,15 +229,15 @@ http_archive(
|
|||
# Point to the commit that deprecates the usage of Eigen::MappedSparseMatrix.
|
||||
http_archive(
|
||||
name = "ceres_solver",
|
||||
url = "https://github.com/ceres-solver/ceres-solver/archive/123fba61cf2611a3c8bddc9d91416db26b10b558.zip",
|
||||
patches = [
|
||||
"@//third_party:ceres_solver_compatibility_fixes.diff"
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:ceres_solver_compatibility_fixes.diff",
|
||||
],
|
||||
sha256 = "8b7b16ceb363420e0fd499576daf73fa338adb0b1449f58bea7862766baa1ac7",
|
||||
strip_prefix = "ceres-solver-123fba61cf2611a3c8bddc9d91416db26b10b558",
|
||||
sha256 = "8b7b16ceb363420e0fd499576daf73fa338adb0b1449f58bea7862766baa1ac7"
|
||||
url = "https://github.com/ceres-solver/ceres-solver/archive/123fba61cf2611a3c8bddc9d91416db26b10b558.zip",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
|
@ -250,7 +256,7 @@ new_local_repository(
|
|||
new_local_repository(
|
||||
name = "linux_ffmpeg",
|
||||
build_file = "@//third_party:ffmpeg_linux.BUILD",
|
||||
path = "/usr"
|
||||
path = "/usr",
|
||||
)
|
||||
|
||||
new_local_repository(
|
||||
|
@ -288,39 +294,39 @@ http_archive(
|
|||
# '-DBUILD_PROTOBUF=OFF -DBUILD_opencv_dnn=OFF'.
|
||||
http_archive(
|
||||
name = "ios_opencv",
|
||||
sha256 = "7dd536d06f59e6e1156b546bd581523d8df92ce83440002885ec5abc06558de2",
|
||||
build_file = "@//third_party:opencv_ios.BUILD",
|
||||
sha256 = "7dd536d06f59e6e1156b546bd581523d8df92ce83440002885ec5abc06558de2",
|
||||
type = "zip",
|
||||
url = "https://github.com/opencv/opencv/releases/download/3.2.0/opencv-3.2.0-ios-framework.zip",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "stblib",
|
||||
strip_prefix = "stb-b42009b3b9d4ca35bc703f5310eedc74f584be58",
|
||||
sha256 = "13a99ad430e930907f5611325ec384168a958bf7610e63e60e2fd8e7b7379610",
|
||||
urls = ["https://github.com/nothings/stb/archive/b42009b3b9d4ca35bc703f5310eedc74f584be58.tar.gz"],
|
||||
build_file = "@//third_party:stblib.BUILD",
|
||||
patches = [
|
||||
"@//third_party:stb_image_impl.diff"
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:stb_image_impl.diff",
|
||||
],
|
||||
sha256 = "13a99ad430e930907f5611325ec384168a958bf7610e63e60e2fd8e7b7379610",
|
||||
strip_prefix = "stb-b42009b3b9d4ca35bc703f5310eedc74f584be58",
|
||||
urls = ["https://github.com/nothings/stb/archive/b42009b3b9d4ca35bc703f5310eedc74f584be58.tar.gz"],
|
||||
)
|
||||
|
||||
# iOS basic build deps.
|
||||
|
||||
http_archive(
|
||||
name = "build_bazel_rules_apple",
|
||||
sha256 = "77e8bf6fda706f420a55874ae6ee4df0c9d95da6c7838228b26910fc82eea5a2",
|
||||
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.32.0/rules_apple.0.32.0.tar.gz",
|
||||
patches = [
|
||||
# Bypass checking ios unit test runner when building MP ios applications.
|
||||
"@//third_party:build_bazel_rules_apple_bypass_test_runner_check.diff"
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
# Bypass checking ios unit test runner when building MP ios applications.
|
||||
"@//third_party:build_bazel_rules_apple_bypass_test_runner_check.diff",
|
||||
],
|
||||
sha256 = "77e8bf6fda706f420a55874ae6ee4df0c9d95da6c7838228b26910fc82eea5a2",
|
||||
url = "https://github.com/bazelbuild/rules_apple/releases/download/0.32.0/rules_apple.0.32.0.tar.gz",
|
||||
)
|
||||
|
||||
load(
|
||||
|
@ -341,7 +347,7 @@ http_archive(
|
|||
name = "build_bazel_apple_support",
|
||||
sha256 = "741366f79d900c11e11d8efd6cc6c66a31bfb2451178b58e0b5edc6f1db17b35",
|
||||
urls = [
|
||||
"https://github.com/bazelbuild/apple_support/releases/download/0.10.0/apple_support.0.10.0.tar.gz"
|
||||
"https://github.com/bazelbuild/apple_support/releases/download/0.10.0/apple_support.0.10.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -356,21 +362,22 @@ apple_support_dependencies()
|
|||
|
||||
http_archive(
|
||||
name = "google_toolbox_for_mac",
|
||||
url = "https://github.com/google/google-toolbox-for-mac/archive/v2.2.1.zip",
|
||||
build_file = "@//third_party:google_toolbox_for_mac.BUILD",
|
||||
sha256 = "e3ac053813c989a88703556df4dc4466e424e30d32108433ed6beaec76ba4fdc",
|
||||
strip_prefix = "google-toolbox-for-mac-2.2.1",
|
||||
build_file = "@//third_party:google_toolbox_for_mac.BUILD",
|
||||
url = "https://github.com/google/google-toolbox-for-mac/archive/v2.2.1.zip",
|
||||
)
|
||||
|
||||
# Maven dependencies.
|
||||
|
||||
RULES_JVM_EXTERNAL_TAG = "4.0"
|
||||
|
||||
RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169"
|
||||
|
||||
http_archive(
|
||||
name = "rules_jvm_external",
|
||||
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
|
||||
sha256 = RULES_JVM_EXTERNAL_SHA,
|
||||
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
|
||||
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
|
||||
)
|
||||
|
||||
|
@ -409,13 +416,13 @@ maven_install(
|
|||
"junit:junit:4.12",
|
||||
"org.hamcrest:hamcrest-library:1.3",
|
||||
],
|
||||
fetch_sources = True,
|
||||
repositories = [
|
||||
"https://maven.google.com",
|
||||
"https://dl.google.com/dl/android/maven2",
|
||||
"https://repo1.maven.org/maven2",
|
||||
"https://jcenter.bintray.com",
|
||||
],
|
||||
fetch_sources = True,
|
||||
version_conflict_policy = "pinned",
|
||||
)
|
||||
|
||||
|
@ -435,44 +442,49 @@ http_archive(
|
|||
http_archive(
|
||||
name = "zlib",
|
||||
build_file = "//third_party:zlib.BUILD",
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:zlib.diff",
|
||||
],
|
||||
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
|
||||
strip_prefix = "zlib-1.2.11",
|
||||
urls = [
|
||||
"http://mirror.bazel.build/zlib.net/fossils/zlib-1.2.11.tar.gz",
|
||||
"http://zlib.net/fossils/zlib-1.2.11.tar.gz", # 2017-01-15
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:zlib.diff",
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
)
|
||||
|
||||
# TensorFlow repo should always go after the other external dependencies.
|
||||
# TF on 2022-08-10.
|
||||
_TENSORFLOW_GIT_COMMIT = "af1d5bc4fbb66d9e6cc1cf89503014a99233583b"
|
||||
|
||||
_TENSORFLOW_SHA256 = "f85a5443264fc58a12d136ca6a30774b5bc25ceaf7d114d97f252351b3c3a2cb"
|
||||
|
||||
http_archive(
|
||||
name = "org_tensorflow",
|
||||
urls = [
|
||||
"https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT,
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
patches = [
|
||||
"@//third_party:org_tensorflow_compatibility_fixes.diff",
|
||||
# Diff is generated with a script, don't update it manually.
|
||||
"@//third_party:org_tensorflow_custom_ops.diff",
|
||||
],
|
||||
patch_args = [
|
||||
"-p1",
|
||||
],
|
||||
strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT,
|
||||
sha256 = _TENSORFLOW_SHA256,
|
||||
strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT,
|
||||
urls = [
|
||||
"https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT,
|
||||
],
|
||||
)
|
||||
|
||||
load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3")
|
||||
|
||||
tf_workspace3()
|
||||
|
||||
load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2")
|
||||
|
||||
tf_workspace2()
|
||||
|
||||
# Edge TPU
|
||||
|
@ -481,14 +493,32 @@ http_archive(
|
|||
sha256 = "14d5527a943a25bc648c28a9961f954f70ba4d79c0a9ca5ae226e1831d72fe80",
|
||||
strip_prefix = "libedgetpu-3164995622300286ef2bb14d7fdc2792dae045b7",
|
||||
urls = [
|
||||
"https://github.com/google-coral/libedgetpu/archive/3164995622300286ef2bb14d7fdc2792dae045b7.tar.gz"
|
||||
"https://github.com/google-coral/libedgetpu/archive/3164995622300286ef2bb14d7fdc2792dae045b7.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
load("@libedgetpu//:workspace.bzl", "libedgetpu_dependencies")
|
||||
|
||||
libedgetpu_dependencies()
|
||||
|
||||
load("@coral_crosstool//:configure.bzl", "cc_crosstool")
|
||||
|
||||
cc_crosstool(name = "crosstool")
|
||||
|
||||
load("//third_party:external_files.bzl", "external_files")
|
||||
|
||||
external_files()
|
||||
|
||||
load("@build_bazel_rules_android//android:rules.bzl", "android_ndk_repository", "android_sdk_repository")
|
||||
|
||||
android_sdk_repository(
|
||||
name = "androidsdk",
|
||||
# build_tools_version = "30.0.3",
|
||||
# path = "/Users/tj/Library/Android/sdk", # Path to Android SDK, optional if $ANDROID_HOME is set
|
||||
)
|
||||
|
||||
android_ndk_repository(
|
||||
name = "androidndk", # Required. Name *must* be "androidndk".
|
||||
api_level = 21,
|
||||
# path = "/Users/tj/Library/Android/sdk/ndk/21.4.7075529", # Optional. Can be omitted if `ANDROID_NDK_HOME` environment variable is set.
|
||||
)
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.google.mediapipe.apps.posetracking_camera"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Copper Labs AAR Files
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
|
||||
// App Dependencies
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.3.3'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
// Mediapipe dependencies
|
||||
implementation 'com.google.protobuf:protobuf-javalite:3.19.1'
|
||||
implementation 'com.google.flogger:flogger:latest.release'
|
||||
implementation 'com.google.flogger:flogger-system-backend:latest.release'
|
||||
implementation 'com.google.code.findbugs:jsr305:latest.release'
|
||||
implementation 'com.google.guava:guava:27.0.1-android'
|
||||
|
||||
// CameraX core library
|
||||
def camerax_version = "1.0.0-beta10"
|
||||
implementation "androidx.camera:camera-core:$camerax_version"
|
||||
implementation "androidx.camera:camera-camera2:$camerax_version"
|
||||
implementation "androidx.camera:camera-lifecycle:$camerax_version"
|
||||
// We cannot use official solution as it is missing dependencies for pose tracking.
|
||||
// implementation 'com.google.mediapipe:solution-core:latest.release'
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
POSE_TRACKING_OUTPUT_DIR=bazel-bin/mediapipe/java/com/google/mediapipe/solutions/posetracking
|
||||
GRADLE_LIBS_DIR=mediapipe/examples/android/solutions/posetracking-camera/libs
|
||||
#
|
||||
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/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutioncore:copperlabs-mediapipe
|
||||
|
||||
|
||||
mkdir $GRADLE_LIBS_DIR
|
||||
rm -f $GRADLE_LIBS_DIR/copperlabs-*.aar
|
||||
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-api.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-detection.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-graph.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-landmark.aar $GRADLE_LIBS_DIR
|
||||
\cp bazel-bin/mediapipe/java/com/google/mediapipe/solutioncore/copperlabs-mediapipe.aar $GRADLE_LIBS_DIR
|
||||
|
21
mediapipe/examples/android/solutions/posetracking-camera/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.examples.posetracking_camera">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="30" />
|
||||
|
||||
<!-- For loading images from gallery -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- For using the camera -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<!-- For logging solution events -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="CopperLabs PoseTracking"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,50 @@
|
|||
# Copyright 2021 The MediaPipe Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
package(default_visibility = ["//visibility:private"])
|
||||
|
||||
android_binary(
|
||||
name = "posetracking-camera",
|
||||
srcs = glob(["**/*.java"]),
|
||||
custom_package = "com.google.mediapipe.examples.posetracking_camera",
|
||||
manifest = "AndroidManifest.xml",
|
||||
manifest_values = {
|
||||
"applicationId": "com.google.mediapipe.examples.posetracking_camera",
|
||||
},
|
||||
multidex = "native",
|
||||
resource_files = ["//mediapipe/examples/android/solutions:resource_files"],
|
||||
deps = [
|
||||
"//mediapipe/framework/formats:detection_java_proto_lite",
|
||||
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||
"//mediapipe/framework/formats:location_data_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:mediapipe_jni_lib",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_rendering",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:video_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:androidx_constraint_layout",
|
||||
"//third_party:opencv",
|
||||
"@maven//:androidx_activity_activity",
|
||||
"@maven//:androidx_concurrent_concurrent_futures",
|
||||
"@maven//:androidx_exifinterface_exifinterface",
|
||||
"@maven//:androidx_fragment_fragment",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,156 @@
|
|||
// Copyright 2021 The MediaPipe Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.mediapipe.examples.posetracking_camera;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.mediapipe.formats.proto.LandmarkProto;
|
||||
import com.google.mediapipe.solutioncore.CameraInput;
|
||||
import com.google.mediapipe.solutioncore.SolutionGlSurfaceView;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTracking;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTrackingOptions;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTrackingResult;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTrackingResultGlRenderer;
|
||||
|
||||
|
||||
/**
|
||||
* Main activity of MediaPipe Face Detection app.
|
||||
*/
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
private static final int rotation = Surface.ROTATION_0;
|
||||
private PoseTracking poseTracking;
|
||||
|
||||
|
||||
private ActivityResultLauncher<Intent> videoGetter;
|
||||
// Live camera demo UI and camera components.
|
||||
private CameraInput cameraInput;
|
||||
|
||||
private SolutionGlSurfaceView<PoseTrackingResult> glSurfaceView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
disableRedundantUI();
|
||||
|
||||
setupLiveDemoUiComponents();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the UI components for the live demo with camera input.
|
||||
*/
|
||||
private void setupLiveDemoUiComponents() {
|
||||
|
||||
Button startCameraButton = findViewById(R.id.button_start_camera);
|
||||
startCameraButton.setOnClickListener(
|
||||
v -> {
|
||||
setupStreamingModePipeline();
|
||||
startCameraButton.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables unecesary UI buttons
|
||||
*/
|
||||
private void disableRedundantUI() {
|
||||
findViewById(R.id.button_load_picture).setVisibility(View.GONE);
|
||||
findViewById(R.id.button_load_video).setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up core workflow for streaming mode.
|
||||
*/
|
||||
private void setupStreamingModePipeline() {
|
||||
// Initializes a new MediaPipe Face Detection solution instance in the streaming mode.
|
||||
poseTracking =
|
||||
new PoseTracking(
|
||||
this,
|
||||
PoseTrackingOptions.builder()
|
||||
.setStaticImageMode(false)
|
||||
.setLandmarkVisibility(true)
|
||||
.setModelComplexity(0)
|
||||
.setSmoothLandmarks(true)
|
||||
.build());
|
||||
poseTracking.setErrorListener(
|
||||
(message, e) -> Log.e(TAG, "MediaPipe Face Detection error:" + message));
|
||||
cameraInput = new CameraInput(this);
|
||||
|
||||
cameraInput.setNewFrameListener(textureFrame -> poseTracking.send(textureFrame));
|
||||
|
||||
|
||||
// Initializes a new Gl surface view with a user-defined PoseTrackingResultGlRenderer.
|
||||
glSurfaceView =
|
||||
new SolutionGlSurfaceView<>(
|
||||
this, poseTracking.getGlContext(), poseTracking.getGlMajorVersion());
|
||||
glSurfaceView.setSolutionResultRenderer(new PoseTrackingResultGlRenderer());
|
||||
glSurfaceView.setRenderInputImage(true);
|
||||
poseTracking.setResultListener(
|
||||
poseTrackingResult -> {
|
||||
logExampleKeypoint(poseTrackingResult);
|
||||
glSurfaceView.setRenderData(poseTrackingResult);
|
||||
glSurfaceView.requestRender();
|
||||
});
|
||||
|
||||
// The runnable to start camera after the gl surface view is attached.
|
||||
// For video input source, videoInput.start() will be called when the video uri is available.
|
||||
glSurfaceView.post(this::startCamera);
|
||||
|
||||
// Updates the preview layout.
|
||||
FrameLayout frameLayout = findViewById(R.id.preview_display_layout);
|
||||
frameLayout.removeAllViewsInLayout();
|
||||
frameLayout.addView(glSurfaceView);
|
||||
glSurfaceView.setVisibility(View.VISIBLE);
|
||||
frameLayout.requestLayout();
|
||||
}
|
||||
|
||||
private void startCamera() {
|
||||
cameraInput.getConverter(poseTracking.getGlContext()).setRotation(rotation);
|
||||
cameraInput.start(
|
||||
this,
|
||||
poseTracking.getGlContext(),
|
||||
CameraInput.CameraFacing.FRONT,
|
||||
glSurfaceView.getWidth(),
|
||||
glSurfaceView.getHeight());
|
||||
}
|
||||
|
||||
|
||||
private void logExampleKeypoint(
|
||||
PoseTrackingResult result) {
|
||||
if (result.multiPoseLandmarks().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
LandmarkProto.Landmark exampleLandmark = result.multiPoseLandmarks().get(PoseTrackingResult.NOSE);
|
||||
Log.i(
|
||||
TAG,
|
||||
String.format(
|
||||
"Pose Landmark Landmark of Nose: x=%f, y=%f, z=%f",
|
||||
exampleLandmark.getX(), exampleLandmark.getY(), exampleLandmark.getZ()));
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
../../../res
|
|
@ -0,0 +1,57 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.google.mediapipe.apps.posetracking_lindera"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Copper Labs AAR Files
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
|
||||
// App Dependencies
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.3.3'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
// Mediapipe dependencies
|
||||
implementation 'com.google.protobuf:protobuf-javalite:3.19.1'
|
||||
implementation 'com.google.flogger:flogger:latest.release'
|
||||
implementation 'com.google.flogger:flogger-system-backend:latest.release'
|
||||
implementation 'com.google.code.findbugs:jsr305:latest.release'
|
||||
implementation 'com.google.guava:guava:27.0.1-android'
|
||||
|
||||
// CameraX core library
|
||||
def camerax_version = "1.0.0-beta10"
|
||||
implementation "androidx.camera:camera-core:$camerax_version"
|
||||
implementation "androidx.camera:camera-camera2:$camerax_version"
|
||||
implementation "androidx.camera:camera-lifecycle:$camerax_version"
|
||||
// We cannot use official solution as it is missing dependencies for pose tracking.
|
||||
// implementation 'com.google.mediapipe:solution-core:latest.release'
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
POSE_TRACKING_OUTPUT_DIR=bazel-bin/mediapipe/java/com/google/mediapipe/solutions/posetracking
|
||||
GRADLE_LIBS_DIR=mediapipe/examples/android/solutions/posetracking-lindera/libs
|
||||
#
|
||||
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/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/lindera:copperlabs-lindera.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutioncore:copperlabs-mediapipe
|
||||
|
||||
|
||||
|
||||
mkdir $GRADLE_LIBS_DIR
|
||||
rm -f $GRADLE_LIBS_DIR/copperlabs-*.aar
|
||||
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-api.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-detection.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-graph.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-landmark.aar $GRADLE_LIBS_DIR
|
||||
\cp bazel-bin/mediapipe/java/com/google/mediapipe/solutions/lindera/copperlabs-lindera.aar $GRADLE_LIBS_DIR
|
||||
\cp bazel-bin/mediapipe/java/com/google/mediapipe/solutioncore/copperlabs-mediapipe.aar $GRADLE_LIBS_DIR
|
||||
|
21
mediapipe/examples/android/solutions/posetracking-lindera/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.examples.posetracking_lindera">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="30" />
|
||||
|
||||
<!-- For loading images from gallery -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- For using the camera -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<!-- For logging solution events -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="CopperLabs Lindera"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,52 @@
|
|||
# Copyright 2021 The MediaPipe Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
package(default_visibility = ["//visibility:private"])
|
||||
|
||||
android_binary(
|
||||
name = "posetracking-lindera",
|
||||
srcs = glob(["**/*.java"]),
|
||||
custom_package = "com.google.mediapipe.examples.posetracking_lindera",
|
||||
manifest = "AndroidManifest.xml",
|
||||
manifest_values = {
|
||||
"applicationId": "com.google.mediapipe.examples.posetracking_lindera",
|
||||
},
|
||||
multidex = "native",
|
||||
resource_files = ["//mediapipe/examples/android/solutions:resource_files"],
|
||||
deps = [
|
||||
"//mediapipe/framework/formats:detection_java_proto_lite",
|
||||
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||
"//mediapipe/framework/formats:location_data_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:mediapipe_jni_lib",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_rendering",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:video_input",
|
||||
# "//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-lindera",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/lindera:copperlabs-lindera",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:androidx_constraint_layout",
|
||||
"//third_party:opencv",
|
||||
"@maven//:androidx_activity_activity",
|
||||
"@maven//:androidx_concurrent_concurrent_futures",
|
||||
"@maven//:androidx_exifinterface_exifinterface",
|
||||
"@maven//:androidx_fragment_fragment",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,18 @@
|
|||
package com.google.mediapipe.examples.posetracking_lindera;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.mediapipe.solutions.lindera.BodyJoints;
|
||||
import com.google.mediapipe.solutions.lindera.ComputerVisionPlugin;
|
||||
import com.google.mediapipe.solutions.lindera.XYZPointWithConfidence;
|
||||
|
||||
public class ComputerVisionPluginImpl implements ComputerVisionPlugin {
|
||||
|
||||
@Override
|
||||
public void bodyJoints(int timestamp, BodyJoints bodyJoints) {
|
||||
XYZPointWithConfidence nose = bodyJoints.nose;
|
||||
Log.v("ComputerVisionPluginImpl", String.format(
|
||||
|
||||
"Lindera BodyJoint of Nose: x=%f, y=%f, z=%f", nose.x, nose.y, nose.z));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
// Copyright 2021 The MediaPipe Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.mediapipe.examples.posetracking_lindera;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.mediapipe.solutions.lindera.CameraRotation;
|
||||
import com.google.mediapipe.solutions.lindera.ComputerVisionPlugin;
|
||||
import com.google.mediapipe.solutions.lindera.Lindera;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Main activity of MediaPipe Face Detection app.
|
||||
*/
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
private Lindera lindera;
|
||||
private ComputerVisionPlugin plugin;
|
||||
private boolean isLinderaInitialized = false;
|
||||
private boolean isDetectionStarted = false;
|
||||
// Live camera demo UI and camera components.
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
|
||||
disableRedundantUI();
|
||||
|
||||
setupLiveDemoUiComponents();
|
||||
plugin = new ComputerVisionPluginImpl();
|
||||
lindera = new Lindera(plugin);
|
||||
List<String> cameras = lindera.getAvailableCameras();
|
||||
// FRONT or BACK
|
||||
lindera.setCamera("FRONT");
|
||||
lindera.setCameraRotation(CameraRotation.AUTOMATIC);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets up the UI components for the live demo with camera input.
|
||||
*/
|
||||
private void setupLiveDemoUiComponents() {
|
||||
|
||||
Button startCameraButton = findViewById(R.id.button_start_camera);
|
||||
FrameLayout frameLayout = findViewById(R.id.preview_display_layout);
|
||||
|
||||
startCameraButton.setOnClickListener(
|
||||
v -> {
|
||||
// startCameraButton.setVisibility(View.GONE);
|
||||
if (!isLinderaInitialized) {
|
||||
lindera.initialize(frameLayout, MainActivity.this);
|
||||
isLinderaInitialized = true;
|
||||
startCameraButton.setText("STOP CAMERA");
|
||||
|
||||
} else {
|
||||
|
||||
if (isDetectionStarted) {
|
||||
startCameraButton.setText(R.string.start_camera);
|
||||
|
||||
|
||||
lindera.stopDetection();
|
||||
} else {
|
||||
lindera.startDetection();
|
||||
startCameraButton.setText("STOP CAMERA");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
isDetectionStarted = !isDetectionStarted;
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables unecesary UI buttons
|
||||
*/
|
||||
private void disableRedundantUI() {
|
||||
findViewById(R.id.button_load_picture).setVisibility(View.GONE);
|
||||
findViewById(R.id.button_load_video).setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
../../../res
|
|
@ -0,0 +1,57 @@
|
|||
plugins {
|
||||
id 'com.android.application'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.google.mediapipe.apps.posetracking"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Copper Labs AAR Files
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
|
||||
// App Dependencies
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.3.3'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
|
||||
// Mediapipe dependencies
|
||||
implementation 'com.google.protobuf:protobuf-javalite:3.19.1'
|
||||
implementation 'com.google.flogger:flogger:latest.release'
|
||||
implementation 'com.google.flogger:flogger-system-backend:latest.release'
|
||||
implementation 'com.google.code.findbugs:jsr305:latest.release'
|
||||
implementation 'com.google.guava:guava:27.0.1-android'
|
||||
|
||||
// CameraX core library
|
||||
def camerax_version = "1.0.0-beta10"
|
||||
implementation "androidx.camera:camera-core:$camerax_version"
|
||||
implementation "androidx.camera:camera-camera2:$camerax_version"
|
||||
implementation "androidx.camera:camera-lifecycle:$camerax_version"
|
||||
// We cannot use official solution as it is missing dependencies for pose tracking.
|
||||
// implementation 'com.google.mediapipe:solution-core:latest.release'
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
POSE_TRACKING_OUTPUT_DIR=bazel-bin/mediapipe/java/com/google/mediapipe/solutions/posetracking
|
||||
GRADLE_LIBS_DIR=mediapipe/examples/android/solutions/posetracking/libs
|
||||
#
|
||||
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/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph.aar \
|
||||
//mediapipe/java/com/google/mediapipe/solutioncore:copperlabs-mediapipe
|
||||
|
||||
|
||||
mkdir $GRADLE_LIBS_DIR
|
||||
rm -f $GRADLE_LIBS_DIR/copperlabs-*.aar
|
||||
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-api.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-detection.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-graph.aar $GRADLE_LIBS_DIR
|
||||
\cp $POSE_TRACKING_OUTPUT_DIR/copperlabs-pose-landmark.aar $GRADLE_LIBS_DIR
|
||||
\cp bazel-bin/mediapipe/java/com/google/mediapipe/solutioncore/copperlabs-mediapipe.aar $GRADLE_LIBS_DIR
|
||||
|
21
mediapipe/examples/android/solutions/posetracking/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.examples.posetracking">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="30" />
|
||||
|
||||
<!-- For loading images from gallery -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- For using the camera -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<!-- For logging solution events -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="CopperLabs PoseTracking"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,50 @@
|
|||
# Copyright 2021 The MediaPipe Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
package(default_visibility = ["//visibility:private"])
|
||||
|
||||
android_binary(
|
||||
name = "posetracking",
|
||||
srcs = glob(["**/*.java"]),
|
||||
custom_package = "com.google.mediapipe.examples.posetracking",
|
||||
manifest = "AndroidManifest.xml",
|
||||
manifest_values = {
|
||||
"applicationId": "com.google.mediapipe.examples.posetracking",
|
||||
},
|
||||
multidex = "native",
|
||||
resource_files = ["//mediapipe/examples/android/solutions:resource_files"],
|
||||
deps = [
|
||||
"//mediapipe/framework/formats:detection_java_proto_lite",
|
||||
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||
"//mediapipe/framework/formats:location_data_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:mediapipe_jni_lib",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_rendering",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:video_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-detection",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-graph",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-landmark",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:androidx_constraint_layout",
|
||||
"//third_party:opencv",
|
||||
"@maven//:androidx_activity_activity",
|
||||
"@maven//:androidx_concurrent_concurrent_futures",
|
||||
"@maven//:androidx_exifinterface_exifinterface",
|
||||
"@maven//:androidx_fragment_fragment",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.mediapipe.apps.posetrackingsolutiongpu;
|
||||
package com.google.mediapipe.examples.posetracking;;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -346,7 +346,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
private void logExampleKeypoint(
|
||||
PoseTrackingResult result, int faceIndex, boolean showPixelValues) {
|
||||
if (result.multiPoseTrackings().isEmpty()) {
|
||||
if (result.multiPoseLandmarks().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
LandmarkProto.Landmark exampleLandmark = result.multiPoseLandmarks().get(0);
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.mediapipe.apps.posetrackingsolutiongpu;
|
||||
package com.google.mediapipe.examples.posetracking;;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
|
1
mediapipe/examples/android/solutions/posetracking/src/main/res
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../../res
|
|
@ -1,4 +1,6 @@
|
|||
rootProject.name = "mediapipe-solutions-examples"
|
||||
include ':facedetection'
|
||||
include ':facemesh'
|
||||
include ':posetracking'
|
||||
include ':hands'
|
||||
include ':posetracking-camera'
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.apps.posetrackingsolutiongpu">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="27" />
|
||||
|
||||
<!-- For using the camera -->
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
|
||||
<!-- For profiling -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="${appName}"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name="${mainActivity}"
|
||||
android:exported="true"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- <meta-data android:name="cameraFacingFront" android:value="${cameraFacingFront}"/>-->
|
||||
<!-- <meta-data android:name="binaryGraphName" android:value="${binaryGraphName}"/>-->
|
||||
<!-- <meta-data android:name="inputVideoStreamName" android:value="${inputVideoStreamName}"/>-->
|
||||
<!-- <meta-data android:name="outputVideoStreamName" android:value="${outputVideoStreamName}"/>-->
|
||||
<!-- <meta-data android:name="flipFramesVertically" android:value="${flipFramesVertically}"/>-->
|
||||
<!-- <meta-data android:name="converterNumBuffers" android:value="${converterNumBuffers}"/>-->
|
||||
</application>
|
||||
</manifest>
|
|
@ -1,100 +0,0 @@
|
|||
# Copyright 2019 The MediaPipe Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
# Basic library common across example apps.
|
||||
android_library(
|
||||
name = "basic_lib",
|
||||
srcs = glob(["*.java"]),
|
||||
manifest = "AndroidManifest.xml",
|
||||
resource_files = glob(["res/**"]),
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||
"//mediapipe/framework/formats:detection_java_proto_lite",
|
||||
"//mediapipe/framework/formats:location_data_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/components:android_camerax_helper",
|
||||
"//mediapipe/java/com/google/mediapipe/components:android_components",
|
||||
"//mediapipe/java/com/google/mediapipe/framework:android_framework",
|
||||
"//mediapipe/java/com/google/mediapipe/glutil",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_rendering",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:video_input",
|
||||
# "//mediapipe/java/com/google/mediapipe/solutions/facedetection",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:androidx_constraint_layout",
|
||||
"//third_party:opencv",
|
||||
"@maven//:androidx_activity_activity",
|
||||
"@maven//:androidx_concurrent_concurrent_futures",
|
||||
"@maven//:androidx_exifinterface_exifinterface",
|
||||
"@maven//:androidx_fragment_fragment",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
||||
|
||||
# Manifest common across example apps.
|
||||
exports_files(
|
||||
srcs = ["AndroidManifest.xml"],
|
||||
)
|
||||
|
||||
# Native dependencies to perform edge detection in the Hello World example.
|
||||
cc_binary(
|
||||
name = "libmediapipe_jni.so",
|
||||
linkshared = 1,
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
# "//mediapipe/graphs/edge_detection:mobile_calculators",
|
||||
"//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni",
|
||||
#facedetection deps
|
||||
# "//mediapipe/graphs/face_detection:face_detection_full_range_mobile_gpu_deps",
|
||||
# "//mediapipe/graphs/face_detection:mobile_calculators",
|
||||
#pose tracking deps
|
||||
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu_deps",
|
||||
],
|
||||
)
|
||||
|
||||
# Converts the .so cc_binary into a cc_library, to be consumed in an android_binary.
|
||||
cc_library(
|
||||
name = "mediapipe_jni_lib",
|
||||
srcs = [":libmediapipe_jni.so"],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
# Hello World example app.
|
||||
android_binary(
|
||||
name = "helloworld",
|
||||
# assets = [
|
||||
# "//mediapipe/graphs/edge_detection:mobile_gpu.binarypb",
|
||||
# ],
|
||||
# assets_dir = "",
|
||||
manifest = "AndroidManifest.xml",
|
||||
manifest_values = {
|
||||
"applicationId": "com.google.mediapipe.apps.posetrackingsolutiongpu",
|
||||
"appName": "Hello World",
|
||||
"mainActivity": ".MainActivity",
|
||||
# "cameraFacingFront": "False",
|
||||
# "binaryGraphName": "mobile_gpu.binarypb",
|
||||
# "inputVideoStreamName": "input_video",
|
||||
# "outputVideoStreamName": "output_video",
|
||||
# "flipFramesVertically": "True",
|
||||
# "converterNumBuffers": "2",
|
||||
},
|
||||
multidex = "native",
|
||||
deps = [
|
||||
":basic_lib",
|
||||
":mediapipe_jni_lib",
|
||||
],
|
||||
)
|
|
@ -1,34 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108">
|
||||
<path
|
||||
android:fillType="evenOdd"
|
||||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="78.5885"
|
||||
android:endY="90.9159"
|
||||
android:startX="48.7653"
|
||||
android:startY="61.0927"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
|
||||
android:strokeColor="#00000000"
|
||||
android:strokeWidth="1" />
|
||||
</vector>
|
|
@ -1,74 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector
|
||||
android:height="108dp"
|
||||
android:width="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#26A69A"
|
||||
android:pathData="M0,0h108v108h-108z"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
</vector>
|
|
@ -1,40 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?android:attr/buttonBarStyle" android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/button_load_picture"
|
||||
android:layout_width="wrap_content"
|
||||
style="?android:attr/buttonBarButtonStyle" android:layout_height="wrap_content"
|
||||
android:text="Load Image" />
|
||||
<Button
|
||||
android:id="@+id/button_load_video"
|
||||
android:layout_width="wrap_content"
|
||||
style="?android:attr/buttonBarButtonStyle" android:layout_height="wrap_content"
|
||||
android:text="Load Video" />
|
||||
<Button
|
||||
android:id="@+id/button_start_camera"
|
||||
android:layout_width="wrap_content"
|
||||
style="?android:attr/buttonBarButtonStyle" android:layout_height="wrap_content"
|
||||
android:text="Start Camera" />
|
||||
</LinearLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/preview_display_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:id="@+id/no_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="No camera" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background"/>
|
||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||
</adaptive-icon>
|
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 959 B |
Before Width: | Height: | Size: 900 B |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 11 KiB |
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#008577</color>
|
||||
<color name="colorPrimaryDark">#00574B</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
</resources>
|
|
@ -1,3 +0,0 @@
|
|||
<resources>
|
||||
<string name="no_camera_access" translatable="false">Please grant camera permissions.</string>
|
||||
</resources>
|
|
@ -1,11 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -110,6 +110,7 @@ cc_binary(
|
|||
linkstatic = 1,
|
||||
# TODO: Add more calculators to support other top-level solutions.
|
||||
deps = [
|
||||
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu_deps",
|
||||
"//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni",
|
||||
"//mediapipe/modules/face_detection:face_detection_full_range_image",
|
||||
"//mediapipe/modules/face_detection:face_detection_short_range_image",
|
||||
|
@ -131,7 +132,13 @@ cc_library(
|
|||
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
|
||||
|
||||
mediapipe_aar(
|
||||
name = "solution_core",
|
||||
name = "copperlabs-mediapipe",
|
||||
srcs = glob(["**/*.java"]),
|
||||
gen_libmediapipe = False,
|
||||
)
|
||||
|
||||
#mediapipe_aar(
|
||||
# name = "solution_core",
|
||||
# srcs = glob(["**/*.java"]),
|
||||
# gen_libmediapipe = False,
|
||||
#)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe.solutions.lindera">
|
||||
|
||||
<uses-sdk android:minSdkVersion="21"
|
||||
android:targetSdkVersion="27" />
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
</manifest>
|
21
mediapipe/java/com/google/mediapipe/solutions/lindera/BUILD
Normal file
|
@ -0,0 +1,21 @@
|
|||
android_library(
|
||||
name = "copperlabs-lindera",
|
||||
srcs = glob(["*.java"]),
|
||||
manifest = "AndroidManifest.xml",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//mediapipe/framework/formats:detection_java_proto_lite",
|
||||
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/framework:android_framework",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_base",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_rendering",
|
||||
"//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs-pose-api",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:autovalue",
|
||||
"@com_google_protobuf//:protobuf_javalite",
|
||||
"@maven//:androidx_annotation_annotation",
|
||||
"@maven//:com_google_code_findbugs_jsr305",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,115 @@
|
|||
package com.google.mediapipe.solutions.lindera;
|
||||
|
||||
public class BodyJoints {
|
||||
public XYZPointWithConfidence nose;
|
||||
|
||||
public XYZPointWithConfidence leftEyeInner;
|
||||
public XYZPointWithConfidence leftEye;
|
||||
public XYZPointWithConfidence leftEyeOuter;
|
||||
|
||||
public XYZPointWithConfidence rightEyeInner;
|
||||
public XYZPointWithConfidence rightEye;
|
||||
public XYZPointWithConfidence rightEyeOuter;
|
||||
|
||||
public XYZPointWithConfidence leftEar;
|
||||
public XYZPointWithConfidence rightEar;
|
||||
|
||||
public XYZPointWithConfidence mouthLeft;
|
||||
public XYZPointWithConfidence mouthRight;
|
||||
|
||||
public XYZPointWithConfidence leftShoulder;
|
||||
public XYZPointWithConfidence rightShoulder;
|
||||
|
||||
public XYZPointWithConfidence leftElbow;
|
||||
public XYZPointWithConfidence rightElbow;
|
||||
|
||||
public XYZPointWithConfidence leftWrist;
|
||||
public XYZPointWithConfidence rightWrist;
|
||||
|
||||
public XYZPointWithConfidence leftPinky;
|
||||
public XYZPointWithConfidence rightPinky;
|
||||
|
||||
public XYZPointWithConfidence leftIndex;
|
||||
public XYZPointWithConfidence rightIndex;
|
||||
|
||||
public XYZPointWithConfidence leftThumb;
|
||||
public XYZPointWithConfidence rightThumb;
|
||||
|
||||
public XYZPointWithConfidence leftHip;
|
||||
public XYZPointWithConfidence rightHip;
|
||||
|
||||
public XYZPointWithConfidence leftKnee;
|
||||
public XYZPointWithConfidence rightKnee;
|
||||
|
||||
public XYZPointWithConfidence rightAnkle;
|
||||
public XYZPointWithConfidence leftAnkle;
|
||||
|
||||
|
||||
public XYZPointWithConfidence rightHeel;
|
||||
public XYZPointWithConfidence leftHeel;
|
||||
|
||||
public XYZPointWithConfidence rightFoot;
|
||||
public XYZPointWithConfidence leftFoot;
|
||||
|
||||
|
||||
// public XYZPointWithConfidence pelvis;
|
||||
//
|
||||
// public XYZPointWithConfidence spine;
|
||||
// public XYZPointWithConfidence thorax;
|
||||
// public XYZPointWithConfidence neckNose;
|
||||
// public XYZPointWithConfidence headTop;
|
||||
|
||||
|
||||
public BodyJoints() {
|
||||
nose = new XYZPointWithConfidence();
|
||||
|
||||
leftEyeInner= new XYZPointWithConfidence();
|
||||
leftEye= new XYZPointWithConfidence();
|
||||
leftEyeOuter= new XYZPointWithConfidence();
|
||||
|
||||
rightEyeInner= new XYZPointWithConfidence();
|
||||
rightEye= new XYZPointWithConfidence();
|
||||
rightEyeOuter= new XYZPointWithConfidence();
|
||||
|
||||
leftEar= new XYZPointWithConfidence();
|
||||
rightEar= new XYZPointWithConfidence();
|
||||
|
||||
mouthLeft= new XYZPointWithConfidence();
|
||||
mouthRight= new XYZPointWithConfidence();
|
||||
|
||||
leftShoulder= new XYZPointWithConfidence();
|
||||
rightShoulder= new XYZPointWithConfidence();
|
||||
|
||||
leftElbow= new XYZPointWithConfidence();
|
||||
rightElbow= new XYZPointWithConfidence();
|
||||
|
||||
leftWrist= new XYZPointWithConfidence();
|
||||
rightWrist= new XYZPointWithConfidence();
|
||||
|
||||
leftPinky= new XYZPointWithConfidence();
|
||||
rightPinky= new XYZPointWithConfidence();
|
||||
|
||||
leftIndex= new XYZPointWithConfidence();
|
||||
rightIndex= new XYZPointWithConfidence();
|
||||
|
||||
leftThumb= new XYZPointWithConfidence();
|
||||
rightThumb= new XYZPointWithConfidence();
|
||||
|
||||
leftHip= new XYZPointWithConfidence();
|
||||
rightHip= new XYZPointWithConfidence();
|
||||
|
||||
leftKnee= new XYZPointWithConfidence();
|
||||
rightKnee= new XYZPointWithConfidence();
|
||||
|
||||
rightAnkle= new XYZPointWithConfidence();
|
||||
leftAnkle= new XYZPointWithConfidence();
|
||||
|
||||
|
||||
rightHeel= new XYZPointWithConfidence();
|
||||
leftHeel= new XYZPointWithConfidence();
|
||||
|
||||
rightFoot= new XYZPointWithConfidence();
|
||||
leftFoot= new XYZPointWithConfidence();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.google.mediapipe.solutions.lindera;
|
||||
|
||||
|
||||
|
||||
import android.view.Surface;
|
||||
|
||||
//public class CameraRotation {
|
||||
//
|
||||
// public static final int FIXED_0_DEG = Surface.ROTATION_0;
|
||||
// public static final int FIXED_180_DEG = Surface.ROTATION_180;
|
||||
// public static final int FIXED_270_DEG = Surface.ROTATION_270;
|
||||
// public static final int FIXED_90_DEG = Surface.ROTATION_90;
|
||||
// public static final int AUTOMATIC = -1;
|
||||
//
|
||||
//}
|
||||
public enum CameraRotation {
|
||||
FIXED_0_DEG(Surface.ROTATION_0),FIXED_90_DEG(Surface.ROTATION_90),FIXED_180_DEG(Surface.ROTATION_180),FIXED_270_DEG(Surface.ROTATION_270),AUTOMATIC(-1);
|
||||
private final int value;
|
||||
private CameraRotation(int rotation) {
|
||||
value = rotation;
|
||||
}
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.google.mediapipe.solutions.lindera;
|
||||
|
||||
public interface ComputerVisionPlugin {
|
||||
void bodyJoints(int timestamp, BodyJoints bodyJoints);
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package com.google.mediapipe.solutions.lindera;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.mediapipe.formats.proto.LandmarkProto;
|
||||
import com.google.mediapipe.solutioncore.CameraInput;
|
||||
import com.google.mediapipe.solutioncore.SolutionGlSurfaceView;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTracking;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTrackingOptions;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTrackingResult;
|
||||
import com.google.mediapipe.solutions.posetracking.PoseTrackingResultGlRenderer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Lindera {
|
||||
private ComputerVisionPlugin plugin;
|
||||
private PoseTracking poseTracking;
|
||||
// TODO: Verify that this is the timestamp used in Actual Plugin
|
||||
private int timeStamp = 0;
|
||||
private CameraRotation cameraRotation = CameraRotation.AUTOMATIC;
|
||||
// Live camera demo UI and camera components.
|
||||
private CameraInput cameraInput;
|
||||
private SolutionGlSurfaceView<PoseTrackingResult> glSurfaceView;
|
||||
private CameraInput.CameraFacing cameraFacing = CameraInput.CameraFacing.FRONT;
|
||||
private AppCompatActivity appCompatActivity;
|
||||
private ViewGroup computerVisionContainerView;
|
||||
public Lindera(ComputerVisionPlugin plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void initialize (ViewGroup computerVisionContainerView , AppCompatActivity appCompatActivity){
|
||||
|
||||
this.computerVisionContainerView = computerVisionContainerView;
|
||||
this.appCompatActivity = appCompatActivity;
|
||||
startDetection();
|
||||
}
|
||||
|
||||
public void setCameraRotation(CameraRotation cameraRotation){
|
||||
this.cameraRotation = cameraRotation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setupEventListener() {
|
||||
poseTracking.setResultListener(
|
||||
poseTrackingResult -> {
|
||||
glSurfaceView.setRenderData(poseTrackingResult);
|
||||
glSurfaceView.requestRender();
|
||||
ImmutableList<LandmarkProto.Landmark> landmarks = poseTrackingResult.multiPoseLandmarks();
|
||||
timeStamp+=1;
|
||||
|
||||
if (landmarks.isEmpty()) return;
|
||||
|
||||
BodyJoints bodyJoints = new BodyJoints();
|
||||
landmarksToBodyJoints(landmarks,bodyJoints);
|
||||
|
||||
plugin.bodyJoints(timeStamp, bodyJoints);
|
||||
});
|
||||
}
|
||||
|
||||
public List<String> getAvailableCameras(){
|
||||
return Arrays.stream(CameraInput.CameraFacing.values()).map(Enum::name).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
public void doOnDestroy(){
|
||||
stopDetection();
|
||||
appCompatActivity = null;
|
||||
computerVisionContainerView = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will need to restart camera pipeline if already started
|
||||
* @param name One of FRONT or BACK
|
||||
*/
|
||||
public void setCamera(String name){
|
||||
cameraFacing = CameraInput.CameraFacing.valueOf(name);
|
||||
|
||||
}
|
||||
|
||||
public void startDetection(){
|
||||
// ensure that class is initalized
|
||||
assert (appCompatActivity != null);
|
||||
// Initializes a new MediaPipe Face Detection solution instance in the streaming mode.
|
||||
poseTracking =
|
||||
new PoseTracking(
|
||||
appCompatActivity,
|
||||
PoseTrackingOptions.builder()
|
||||
.setStaticImageMode(false)
|
||||
.setLandmarkVisibility(true)
|
||||
.setModelComplexity(0)
|
||||
.setSmoothLandmarks(true)
|
||||
.build());
|
||||
poseTracking.setErrorListener(
|
||||
(message, e) -> Log.e("Lindera", "MediaPipe Pose Tracking error:" + message));
|
||||
cameraInput = new CameraInput(appCompatActivity);
|
||||
|
||||
cameraInput.setNewFrameListener(textureFrame -> poseTracking.send(textureFrame));
|
||||
|
||||
|
||||
// Initializes a new Gl surface view with a user-defined PoseTrackingResultGlRenderer.
|
||||
glSurfaceView =
|
||||
new SolutionGlSurfaceView<>(
|
||||
appCompatActivity, poseTracking.getGlContext(), poseTracking.getGlMajorVersion());
|
||||
glSurfaceView.setSolutionResultRenderer(new PoseTrackingResultGlRenderer());
|
||||
glSurfaceView.setRenderInputImage(true);
|
||||
|
||||
setupEventListener();
|
||||
// The runnable to start camera after the gl surface view is attached.
|
||||
// For video input source, videoInput.start() will be called when the video uri is available.
|
||||
glSurfaceView.post(this::startCamera);
|
||||
// Updates the preview layout.
|
||||
|
||||
computerVisionContainerView.removeAllViewsInLayout();
|
||||
computerVisionContainerView.addView(glSurfaceView);
|
||||
glSurfaceView.setVisibility(View.VISIBLE);
|
||||
computerVisionContainerView.requestLayout();
|
||||
}
|
||||
public void stopDetection(){
|
||||
if (cameraInput != null) {
|
||||
cameraInput.setNewFrameListener(null);
|
||||
cameraInput.close();
|
||||
}
|
||||
if (glSurfaceView != null) {
|
||||
glSurfaceView.setVisibility(View.GONE);
|
||||
}
|
||||
if (poseTracking != null) {
|
||||
poseTracking.close();
|
||||
}
|
||||
timeStamp = 0;
|
||||
}
|
||||
|
||||
|
||||
private void landmarkToXYZPointWithConfidence(LandmarkProto.Landmark landmark,XYZPointWithConfidence bodyJoint){
|
||||
bodyJoint.x = landmark.getX();
|
||||
bodyJoint.y = landmark.getY();
|
||||
bodyJoint.z = landmark.getZ();
|
||||
bodyJoint.confidence = landmark.getVisibility();
|
||||
}
|
||||
private void landmarksToBodyJoints(ImmutableList<LandmarkProto.Landmark> landmarks , BodyJoints bodyJoints){
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.NOSE), bodyJoints.nose);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_EYE_INNER), bodyJoints.leftEyeInner);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_EYE), bodyJoints.leftEye);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_EYE_OUTER), bodyJoints.leftEyeOuter);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_EYE_INNER), bodyJoints.rightEyeInner);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_EYE), bodyJoints.rightEye);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_EYE_OUTER), bodyJoints.rightEyeOuter);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_EAR), bodyJoints.leftEar);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_EAR), bodyJoints.rightEar);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.MOUTH_LEFT), bodyJoints.mouthLeft);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.MOUTH_RIGHT), bodyJoints.mouthRight);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_SHOULDER), bodyJoints.leftShoulder);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_SHOULDER), bodyJoints.rightShoulder);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_ELBOW), bodyJoints.leftElbow);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_ELBOW), bodyJoints.rightElbow);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_WRIST), bodyJoints.leftWrist);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_WRIST), bodyJoints.rightWrist);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_PINKY), bodyJoints.leftPinky);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_PINKY), bodyJoints.rightPinky);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_INDEX), bodyJoints.leftIndex);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_INDEX), bodyJoints.rightIndex);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_THUMB), bodyJoints.leftThumb);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_THUMB), bodyJoints.rightThumb);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_HIP), bodyJoints.leftHip);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_HIP), bodyJoints.rightHip);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_KNEE), bodyJoints.leftKnee);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_KNEE), bodyJoints.rightKnee);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_ANKLE), bodyJoints.rightAnkle);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_ANKLE), bodyJoints.leftAnkle);
|
||||
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_HEEL), bodyJoints.rightHeel);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_HEEL), bodyJoints.leftHeel);
|
||||
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.RIGHT_FOOT), bodyJoints.rightFoot);
|
||||
landmarkToXYZPointWithConfidence(landmarks.get(PoseTrackingResult.LEFT_FOOT), bodyJoints.leftFoot);
|
||||
}
|
||||
|
||||
private void startCamera() {
|
||||
if (cameraRotation!=CameraRotation.AUTOMATIC) {
|
||||
cameraInput.getConverter(poseTracking.getGlContext()).setRotation(cameraRotation.getValue());
|
||||
}
|
||||
cameraInput.start(
|
||||
appCompatActivity,
|
||||
poseTracking.getGlContext(),
|
||||
cameraFacing,
|
||||
glSurfaceView.getWidth(),
|
||||
glSurfaceView.getHeight());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.google.mediapipe.solutions.lindera;
|
||||
|
||||
public class XYZPointWithConfidence {
|
||||
public float x = 0;
|
||||
public float y = 0;
|
||||
public float z = 0;
|
||||
public float confidence = 0;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
<uses-sdk android:minSdkVersion="21"
|
||||
android:targetSdkVersion="27" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
</manifest>
|
||||
|
|
|
@ -11,42 +11,107 @@
|
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
load("//mediapipe/java/com/google/mediapipe/solutions/posetracking:copperlabs_aar.bzl", "copperlabs_aar")
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
android_library(
|
||||
name = "posetracking",
|
||||
srcs = [
|
||||
POSE_TRACKING_SRCS = [
|
||||
"PersonKeypoint.java",
|
||||
"PoseTracking.java",
|
||||
"PoseTrackingOptions.java",
|
||||
"PoseTrackingResult.java",
|
||||
],
|
||||
assets = [
|
||||
# "//mediapipe/modules/face_detection:face_detection_full_range_image.binarypb",
|
||||
# "//mediapipe/modules/face_detection:face_detection_full_range_sparse.tflite",
|
||||
# "//mediapipe/modules/face_detection:face_detection_short_range.tflite",
|
||||
# "//mediapipe/modules/face_detection:face_detection_short_range_image.binarypb",
|
||||
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu_image.binarypb",
|
||||
"//mediapipe/modules/pose_landmark:pose_landmark_heavy.tflite",
|
||||
"//mediapipe/modules/pose_landmark:pose_landmark_full.tflite",
|
||||
"//mediapipe/modules/pose_landmark:pose_landmark_lite.tflite",
|
||||
"//mediapipe/modules/pose_detection:pose_detection.tflite",
|
||||
],
|
||||
assets_dir = "",
|
||||
"PoseTrackingResultGlRenderer.java",
|
||||
]
|
||||
|
||||
android_library(
|
||||
name = "copperlabs-pose-api",
|
||||
srcs = POSE_TRACKING_SRCS,
|
||||
javacopts = ["-Acom.google.auto.value.AutoBuilderIsUnstable"],
|
||||
manifest = ":AndroidManifest.xml",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//mediapipe/framework/formats:detection_java_proto_lite",
|
||||
"//mediapipe/framework/formats:landmark_java_proto_lite",
|
||||
"//mediapipe/framework/formats:location_data_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/framework:android_framework",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_base",
|
||||
"//mediapipe/java/com/google/mediapipe/solutioncore:solution_rendering",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:androidx_constraint_layout",
|
||||
"//third_party:autovalue",
|
||||
"@com_google_protobuf//:protobuf_javalite",
|
||||
"@maven//:androidx_activity_activity",
|
||||
"@maven//:androidx_annotation_annotation",
|
||||
"@maven//:androidx_concurrent_concurrent_futures",
|
||||
"@maven//:androidx_exifinterface_exifinterface",
|
||||
"@maven//:androidx_fragment_fragment",
|
||||
"@maven//:com_google_code_findbugs_jsr305",
|
||||
"@maven//:com_google_guava_guava",
|
||||
],
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "copperlabs-pose-landmark",
|
||||
srcs = [],
|
||||
assets = [
|
||||
"//mediapipe/modules/pose_landmark:pose_landmark_heavy.tflite",
|
||||
"//mediapipe/modules/pose_landmark:pose_landmark_full.tflite",
|
||||
"//mediapipe/modules/pose_landmark:pose_landmark_lite.tflite",
|
||||
],
|
||||
assets_dir = "",
|
||||
manifest = ":AndroidManifest.xml",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [],
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "copperlabs-pose-detection",
|
||||
srcs = [],
|
||||
assets = [
|
||||
"//mediapipe/modules/pose_detection:pose_detection.tflite",
|
||||
],
|
||||
assets_dir = "",
|
||||
manifest = ":AndroidManifest.xml",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [],
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = "copperlabs-pose-graph",
|
||||
srcs = [],
|
||||
assets = [
|
||||
"//mediapipe/graphs/pose_tracking:pose_tracking_gpu_image.binarypb",
|
||||
],
|
||||
assets_dir = "",
|
||||
manifest = ":AndroidManifest.xml",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [],
|
||||
)
|
||||
|
||||
#mediapipe_aar(
|
||||
# name = "copperlabs-mediapipe",
|
||||
# calculators = ["//mediapipe/graphs/pose_tracking:pose_tracking_gpu_deps"],
|
||||
#)
|
||||
#
|
||||
|
||||
#copperlabs_aar(
|
||||
# name = "copperlabs-pose-api",
|
||||
# srcs = POSE_TRACKING_SRCS,
|
||||
# additional_deps = [
|
||||
# "//mediapipe/java/com/google/mediapipe/solutioncore:solution_base",
|
||||
# "//mediapipe/java/com/google/mediapipe/solutioncore:camera_input",
|
||||
# "@maven//:androidx_annotation_annotation",
|
||||
# ],
|
||||
# gen_libmediapipe = False,
|
||||
#)
|
||||
|
||||
#mediapipe_aar(
|
||||
# name = "copperlabs-pose-landmark",
|
||||
# assets = [
|
||||
# "//mediapipe/modules/pose_landmark:pose_landmark_heavy.tflite",
|
||||
# "//mediapipe/modules/pose_landmark:pose_landmark_full.tflite",
|
||||
# "//mediapipe/modules/pose_landmark:pose_landmark_lite.tflite",
|
||||
# ],
|
||||
# gen_libmediapipe = False,
|
||||
#)
|
||||
|
|
|
@ -24,6 +24,8 @@ import com.google.mediapipe.solutioncore.ImageSolutionResult;
|
|||
import com.google.mediapipe.formats.proto.DetectionProto.Detection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* FaceDetectionResult contains the detected faces, and the input {@link Bitmap} or {@link
|
||||
* TextureFrame}. If not in static image mode, the timestamp field will be set to the timestamp of
|
||||
|
@ -33,6 +35,41 @@ public class PoseTrackingResult extends ImageSolutionResult {
|
|||
private final ImmutableList<Detection> multiPoseDetections;
|
||||
private final ImmutableList<LandmarkProto.Landmark> multiPoseLandmarks;
|
||||
|
||||
public static final int NOSE = 0;
|
||||
public static final int LEFT_EYE_INNER = 1;
|
||||
public static final int LEFT_EYE = 2;
|
||||
public static final int LEFT_EYE_OUTER = 3;
|
||||
public static final int RIGHT_EYE_INNER = 4;
|
||||
public static final int RIGHT_EYE = 5;
|
||||
public static final int RIGHT_EYE_OUTER = 6;
|
||||
public static final int LEFT_EAR = 7;
|
||||
public static final int RIGHT_EAR = 8;
|
||||
public static final int MOUTH_LEFT = 9;
|
||||
public static final int MOUTH_RIGHT = 10;
|
||||
public static final int LEFT_SHOULDER = 11;
|
||||
public static final int RIGHT_SHOULDER = 12;
|
||||
public static final int LEFT_ELBOW = 13;
|
||||
public static final int RIGHT_ELBOW = 14;
|
||||
public static final int LEFT_WRIST = 15;
|
||||
public static final int RIGHT_WRIST = 16;
|
||||
public static final int LEFT_PINKY = 17;
|
||||
public static final int RIGHT_PINKY = 18;
|
||||
public static final int LEFT_INDEX = 19;
|
||||
public static final int RIGHT_INDEX = 20;
|
||||
public static final int LEFT_THUMB = 21;
|
||||
public static final int RIGHT_THUMB = 22;
|
||||
public static final int LEFT_HIP = 23;
|
||||
public static final int RIGHT_HIP = 24;
|
||||
public static final int LEFT_KNEE = 25;
|
||||
public static final int RIGHT_KNEE = 26;
|
||||
public static final int LEFT_ANKLE = 27;
|
||||
public static final int RIGHT_ANKLE = 28;
|
||||
public static final int LEFT_HEEL = 29;
|
||||
public static final int RIGHT_HEEL = 30;
|
||||
public static final int LEFT_FOOT = 31;
|
||||
public static final int RIGHT_FOOT = 32;
|
||||
|
||||
|
||||
PoseTrackingResult(
|
||||
ImmutableList<Detection> multiPoseDetections,ImmutableList<LandmarkProto.Landmark> multiPoseLandmarks, Packet imagePacket, long timestamp) {
|
||||
this.multiPoseDetections = multiPoseDetections;
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
// Copyright 2021 The MediaPipe Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.mediapipe.solutions.posetracking;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
|
||||
import com.google.mediapipe.formats.proto.DetectionProto.Detection;
|
||||
import com.google.mediapipe.solutioncore.ResultGlRenderer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
|
||||
|
||||
/** A custom implementation of {@link ResultGlRenderer} to render {@link PoseTrackingResult}. */
|
||||
public class PoseTrackingResultGlRenderer implements ResultGlRenderer<PoseTrackingResult> {
|
||||
private static final String TAG = "PoseTrackingResultGlRenderer";
|
||||
|
||||
private static final float[] KEYPOINT_COLOR = new float[] {1f, 0f, 0f, 1f};
|
||||
private static final float KEYPOINT_SIZE = 16f;
|
||||
private static final float[] BBOX_COLOR = new float[] {0f, 1f, 0f, 1f};
|
||||
private static final int BBOX_THICKNESS = 8;
|
||||
private static final String VERTEX_SHADER =
|
||||
"uniform mat4 uProjectionMatrix;\n"
|
||||
+ "uniform float uPointSize;\n"
|
||||
+ "attribute vec4 vPosition;\n"
|
||||
+ "void main() {\n"
|
||||
+ " gl_Position = uProjectionMatrix * vPosition;\n"
|
||||
+ " gl_PointSize = uPointSize;"
|
||||
+ "}";
|
||||
private static final String FRAGMENT_SHADER =
|
||||
"precision mediump float;\n"
|
||||
+ "uniform vec4 uColor;\n"
|
||||
+ "void main() {\n"
|
||||
+ " gl_FragColor = uColor;\n"
|
||||
+ "}";
|
||||
private int program;
|
||||
private int positionHandle;
|
||||
private int pointSizeHandle;
|
||||
private int projectionMatrixHandle;
|
||||
private int colorHandle;
|
||||
|
||||
private int loadShader(int type, String shaderCode) {
|
||||
int shader = GLES20.glCreateShader(type);
|
||||
GLES20.glShaderSource(shader, shaderCode);
|
||||
GLES20.glCompileShader(shader);
|
||||
return shader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRendering() {
|
||||
program = GLES20.glCreateProgram();
|
||||
int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, VERTEX_SHADER);
|
||||
int fragmentShader = loadShader(GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
|
||||
GLES20.glAttachShader(program, vertexShader);
|
||||
GLES20.glAttachShader(program, fragmentShader);
|
||||
GLES20.glLinkProgram(program);
|
||||
positionHandle = GLES20.glGetAttribLocation(program, "vPosition");
|
||||
pointSizeHandle = GLES20.glGetUniformLocation(program, "uPointSize");
|
||||
projectionMatrixHandle = GLES20.glGetUniformLocation(program, "uProjectionMatrix");
|
||||
colorHandle = GLES20.glGetUniformLocation(program, "uColor");
|
||||
}
|
||||
|
||||
/**
|
||||
* No needed anymore to be deleted
|
||||
* **/
|
||||
@Override
|
||||
public void renderResult(PoseTrackingResult result, float[] projectionMatrix) {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GLES20.glUseProgram(program);
|
||||
GLES20.glUniformMatrix4fv(projectionMatrixHandle, 1, false, projectionMatrix, 0);
|
||||
// GLES20.glUniform1f(pointSizeHandle, KEYPOINT_SIZE);
|
||||
// int numDetectedFaces = result.multiPoseTrackings().size();
|
||||
// for (int i = 0; i < numDetectedFaces; ++i) {
|
||||
// drawDetection(result.multiPoseTrackings().get(i));
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the shader program.
|
||||
*
|
||||
* <p>This is only necessary if one wants to release the program while keeping the context around.
|
||||
*/
|
||||
public void release() {
|
||||
GLES20.glDeleteProgram(program);
|
||||
}
|
||||
/**
|
||||
* Not needed anymore, to be cleaned
|
||||
* */
|
||||
private void drawDetection(Detection detection) {
|
||||
|
||||
if (!detection.hasLocationData()) {
|
||||
return;
|
||||
}
|
||||
// Draw keypoints.
|
||||
// float[] points = new float[FaceKeypoint.NUM_KEY_POINTS * 2];
|
||||
// for (int i = 0; i < FaceKeypoint.NUM_KEY_POINTS; ++i) {
|
||||
// points[2 * i] = detection.getLocationData().getRelativeKeypoints(i).getX();
|
||||
// points[2 * i + 1] = detection.getLocationData().getRelativeKeypoints(i).getY();
|
||||
// }
|
||||
// GLES20.glUniform4fv(colorHandle, 1, KEYPOINT_COLOR, 0);
|
||||
// FloatBuffer vertexBuffer =
|
||||
// ByteBuffer.allocateDirect(points.length * 4)
|
||||
// .order(ByteOrder.nativeOrder())
|
||||
// .asFloatBuffer()
|
||||
// .put(points);
|
||||
// vertexBuffer.position(0);
|
||||
// GLES20.glEnableVertexAttribArray(positionHandle);
|
||||
// GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
|
||||
// GLES20.glDrawArrays(GLES20.GL_POINTS, 0, FaceKeypoint.NUM_KEY_POINTS);
|
||||
if (!detection.getLocationData().hasRelativeBoundingBox()) {
|
||||
return;
|
||||
}
|
||||
// Draw bounding box.
|
||||
// float left = detection.getLocationData().getRelativeBoundingBox().getXmin();
|
||||
// float top = detection.getLocationData().getRelativeBoundingBox().getYmin();
|
||||
// float right = left + detection.getLocationData().getRelativeBoundingBox().getWidth();
|
||||
// float bottom = top + detection.getLocationData().getRelativeBoundingBox().getHeight();
|
||||
// drawLine(top, left, top, right);
|
||||
// drawLine(bottom, left, bottom, right);
|
||||
// drawLine(top, left, bottom, left);
|
||||
// drawLine(top, right, bottom, right);
|
||||
}
|
||||
|
||||
private void drawLine(float y1, float x1, float y2, float x2) {
|
||||
GLES20.glUniform4fv(colorHandle, 1, BBOX_COLOR, 0);
|
||||
GLES20.glLineWidth(BBOX_THICKNESS);
|
||||
float[] vertex = {x1, y1, x2, y2};
|
||||
FloatBuffer vertexBuffer =
|
||||
ByteBuffer.allocateDirect(vertex.length * 4)
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.asFloatBuffer()
|
||||
.put(vertex);
|
||||
vertexBuffer.position(0);
|
||||
GLES20.glEnableVertexAttribArray(positionHandle);
|
||||
GLES20.glVertexAttribPointer(positionHandle, 2, GLES20.GL_FLOAT, false, 0, vertexBuffer);
|
||||
GLES20.glDrawArrays(GLES20.GL_LINES, 0, 2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,347 @@
|
|||
# Copyright 2019-2020 The MediaPipe Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Generates Copperlab AAR including different variants of .so in jni folder.
|
||||
|
||||
Usage:
|
||||
|
||||
Creates a new copperlabs_aar() target in a BUILD file. For example,
|
||||
putting the following code into mediapipe/examples/android/aar_demo/BUILD.
|
||||
|
||||
```
|
||||
load("//mediapipe/java/com/google/mediapipe:mediapipe_aar.bzl", "mediapipe_aar")
|
||||
|
||||
mediapipe_aar(
|
||||
name = "demo",
|
||||
calculators = ["//mediapipe/calculators/core:pass_through_calculator"],
|
||||
)
|
||||
```
|
||||
|
||||
Then, runs the following Bazel command to generate the aar.
|
||||
|
||||
```
|
||||
$ bazel build --strip=always -s -c opt \
|
||||
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain \
|
||||
--fat_apk_cpu=arm64-v8a,armeabi-v7a \
|
||||
mediapipe/examples/android/aar_demo:demo.aar
|
||||
```
|
||||
|
||||
Finally, imports the aar into Android Studio.
|
||||
|
||||
"""
|
||||
|
||||
load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library")
|
||||
|
||||
def copperlabs_aar(
|
||||
name,
|
||||
srcs = [],
|
||||
gen_libmediapipe = True,
|
||||
calculators = [],
|
||||
assets = [],
|
||||
assets_dir = "",
|
||||
additional_deps = []):
|
||||
"""Generates MediaPipe android archive library.
|
||||
|
||||
Args:
|
||||
name: the name of the aar.
|
||||
srcs: the additional java source code to be added into the android library.
|
||||
gen_libmediapipe: whether to generate libmediapipe_jni.so. Default to True.
|
||||
calculators: the calculator libraries to be compiled into the jni library.
|
||||
assets: additional assets to be included into the archive.
|
||||
assets_dir: path where the assets will the packaged.
|
||||
"""
|
||||
|
||||
# When "--define EXCLUDE_OPENCV_SO_LIB=1" is set in the build command,
|
||||
# the OpenCV so libraries will be excluded from the AAR package to
|
||||
# save the package size.
|
||||
native.config_setting(
|
||||
name = "exclude_opencv_so_lib",
|
||||
define_values = {
|
||||
"EXCLUDE_OPENCV_SO_LIB": "1",
|
||||
},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
# When "--define ENABLE_STATS_LOGGING=1" is set in the build command,
|
||||
# the solution stats logging component will be added into the AAR.
|
||||
# This flag is for internal use only.
|
||||
native.config_setting(
|
||||
name = "enable_stats_logging",
|
||||
define_values = {
|
||||
"ENABLE_STATS_LOGGING": "1",
|
||||
},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
_mediapipe_jni(
|
||||
name = name + "_jni",
|
||||
gen_libmediapipe = gen_libmediapipe,
|
||||
calculators = calculators,
|
||||
)
|
||||
|
||||
_mediapipe_proto(
|
||||
name = name + "_proto",
|
||||
)
|
||||
|
||||
native.genrule(
|
||||
name = name + "_aar_manifest_generator",
|
||||
outs = ["AndroidManifest.xml"],
|
||||
cmd = """
|
||||
cat > $(OUTS) <<EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.mediapipe">
|
||||
<uses-sdk
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="27" />
|
||||
</manifest>
|
||||
EOF
|
||||
""",
|
||||
)
|
||||
|
||||
android_library(
|
||||
name = name + "_android_lib",
|
||||
srcs = srcs + [
|
||||
"//mediapipe/java/com/google/mediapipe/components:java_src",
|
||||
"//mediapipe/java/com/google/mediapipe/framework:java_src",
|
||||
"//mediapipe/java/com/google/mediapipe/glutil:java_src",
|
||||
"com/google/mediapipe/formats/annotation/proto/RasterizationProto.java",
|
||||
"com/google/mediapipe/formats/proto/ClassificationProto.java",
|
||||
"com/google/mediapipe/formats/proto/DetectionProto.java",
|
||||
"com/google/mediapipe/formats/proto/LandmarkProto.java",
|
||||
"com/google/mediapipe/formats/proto/LocationDataProto.java",
|
||||
"com/google/mediapipe/proto/CalculatorProto.java",
|
||||
] +
|
||||
select({
|
||||
"//conditions:default": [],
|
||||
"enable_stats_logging": [
|
||||
"com/google/mediapipe/proto/MediaPipeLoggingProto.java",
|
||||
"com/google/mediapipe/proto/MediaPipeLoggingEnumsProto.java",
|
||||
],
|
||||
}),
|
||||
manifest = "AndroidManifest.xml",
|
||||
proguard_specs = ["//mediapipe/java/com/google/mediapipe/framework:proguard.pgcfg"],
|
||||
deps = [
|
||||
":" + name + "_jni_cc_lib",
|
||||
"//mediapipe/framework:calculator_java_proto_lite",
|
||||
"//mediapipe/framework:calculator_profile_java_proto_lite",
|
||||
"//mediapipe/framework:calculator_options_java_proto_lite",
|
||||
"//mediapipe/framework:mediapipe_options_java_proto_lite",
|
||||
"//mediapipe/framework:packet_factory_java_proto_lite",
|
||||
"//mediapipe/framework:packet_generator_java_proto_lite",
|
||||
"//mediapipe/framework:status_handler_java_proto_lite",
|
||||
"//mediapipe/framework:stream_handler_java_proto_lite",
|
||||
"//mediapipe/framework/tool:calculator_graph_template_java_proto_lite",
|
||||
"//mediapipe/java/com/google/mediapipe/components:android_components",
|
||||
"//mediapipe/java/com/google/mediapipe/components:android_camerax_helper",
|
||||
"//mediapipe/java/com/google/mediapipe/framework:android_framework",
|
||||
"//mediapipe/java/com/google/mediapipe/glutil",
|
||||
"//third_party:androidx_annotation",
|
||||
"//third_party:androidx_appcompat",
|
||||
"//third_party:androidx_core",
|
||||
"//third_party:androidx_legacy_support_v4",
|
||||
"//third_party:autovalue",
|
||||
"//third_party:camerax_core",
|
||||
"//third_party:camerax_camera2",
|
||||
"//third_party:camerax_lifecycle",
|
||||
"@com_google_protobuf//:protobuf_javalite",
|
||||
"@maven//:com_google_code_findbugs_jsr305",
|
||||
"@maven//:com_google_flogger_flogger",
|
||||
"@maven//:com_google_flogger_flogger_system_backend",
|
||||
"@maven//:com_google_guava_guava",
|
||||
"@maven//:androidx_lifecycle_lifecycle_common",
|
||||
] + select({
|
||||
"//conditions:default": [":" + name + "_jni_opencv_cc_lib"],
|
||||
"//mediapipe/framework/port:disable_opencv": [],
|
||||
"exclude_opencv_so_lib": [],
|
||||
}) + select({
|
||||
"//conditions:default": [],
|
||||
"enable_stats_logging": [
|
||||
"@maven//:com_google_android_datatransport_transport_api",
|
||||
"@maven//:com_google_android_datatransport_transport_backend_cct",
|
||||
"@maven//:com_google_android_datatransport_transport_runtime",
|
||||
],
|
||||
}) + additional_deps,
|
||||
assets = assets,
|
||||
assets_dir = assets_dir,
|
||||
)
|
||||
|
||||
_aar_with_jni(name, name + "_android_lib")
|
||||
|
||||
def _mediapipe_proto(name):
|
||||
"""Generates MediaPipe java proto libraries.
|
||||
|
||||
Args:
|
||||
name: the name of the target.
|
||||
"""
|
||||
_proto_java_src_generator(
|
||||
name = "mediapipe_log_extension_proto",
|
||||
proto_src = "mediapipe/util/analytics/mediapipe_log_extension.proto",
|
||||
java_lite_out = "com/google/mediapipe/proto/MediaPipeLoggingProto.java",
|
||||
srcs = ["//mediapipe/util/analytics:protos_src"],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "mediapipe_logging_enums_proto",
|
||||
proto_src = "mediapipe/util/analytics/mediapipe_logging_enums.proto",
|
||||
java_lite_out = "com/google/mediapipe/proto/MediaPipeLoggingEnumsProto.java",
|
||||
srcs = ["//mediapipe/util/analytics:protos_src"],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "calculator_proto",
|
||||
proto_src = "mediapipe/framework/calculator.proto",
|
||||
java_lite_out = "com/google/mediapipe/proto/CalculatorProto.java",
|
||||
srcs = ["//mediapipe/framework:protos_src"],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "landmark_proto",
|
||||
proto_src = "mediapipe/framework/formats/landmark.proto",
|
||||
java_lite_out = "com/google/mediapipe/formats/proto/LandmarkProto.java",
|
||||
srcs = ["//mediapipe/framework/formats:protos_src"],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "rasterization_proto",
|
||||
proto_src = "mediapipe/framework/formats/annotation/rasterization.proto",
|
||||
java_lite_out = "com/google/mediapipe/formats/annotation/proto/RasterizationProto.java",
|
||||
srcs = ["//mediapipe/framework/formats/annotation:protos_src"],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "location_data_proto",
|
||||
proto_src = "mediapipe/framework/formats/location_data.proto",
|
||||
java_lite_out = "com/google/mediapipe/formats/proto/LocationDataProto.java",
|
||||
srcs = [
|
||||
"//mediapipe/framework/formats:protos_src",
|
||||
"//mediapipe/framework/formats/annotation:protos_src",
|
||||
],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "detection_proto",
|
||||
proto_src = "mediapipe/framework/formats/detection.proto",
|
||||
java_lite_out = "com/google/mediapipe/formats/proto/DetectionProto.java",
|
||||
srcs = [
|
||||
"//mediapipe/framework/formats:protos_src",
|
||||
"//mediapipe/framework/formats/annotation:protos_src",
|
||||
],
|
||||
)
|
||||
|
||||
_proto_java_src_generator(
|
||||
name = "classification_proto",
|
||||
proto_src = "mediapipe/framework/formats/classification.proto",
|
||||
java_lite_out = "com/google/mediapipe/formats/proto/ClassificationProto.java",
|
||||
srcs = [
|
||||
"//mediapipe/framework/formats:protos_src",
|
||||
],
|
||||
)
|
||||
|
||||
def _proto_java_src_generator(name, proto_src, java_lite_out, srcs = []):
|
||||
native.genrule(
|
||||
name = name + "_proto_java_src_generator",
|
||||
srcs = srcs + [
|
||||
"@com_google_protobuf//:lite_well_known_protos",
|
||||
],
|
||||
outs = [java_lite_out],
|
||||
cmd = "$(location @com_google_protobuf//:protoc) " +
|
||||
"--proto_path=. --proto_path=$(GENDIR) " +
|
||||
"--proto_path=$$(pwd)/external/com_google_protobuf/src " +
|
||||
"--java_out=lite:$(GENDIR) " + proto_src + " && " +
|
||||
"mv $(GENDIR)/" + java_lite_out + " $$(dirname $(location " + java_lite_out + "))",
|
||||
tools = [
|
||||
"@com_google_protobuf//:protoc",
|
||||
],
|
||||
)
|
||||
|
||||
def _mediapipe_jni(name, gen_libmediapipe, calculators = []):
|
||||
"""Generates MediaPipe jni library.
|
||||
|
||||
Args:
|
||||
name: the name of the target.
|
||||
gen_libmediapipe: whether to generate libmediapipe_jni.so. Default to True.
|
||||
calculators: the calculator libraries to be compiled into the jni library.
|
||||
"""
|
||||
if gen_libmediapipe:
|
||||
native.cc_binary(
|
||||
name = "libmediapipe_jni.so",
|
||||
linkshared = 1,
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
"//mediapipe/java/com/google/mediapipe/framework/jni:mediapipe_framework_jni",
|
||||
] + calculators,
|
||||
)
|
||||
|
||||
native.cc_library(
|
||||
name = name + "_cc_lib",
|
||||
srcs = [":libmediapipe_jni.so"],
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
native.cc_library(
|
||||
name = name + "_opencv_cc_lib",
|
||||
srcs = select({
|
||||
"//mediapipe:android_arm64": ["@android_opencv//:libopencv_java3_so_arm64-v8a"],
|
||||
"//mediapipe:android_armeabi": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
|
||||
"//mediapipe:android_arm": ["@android_opencv//:libopencv_java3_so_armeabi-v7a"],
|
||||
"//mediapipe:android_x86": ["@android_opencv//:libopencv_java3_so_x86"],
|
||||
"//mediapipe:android_x86_64": ["@android_opencv//:libopencv_java3_so_x86_64"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
alwayslink = 1,
|
||||
)
|
||||
|
||||
def _aar_with_jni(name, android_library):
|
||||
# Generates dummy AndroidManifest.xml for dummy apk usage
|
||||
# (dummy apk is generated by <name>_dummy_app target below)
|
||||
native.genrule(
|
||||
name = name + "_binary_manifest_generator",
|
||||
outs = [name + "_generated_AndroidManifest.xml"],
|
||||
cmd = """
|
||||
cat > $(OUTS) <<EOF
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="dummy.package.for.so">
|
||||
<uses-sdk android:minSdkVersion="21"/>
|
||||
</manifest>
|
||||
EOF
|
||||
""",
|
||||
)
|
||||
|
||||
# Generates dummy apk including .so files.
|
||||
# We extract out .so files and throw away the apk.
|
||||
android_binary(
|
||||
name = name + "_dummy_app",
|
||||
manifest = name + "_generated_AndroidManifest.xml",
|
||||
custom_package = "dummy.package.for.so",
|
||||
multidex = "native",
|
||||
deps = [android_library],
|
||||
)
|
||||
|
||||
native.genrule(
|
||||
name = name,
|
||||
srcs = [android_library + ".aar", name + "_dummy_app_unsigned.apk"],
|
||||
outs = [name + ".aar"],
|
||||
tags = ["manual"],
|
||||
cmd = """
|
||||
cp $(location {}.aar) $(location :{}.aar)
|
||||
chmod +w $(location :{}.aar)
|
||||
origdir=$$PWD
|
||||
cd $$(mktemp -d)
|
||||
unzip $$origdir/$(location :{}_dummy_app_unsigned.apk) "lib/*"
|
||||
cp -r lib jni
|
||||
zip -r $$origdir/$(location :{}.aar) jni/*/*.so
|
||||
""".format(android_library, name, name, name, name),
|
||||
)
|
|
@ -140,6 +140,11 @@ node {
|
|||
input_side_packet: "MODEL:model"
|
||||
input_stream: "TENSORS:input_tensors"
|
||||
output_stream: "TENSORS:output_tensors"
|
||||
options: {
|
||||
[mediapipe.InferenceCalculatorOptions.ext] {
|
||||
delegate { gpu { use_advanced_gpu_api: true } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Decodes the tensors into the corresponding landmark and segmentation mask
|
||||
|
|