-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JAVA API][ARM CPU] Add COCO Android ARM demo (update old version) (#924
) * init copy android demo * init copy android demo * update docs * remove redudant files * update docs 2 * remove dirs * update docs 3 * remove docs * update docs * update build.gradle * update AndroidManifest * update * add new files * final fixes * radd spaces * Delete modules/android_demos/coco_detection_android_demo/gradle directory * update docs * fix property * fix docs 3 * finish * finish * Update README.md * Update README.md * Update modules/android_demos/coco_detection_android_demo/README.md Co-authored-by: Anna Likholat <aniali201398@gmail.com> --------- Co-authored-by: Anna Likholat <aniali201398@gmail.com>
- Loading branch information
Showing
15 changed files
with
709 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
modules/android_demos/coco_detection_android_demo/README.md
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,79 @@ | ||
# Coco Detection Android Demo | ||
|
||
![Running result](https://user-images.githubusercontent.com/47499836/189129594-2634e176-5a5b-4051-b713-ae9574a8c3da.png) | ||
|
||
This demo showcases inference of Object Detection network on Android ARM devices using [OpenVINO Java API](https://github.com/openvinotoolkit/openvino_contrib/tree/7239f8201bf18d953298966afd9161cff50b2d38/modules/java_api). | ||
For inference is used `ssd_mobilenet_v2_coco` object detection model. | ||
|
||
## How to run it | ||
|
||
### Build the OpenVINO libraries for Android | ||
|
||
To build the OpenVINO library for an Android system, please follow these step-by-step [instruction](https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/build_android.md) in full. | ||
After successful completion, you can move on to the next step. | ||
|
||
### Re-build the OpenVINO libraries for Java API | ||
_Please save the state of the environment variables_ | ||
|
||
For more information, please refer to [these instructions](../../java_api/README.md) | ||
```sh | ||
# Clone OpenVINO™ contrib repository | ||
git clone --recursive https://github.com/openvinotoolkit/openvino_contrib $OPV_HOME_DIR/openvino_contrib | ||
# Re-configure, created in the previous step, the OpenVINO™ CMake project for Java API | ||
cmake -S $OPV_HOME_DIR/openvino \ | ||
-B $OPV_HOME_DIR/openvino-build \ | ||
-DCMAKE_INSTALL_PREFIX=$OPV_HOME_DIR/openvino-install \ | ||
-DBUILD_java_api=ON \ | ||
-DOPENVINO_EXTRA_MODULES=$OPV_HOME_DIR/openvino_contrib/modules/java_api | ||
# Re-build OpenVINO™ project | ||
cmake --build $OPV_HOME_DIR/openvino-build --parallel | ||
# Re-install OpenVINO™ project | ||
cmake --install $OPV_HOME_DIR/openvino-build | ||
``` | ||
|
||
### Build the OpenVINO JAVA library for Android | ||
For more information, please refer to [these instructions](../../java_api/README.md) | ||
```sh | ||
gradle build --project-dir $OPV_HOME_DIR/openvino_contrib/modules/java_api | ||
``` | ||
|
||
### Preparing a demo to run it | ||
```sh | ||
export ANDROID_DEMO_PATH=$OPV_HOME_DIR/openvino_contrib/modules/android_demos/coco_detection_android_demo | ||
mkdir -p $ANDROID_DEMO_PATH/app/libs | ||
cp $OPV_HOME_DIR/openvino_contrib/modules/java_api/build/libs/* $ANDROID_DEMO_PATH/app/libs/ | ||
mkdir -p $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a | ||
cp -r $OPV_HOME_DIR/openvino-install/runtime/lib/aarch64/* $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a/ | ||
cp -r $OPV_HOME_DIR/one-tbb-install/lib/* $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a/ | ||
cp -r $ANDROID_NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a/ | ||
wget https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-android-sdk.zip --directory-prefix $OPV_HOME_DIR | ||
unzip $OPV_HOME_DIR/opencv-4.10.0-android-sdk.zip -d $OPV_HOME_DIR | ||
cp -r $OPV_HOME_DIR/OpenCV-android-sdk/sdk $ANDROID_DEMO_PATH/OpenCV | ||
``` | ||
|
||
Please rename jar library that project works correct , e.g. | ||
```sh | ||
# Release version can be changed | ||
mv $ANDROID_DEMO_PATH/app/libs/openvino-2024.2-linux-x86_64.jar $ANDROID_DEMO_PATH/app/libs/openvino-java-api.jar | ||
``` | ||
|
||
### Download and convert model | ||
To get a `ssd_mobilenet_v2_coco` model for this demo you should use the Open Model Zoo tools in [these instructions](https://docs.openvino.ai/2024/omz_tools_downloader.html). | ||
|
||
### Import demo project on Android Studio | ||
|
||
- Choose and download [Android Studio](https://developer.android.com/studio) on your PC. | ||
|
||
- Select "File -> Open", and import demo project in `$OPV_HOME_DIR/openvino_contrib/modules/android_demos/coco_detection_android_demo`. | ||
|
||
- Build and run demo | ||
|
||
> The first time when you run the demo application on your device, your need to grant camera permission. Then run it again. | ||
|
||
> To build the project correctly, you should write in OpenCV `build.gradle` file `kotlinOptions` parameter same as current project's `build.gradle` file | ||
### Application Output | ||
The demonstration is expected to include real-time inferencing from the camera stream. This means that the system will continuously analyze and process video data from the camera in real-time, providing immediate insights and responses based on the live feed. |
71 changes: 71 additions & 0 deletions
71
modules/android_demos/coco_detection_android_demo/app/build.gradle
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,71 @@ | ||
plugins { | ||
alias(libs.plugins.android.application) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
} | ||
|
||
android { | ||
namespace 'org.intel.openvino' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
applicationId "org.intel.openvino" | ||
minSdk 30 | ||
targetSdk 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
vectorDrawables { | ||
useSupportLibrary true | ||
} | ||
ndk { abiFilters "arm64-v8a" } | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled 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 { | ||
compose true | ||
} | ||
composeOptions { | ||
kotlinCompilerExtensionVersion '1.5.1' | ||
} | ||
packaging { | ||
resources { | ||
excludes += '/META-INF/{AL2.0,LGPL2.1}' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation libs.androidx.core.ktx | ||
implementation libs.androidx.lifecycle.runtime.ktx | ||
implementation libs.androidx.activity.compose | ||
implementation platform(libs.androidx.compose.bom) | ||
implementation libs.androidx.ui | ||
implementation libs.androidx.ui.graphics | ||
implementation libs.androidx.ui.tooling.preview | ||
implementation libs.androidx.material3 | ||
implementation libs.androidx.constraintlayout | ||
implementation 'com.google.android.material:material:1.5.0' | ||
testImplementation libs.junit | ||
androidTestImplementation libs.androidx.junit | ||
androidTestImplementation libs.androidx.espresso.core | ||
androidTestImplementation platform(libs.androidx.compose.bom) | ||
androidTestImplementation libs.androidx.ui.test.junit4 | ||
debugImplementation libs.androidx.ui.tooling | ||
debugImplementation libs.androidx.ui.test.manifest | ||
implementation project(':OpenCV') | ||
implementation files('libs/openvino-java-api.jar') | ||
} |
27 changes: 27 additions & 0 deletions
27
modules/android_demos/coco_detection_android_demo/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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.intel.openvino"> | ||
<uses-feature | ||
android:name="android.hardware.camera" | ||
android:required="false" /> | ||
<uses-permission android:name="android.permission.CAMERA"/> | ||
<!-- Grant the permission to external libraries --> | ||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:extractNativeLibs="true" | ||
android:theme="@style/Theme.CocoDetectionAndroidDemo"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true" | ||
android:screenOrientation="landscape"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
92 changes: 92 additions & 0 deletions
92
modules/android_demos/coco_detection_android_demo/app/src/main/assets/labels.txt
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,92 @@ | ||
background | ||
person | ||
bicycle | ||
car | ||
motorcycle | ||
airplane | ||
bus | ||
train | ||
truck | ||
boat | ||
traffic light | ||
fire hydrant | ||
street sign | ||
stop sign | ||
parking meter | ||
bench | ||
bird | ||
cat | ||
dog | ||
horse | ||
sheep | ||
cow | ||
elephant | ||
bear | ||
zebra | ||
giraffe | ||
hat | ||
backpack | ||
umbrella | ||
shoe | ||
eye glasses | ||
handbag | ||
tie | ||
suitcase | ||
frisbee | ||
skis | ||
snowboard | ||
sports ball | ||
kite | ||
baseball bat | ||
baseball glove | ||
skateboard | ||
surfboard | ||
tennis racket | ||
bottle | ||
plate | ||
wine glass | ||
cup | ||
fork | ||
knife | ||
spoon | ||
bowl | ||
banana | ||
apple | ||
sandwich | ||
orange | ||
broccoli | ||
carrot | ||
hot dog | ||
pizza | ||
donut | ||
cake | ||
chair | ||
couch | ||
potted plant | ||
bed | ||
mirror | ||
dining table | ||
window | ||
desk | ||
toilet | ||
door | ||
tv | ||
laptop | ||
mouse | ||
remote | ||
keyboard | ||
cell phone | ||
microwave | ||
oven | ||
toaster | ||
sink | ||
refrigerator | ||
blender | ||
book | ||
clock | ||
vase | ||
scissors | ||
teddy bear | ||
hair drier | ||
toothbrush | ||
hair brush |
Oops, something went wrong.