Skip to content

Commit e6eb43a

Browse files
allneslikholat
andauthored
[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>
1 parent a508f97 commit e6eb43a

File tree

15 files changed

+709
-0
lines changed

15 files changed

+709
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Coco Detection Android Demo
2+
3+
![Running result](https://user-images.githubusercontent.com/47499836/189129594-2634e176-5a5b-4051-b713-ae9574a8c3da.png)
4+
5+
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).
6+
For inference is used `ssd_mobilenet_v2_coco` object detection model.
7+
8+
## How to run it
9+
10+
### Build the OpenVINO libraries for Android
11+
12+
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.
13+
After successful completion, you can move on to the next step.
14+
15+
### Re-build the OpenVINO libraries for Java API
16+
_Please save the state of the environment variables_
17+
18+
For more information, please refer to [these instructions](../../java_api/README.md)
19+
```sh
20+
# Clone OpenVINO™ contrib repository
21+
git clone --recursive https://github.com/openvinotoolkit/openvino_contrib $OPV_HOME_DIR/openvino_contrib
22+
# Re-configure, created in the previous step, the OpenVINO™ CMake project for Java API
23+
cmake -S $OPV_HOME_DIR/openvino \
24+
-B $OPV_HOME_DIR/openvino-build \
25+
-DCMAKE_INSTALL_PREFIX=$OPV_HOME_DIR/openvino-install \
26+
-DBUILD_java_api=ON \
27+
-DOPENVINO_EXTRA_MODULES=$OPV_HOME_DIR/openvino_contrib/modules/java_api
28+
# Re-build OpenVINO™ project
29+
cmake --build $OPV_HOME_DIR/openvino-build --parallel
30+
# Re-install OpenVINO™ project
31+
cmake --install $OPV_HOME_DIR/openvino-build
32+
```
33+
34+
### Build the OpenVINO JAVA library for Android
35+
For more information, please refer to [these instructions](../../java_api/README.md)
36+
```sh
37+
gradle build --project-dir $OPV_HOME_DIR/openvino_contrib/modules/java_api
38+
```
39+
40+
### Preparing a demo to run it
41+
```sh
42+
export ANDROID_DEMO_PATH=$OPV_HOME_DIR/openvino_contrib/modules/android_demos/coco_detection_android_demo
43+
mkdir -p $ANDROID_DEMO_PATH/app/libs
44+
cp $OPV_HOME_DIR/openvino_contrib/modules/java_api/build/libs/* $ANDROID_DEMO_PATH/app/libs/
45+
46+
mkdir -p $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a
47+
cp -r $OPV_HOME_DIR/openvino-install/runtime/lib/aarch64/* $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a/
48+
cp -r $OPV_HOME_DIR/one-tbb-install/lib/* $ANDROID_DEMO_PATH/app/src/main/jniLibs/arm64-v8a/
49+
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/
50+
51+
wget https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-android-sdk.zip --directory-prefix $OPV_HOME_DIR
52+
unzip $OPV_HOME_DIR/opencv-4.10.0-android-sdk.zip -d $OPV_HOME_DIR
53+
cp -r $OPV_HOME_DIR/OpenCV-android-sdk/sdk $ANDROID_DEMO_PATH/OpenCV
54+
```
55+
56+
Please rename jar library that project works correct , e.g.
57+
```sh
58+
# Release version can be changed
59+
mv $ANDROID_DEMO_PATH/app/libs/openvino-2024.2-linux-x86_64.jar $ANDROID_DEMO_PATH/app/libs/openvino-java-api.jar
60+
```
61+
62+
### Download and convert model
63+
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).
64+
65+
### Import demo project on Android Studio
66+
67+
- Choose and download [Android Studio](https://developer.android.com/studio) on your PC.
68+
69+
- Select "File -> Open", and import demo project in `$OPV_HOME_DIR/openvino_contrib/modules/android_demos/coco_detection_android_demo`.
70+
71+
- Build and run demo
72+
73+
> The first time when you run the demo application on your device, your need to grant camera permission. Then run it again.
74+
75+
> To build the project correctly, you should write in OpenCV `build.gradle` file `kotlinOptions` parameter same as current project's `build.gradle` file
76+
77+
### Application Output
78+
79+
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.jetbrains.kotlin.android)
4+
}
5+
6+
android {
7+
namespace 'org.intel.openvino'
8+
compileSdk 34
9+
10+
defaultConfig {
11+
applicationId "org.intel.openvino"
12+
minSdk 30
13+
targetSdk 34
14+
versionCode 1
15+
versionName "1.0"
16+
17+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18+
vectorDrawables {
19+
useSupportLibrary true
20+
}
21+
ndk { abiFilters "arm64-v8a" }
22+
}
23+
24+
buildTypes {
25+
release {
26+
minifyEnabled false
27+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
28+
}
29+
}
30+
compileOptions {
31+
sourceCompatibility JavaVersion.VERSION_1_8
32+
targetCompatibility JavaVersion.VERSION_1_8
33+
}
34+
kotlinOptions {
35+
jvmTarget = '1.8'
36+
}
37+
buildFeatures {
38+
compose true
39+
}
40+
composeOptions {
41+
kotlinCompilerExtensionVersion '1.5.1'
42+
}
43+
packaging {
44+
resources {
45+
excludes += '/META-INF/{AL2.0,LGPL2.1}'
46+
}
47+
}
48+
}
49+
50+
dependencies {
51+
52+
implementation libs.androidx.core.ktx
53+
implementation libs.androidx.lifecycle.runtime.ktx
54+
implementation libs.androidx.activity.compose
55+
implementation platform(libs.androidx.compose.bom)
56+
implementation libs.androidx.ui
57+
implementation libs.androidx.ui.graphics
58+
implementation libs.androidx.ui.tooling.preview
59+
implementation libs.androidx.material3
60+
implementation libs.androidx.constraintlayout
61+
implementation 'com.google.android.material:material:1.5.0'
62+
testImplementation libs.junit
63+
androidTestImplementation libs.androidx.junit
64+
androidTestImplementation libs.androidx.espresso.core
65+
androidTestImplementation platform(libs.androidx.compose.bom)
66+
androidTestImplementation libs.androidx.ui.test.junit4
67+
debugImplementation libs.androidx.ui.tooling
68+
debugImplementation libs.androidx.ui.test.manifest
69+
implementation project(':OpenCV')
70+
implementation files('libs/openvino-java-api.jar')
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.intel.openvino">
4+
<uses-feature
5+
android:name="android.hardware.camera"
6+
android:required="false" />
7+
<uses-permission android:name="android.permission.CAMERA"/>
8+
<!-- Grant the permission to external libraries -->
9+
<application
10+
android:allowBackup="true"
11+
android:label="@string/app_name"
12+
android:supportsRtl="true"
13+
android:extractNativeLibs="true"
14+
android:theme="@style/Theme.CocoDetectionAndroidDemo">
15+
<activity
16+
android:name=".MainActivity"
17+
android:exported="true"
18+
android:screenOrientation="landscape">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
<category android:name="android.intent.category.LAUNCHER" />
23+
</intent-filter>
24+
</activity>
25+
</application>
26+
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
background
2+
person
3+
bicycle
4+
car
5+
motorcycle
6+
airplane
7+
bus
8+
train
9+
truck
10+
boat
11+
traffic light
12+
fire hydrant
13+
street sign
14+
stop sign
15+
parking meter
16+
bench
17+
bird
18+
cat
19+
dog
20+
horse
21+
sheep
22+
cow
23+
elephant
24+
bear
25+
zebra
26+
giraffe
27+
hat
28+
backpack
29+
umbrella
30+
shoe
31+
eye glasses
32+
handbag
33+
tie
34+
suitcase
35+
frisbee
36+
skis
37+
snowboard
38+
sports ball
39+
kite
40+
baseball bat
41+
baseball glove
42+
skateboard
43+
surfboard
44+
tennis racket
45+
bottle
46+
plate
47+
wine glass
48+
cup
49+
fork
50+
knife
51+
spoon
52+
bowl
53+
banana
54+
apple
55+
sandwich
56+
orange
57+
broccoli
58+
carrot
59+
hot dog
60+
pizza
61+
donut
62+
cake
63+
chair
64+
couch
65+
potted plant
66+
bed
67+
mirror
68+
dining table
69+
window
70+
desk
71+
toilet
72+
door
73+
tv
74+
laptop
75+
mouse
76+
remote
77+
keyboard
78+
cell phone
79+
microwave
80+
oven
81+
toaster
82+
sink
83+
refrigerator
84+
blender
85+
book
86+
clock
87+
vase
88+
scissors
89+
teddy bear
90+
hair drier
91+
toothbrush
92+
hair brush

0 commit comments

Comments
 (0)