-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97c3a0c
commit ab9b7a3
Showing
51 changed files
with
3,419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
*.task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# MediaPipe Tasks Holistic Landmark Detection Android Demo | ||
|
||
### Overview | ||
|
||
This is a camera app that continuously detects the body, hand, and face | ||
landmarks in the frames seen by your device's back camera, using a | ||
custom **task** file. | ||
|
||
The task file is downloaded by a Gradle script when you build and run the app. | ||
You don't need to do any additional steps to download task files into the | ||
project explicitly unless you wish to use your own landmark detection task. If | ||
you do use your own task file, place it into the app's assets/tasks directory. | ||
|
||
This application should be run on physical Android devices with a back camera. | ||
|
||
![Holistic Landmarker Demo](screenshot.jpg?raw=true "Holistic Landmarker Demo") | ||
|
||
## Build the demo using Android Studio | ||
|
||
### Prerequisites | ||
|
||
* The **[Android Studio](https://developer.android.com/studio/index.html)** IDE. | ||
This sample has been tested on Android Studio Giraffe. | ||
|
||
* A physical Android device with a minimum OS version of SDK 24 (Android 7.0 - | ||
Nougat) with developer mode enabled. The process of enabling developer mode | ||
may vary by device. | ||
|
||
### Building | ||
|
||
* Open Android Studio. From the Welcome screen, select Open an existing | ||
Android Studio project. | ||
|
||
* From the Open File or Project window that appears, navigate to and select | ||
the mediapipe/examples/holistic_landmarker/android directory. Click OK. You | ||
may | ||
be asked if you trust the project. Select Trust. | ||
|
||
* If it asks you to do a Gradle Sync, click OK. | ||
|
||
* With your Android device connected to your computer and developer mode | ||
enabled, click on the green Run arrow in Android Studio. | ||
|
||
### Models used | ||
|
||
Downloading, extraction, and placing the models into the *assets/tasks* folder | ||
is | ||
managed automatically by the **app/build.gradle.kts** file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import de.undercouch.gradle.tasks.download.Download | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
id("de.undercouch.download") | ||
} | ||
|
||
android { | ||
namespace = "com.google.mediapipe.examples.holisticlandmarker" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
applicationId = "com.google.mediapipe.examples.holisticlandmarker" | ||
minSdk = 24 | ||
targetSdk = 34 | ||
versionCode = 1 | ||
versionName = "1.0" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = "1.8" | ||
} | ||
buildFeatures { | ||
viewBinding = true | ||
} | ||
} | ||
|
||
val downloadTaskFile = tasks.register<Download>("downloadTaskFile") { | ||
src("https://storage.googleapis.com/mediapipe-models/holistic_landmarker/holistic_landmarker/float16/latest/holistic_landmarker.task") | ||
dest("$projectDir/src/main/assets/tasks/holistic_landmarker.task") | ||
overwrite(false) | ||
} | ||
|
||
tasks.named("preBuild") { | ||
dependsOn(downloadTaskFile) | ||
} | ||
|
||
dependencies { | ||
|
||
implementation("androidx.core:core-ktx:1.9.0") | ||
implementation("androidx.appcompat:appcompat:1.6.1") | ||
implementation("com.google.android.material:material:1.10.0") | ||
implementation("androidx.constraintlayout:constraintlayout:2.1.4") | ||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.5") | ||
implementation("androidx.navigation:navigation-ui-ktx:2.7.5") | ||
implementation("androidx.fragment:fragment-ktx:1.6.2") | ||
|
||
// CameraX core library | ||
val cameraxVersion = "1.3.0" | ||
implementation("androidx.camera:camera-core:$cameraxVersion") | ||
// CameraX Camera2 extensions | ||
implementation("androidx.camera:camera-camera2:$cameraxVersion") | ||
// CameraX Lifecycle library | ||
implementation("androidx.camera:camera-lifecycle:$cameraxVersion") | ||
// CameraX View class | ||
implementation("androidx.camera:camera-view:$cameraxVersion") | ||
|
||
implementation("com.google.mediapipe:tasks-vision:0.10.11") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test.ext:junit:1.1.5") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") | ||
} |
21 changes: 21 additions & 0 deletions
21
examples/holistic_landmarker/android/app/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
30 changes: 30 additions & 0 deletions
30
examples/holistic_landmarker/android/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<!-- Declare features --> | ||
<uses-feature android:name="android.hardware.camera" /> | ||
|
||
<!-- Declare permissions --> | ||
<uses-permission android:name="android.permission.CAMERA" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name="com.google.mediapipe.examples.holisticlandmarker.MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Oops, something went wrong.