Skip to content

Commit 710fb3d

Browse files
MediaPipe Teamjqtang
MediaPipe Team
authored and
jqtang
committed
Project import generated by Copybara.
GitOrigin-RevId: 1610e588e497817fae2d9a458093ab6a370e2972
1 parent b899d17 commit 710fb3d

File tree

158 files changed

+10139
-1603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+10139
-1603
lines changed

Diff for: WORKSPACE

+21-4
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ load("@rules_jvm_external//:defs.bzl", "maven_install")
331331
maven_install(
332332
artifacts = [
333333
"androidx.concurrent:concurrent-futures:1.0.0-alpha03",
334-
"androidx.lifecycle:lifecycle-common:2.2.0",
334+
"androidx.lifecycle:lifecycle-common:2.3.1",
335+
"androidx.activity:activity:1.2.2",
336+
"androidx.fragment:fragment:1.3.4",
335337
"androidx.annotation:annotation:aar:1.1.0",
336338
"androidx.appcompat:appcompat:aar:1.1.0-rc01",
337339
"androidx.camera:camera-core:1.0.0-beta10",
@@ -376,9 +378,9 @@ http_archive(
376378
)
377379

378380
# Tensorflow repo should always go after the other external dependencies.
379-
# 2021-06-07
380-
_TENSORFLOW_GIT_COMMIT = "700533808e6016dc458bb2eeecfca4babfc482ec"
381-
_TENSORFLOW_SHA256 = "b6edd7f4039bfc19f3e77594ecff558ba620091d0dc48181484b3d9085026126"
381+
# 2021-07-29
382+
_TENSORFLOW_GIT_COMMIT = "52a2905cbc21034766c08041933053178c5d10e3"
383+
_TENSORFLOW_SHA256 = "06d4691bcdb700f3275fa0971a1585221c2b9f3dffe867963be565a6643d7f56"
382384
http_archive(
383385
name = "org_tensorflow",
384386
urls = [
@@ -399,3 +401,18 @@ load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3")
399401
tf_workspace3()
400402
load("@org_tensorflow//tensorflow:workspace2.bzl", "tf_workspace2")
401403
tf_workspace2()
404+
405+
# Edge TPU
406+
http_archive(
407+
name = "libedgetpu",
408+
sha256 = "14d5527a943a25bc648c28a9961f954f70ba4d79c0a9ca5ae226e1831d72fe80",
409+
strip_prefix = "libedgetpu-3164995622300286ef2bb14d7fdc2792dae045b7",
410+
urls = [
411+
"https://github.com/google-coral/libedgetpu/archive/3164995622300286ef2bb14d7fdc2792dae045b7.tar.gz"
412+
],
413+
)
414+
load("@libedgetpu//:workspace.bzl", "libedgetpu_dependencies")
415+
libedgetpu_dependencies()
416+
417+
load("@coral_crosstool//:configure.bzl", "cc_crosstool")
418+
cc_crosstool(name = "crosstool")

Diff for: docs/getting_started/android.md

+7-120
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ nav_order: 1
1616

1717
Please follow instructions below to build Android example apps in the supported
1818
MediaPipe [solutions](../solutions/solutions.md). To learn more about these
19-
example apps, start from [Hello World! on Android](./hello_world_android.md). To
20-
incorporate MediaPipe into an existing Android Studio project, see these
21-
[instructions](./android_archive_library.md) that use Android Archive (AAR) and
22-
Gradle.
19+
example apps, start from [Hello World! on Android](./hello_world_android.md).
2320

24-
## Building Android example apps
21+
To incorporate MediaPipe into Android Studio projects, see these
22+
[instructions](./android_solutions.md) to use the MediaPipe Android Solution
23+
APIs (currently in alpha) that are now available in
24+
[Google's Maven Repository](https://maven.google.com/web/index.html?#com.google.mediapipe).
25+
26+
## Building Android example apps with Bazel
2527

2628
### Prerequisite
2729

@@ -51,16 +53,6 @@ $YOUR_INTENDED_API_LEVEL` in android_ndk_repository() and/or
5153
android_sdk_repository() in the
5254
[`WORKSPACE`](https://github.com/google/mediapipe/blob/master/WORKSPACE) file.
5355

54-
Please verify all the necessary packages are installed.
55-
56-
* Android SDK Platform API Level 28 or 29
57-
* Android SDK Build-Tools 28 or 29
58-
* Android SDK Platform-Tools 28 or 29
59-
* Android SDK Tools 26.1.1
60-
* Android NDK 19c or above
61-
62-
### Option 1: Build with Bazel in Command Line
63-
6456
Tip: You can run this
6557
[script](https://github.com/google/mediapipe/blob/master/build_android_examples.sh)
6658
to build (and install) all MediaPipe Android example apps.
@@ -84,108 +76,3 @@ to build (and install) all MediaPipe Android example apps.
8476
```bash
8577
adb install bazel-bin/mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu/handtrackinggpu.apk
8678
```
87-
88-
### Option 2: Build with Bazel in Android Studio
89-
90-
The MediaPipe project can be imported into Android Studio using the Bazel
91-
plugins. This allows the MediaPipe examples to be built and modified in Android
92-
Studio.
93-
94-
To incorporate MediaPipe into an existing Android Studio project, see these
95-
[instructions](./android_archive_library.md) that use Android Archive (AAR) and
96-
Gradle.
97-
98-
The steps below use Android Studio 3.5 to build and install a MediaPipe example
99-
app:
100-
101-
1. Install and launch Android Studio 3.5.
102-
103-
2. Select `Configure` -> `SDK Manager` -> `SDK Platforms`.
104-
105-
* Verify that Android SDK Platform API Level 28 or 29 is installed.
106-
* Take note of the Android SDK Location, e.g.,
107-
`/usr/local/home/Android/Sdk`.
108-
109-
3. Select `Configure` -> `SDK Manager` -> `SDK Tools`.
110-
111-
* Verify that Android SDK Build-Tools 28 or 29 is installed.
112-
* Verify that Android SDK Platform-Tools 28 or 29 is installed.
113-
* Verify that Android SDK Tools 26.1.1 is installed.
114-
* Verify that Android NDK 19c or above is installed.
115-
* Take note of the Android NDK Location, e.g.,
116-
`/usr/local/home/Android/Sdk/ndk-bundle` or
117-
`/usr/local/home/Android/Sdk/ndk/20.0.5594570`.
118-
119-
4. Set environment variables `$ANDROID_HOME` and `$ANDROID_NDK_HOME` to point
120-
to the installed SDK and NDK.
121-
122-
```bash
123-
export ANDROID_HOME=/usr/local/home/Android/Sdk
124-
125-
# If the NDK libraries are installed by a previous version of Android Studio, do
126-
export ANDROID_NDK_HOME=/usr/local/home/Android/Sdk/ndk-bundle
127-
# If the NDK libraries are installed by Android Studio 3.5, do
128-
export ANDROID_NDK_HOME=/usr/local/home/Android/Sdk/ndk/<version number>
129-
```
130-
131-
5. Select `Configure` -> `Plugins` to install `Bazel`.
132-
133-
6. On Linux, select `File` -> `Settings` -> `Bazel settings`. On macos, select
134-
`Android Studio` -> `Preferences` -> `Bazel settings`. Then, modify `Bazel
135-
binary location` to be the same as the output of `$ which bazel`.
136-
137-
7. Select `Import Bazel Project`.
138-
139-
* Select `Workspace`: `/path/to/mediapipe` and select `Next`.
140-
* Select `Generate from BUILD file`: `/path/to/mediapipe/BUILD` and select
141-
`Next`.
142-
* Modify `Project View` to be the following and select `Finish`.
143-
144-
```
145-
directories:
146-
# read project settings, e.g., .bazelrc
147-
.
148-
-mediapipe/objc
149-
-mediapipe/examples/ios
150-
151-
targets:
152-
//mediapipe/examples/android/...:all
153-
//mediapipe/java/...:all
154-
155-
android_sdk_platform: android-29
156-
157-
sync_flags:
158-
--host_crosstool_top=@bazel_tools//tools/cpp:toolchain
159-
```
160-
161-
8. Select `Bazel` -> `Sync` -> `Sync project with Build files`.
162-
163-
Note: Even after doing step 4, if you still see the error: `"no such package
164-
'@androidsdk//': Either the path attribute of android_sdk_repository or the
165-
ANDROID_HOME environment variable must be set."`, please modify the
166-
[`WORKSPACE`](https://github.com/google/mediapipe/blob/master/WORKSPACE)
167-
file to point to your SDK and NDK library locations, as below:
168-
169-
```
170-
android_sdk_repository(
171-
name = "androidsdk",
172-
path = "/path/to/android/sdk"
173-
)
174-
175-
android_ndk_repository(
176-
name = "androidndk",
177-
path = "/path/to/android/ndk"
178-
)
179-
```
180-
181-
9. Connect an Android device to the workstation.
182-
183-
10. Select `Run...` -> `Edit Configurations...`.
184-
185-
* Select `Templates` -> `Bazel Command`.
186-
* Enter Target Expression:
187-
`//mediapipe/examples/android/src/java/com/google/mediapipe/apps/handtrackinggpu:handtrackinggpu`
188-
* Enter Bazel command: `mobile-install`.
189-
* Enter Bazel flags: `-c opt --config=android_arm64`.
190-
* Press the `[+]` button to add the new configuration.
191-
* Select `Run` to run the example app on the connected Android device.

Diff for: docs/getting_started/android_archive_library.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ layout: default
33
title: MediaPipe Android Archive
44
parent: MediaPipe on Android
55
grand_parent: Getting Started
6-
nav_order: 2
6+
nav_order: 3
77
---
88

99
# MediaPipe Android Archive

Diff for: docs/getting_started/android_solutions.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
layout: default
3+
title: Android Solutions
4+
parent: MediaPipe on Android
5+
grand_parent: Getting Started
6+
nav_order: 2
7+
---
8+
9+
# Android Solution APIs
10+
{: .no_toc }
11+
12+
1. TOC
13+
{:toc}
14+
---
15+
16+
Please follow instructions below to use the MediaPipe Solution APIs in Android
17+
Studio projects and build the Android example apps in the supported MediaPipe
18+
[solutions](../solutions/solutions.md).
19+
20+
## Integrate MediaPipe Android Solutions in Android Studio
21+
22+
MediaPipe Android Solution APIs (currently in alpha) are now available in
23+
[Google's Maven Repository](https://maven.google.com/web/index.html?#com.google.mediapipe).
24+
To incorporate MediaPipe Android Solutions into an Android Studio project, add
25+
the following into the project's Gradle dependencies:
26+
27+
```
28+
dependencies {
29+
// MediaPipe solution-core is the foundation of any MediaPipe solutions.
30+
implementation 'com.google.mediapipe:solution-core:latest.release'
31+
// Optional: MediaPipe Hands solution.
32+
implementation 'com.google.mediapipe:hands:latest.release'
33+
// Optional: MediaPipe FaceMesh solution.
34+
implementation 'com.google.mediapipe:facemesh:latest.release'
35+
// MediaPipe deps
36+
implementation 'com.google.flogger:flogger:latest.release'
37+
implementation 'com.google.flogger:flogger-system-backend:latest.release'
38+
implementation 'com.google.guava:guava:27.0.1-android'
39+
implementation 'com.google.protobuf:protobuf-java:3.11.4'
40+
// CameraX core library
41+
def camerax_version = "1.0.0-beta10"
42+
implementation "androidx.camera:camera-core:$camerax_version"
43+
implementation "androidx.camera:camera-camera2:$camerax_version"
44+
implementation "androidx.camera:camera-lifecycle:$camerax_version"
45+
}
46+
```
47+
48+
See the detailed solutions API usage examples for different use cases in the
49+
solution example apps'
50+
[source code](https://github.com/google/mediapipe/tree/master/mediapipe/examples/android/solutions).
51+
If the prebuilt maven packages are not sufficient, building the MediaPipe
52+
Android archive library locally by following these
53+
[instructions](./android_archive_library.md).
54+
55+
## Build solution example apps in Android Studio
56+
57+
1. Open Android Studio Arctic Fox on Linux, macOS, or Windows.
58+
59+
2. Import mediapipe/examples/android/solutions directory into Android Studio.
60+
61+
![Screenshot](../images/import_mp_android_studio_project.png)
62+
63+
3. For Windows users, run `create_win_symlinks.bat` as administrator to create
64+
res directory symlinks.
65+
66+
![Screenshot](../images/run_create_win_symlinks.png)
67+
68+
4. Select "File" -> "Sync Project with Gradle Files" to sync project.
69+
70+
5. Run solution example app in Android Studio.
71+
72+
![Screenshot](../images/run_android_solution_app.png)
73+
74+
6. (Optional) Run solutions on CPU.
75+
76+
MediaPipe solution example apps run the pipeline and the model inference on
77+
GPU by default. If needed, for example to run the apps on Android Emulator,
78+
set the `RUN_ON_GPU` boolean variable to `false` in the app's
79+
MainActivity.java to run the pipeline and the model inference on CPU.

0 commit comments

Comments
 (0)