From e6eb43a32c98a04162a921a80d89f82b30910973 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Thu, 13 Jun 2024 19:56:36 +0200 Subject: [PATCH] [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 --------- Co-authored-by: Anna Likholat --- .../coco_detection_android_demo/README.md | 79 +++++ .../app/build.gradle | 71 +++++ .../app/src/main/AndroidManifest.xml | 27 ++ .../app/src/main/assets/labels.txt | 92 ++++++ .../java/org/intel/openvino/MainActivity.java | 290 ++++++++++++++++++ .../app/src/main/res/layout/activity_main.xml | 15 + .../app/src/main/res/values-night/themes.xml | 16 + .../app/src/main/res/values/colors.xml | 10 + .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/themes.xml | 16 + .../coco_detection_android_demo/build.gradle | 5 + .../gradle.properties | 23 ++ .../gradle/libs.versions.toml | 32 ++ .../gradle/wrapper/gradle-wrapper.properties | 6 + .../settings.gradle | 24 ++ 15 files changed, 709 insertions(+) create mode 100644 modules/android_demos/coco_detection_android_demo/README.md create mode 100644 modules/android_demos/coco_detection_android_demo/app/build.gradle create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/AndroidManifest.xml create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/assets/labels.txt create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/java/org/intel/openvino/MainActivity.java create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/res/layout/activity_main.xml create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/res/values-night/themes.xml create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/res/values/colors.xml create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/res/values/strings.xml create mode 100644 modules/android_demos/coco_detection_android_demo/app/src/main/res/values/themes.xml create mode 100644 modules/android_demos/coco_detection_android_demo/build.gradle create mode 100644 modules/android_demos/coco_detection_android_demo/gradle.properties create mode 100644 modules/android_demos/coco_detection_android_demo/gradle/libs.versions.toml create mode 100644 modules/android_demos/coco_detection_android_demo/gradle/wrapper/gradle-wrapper.properties create mode 100644 modules/android_demos/coco_detection_android_demo/settings.gradle diff --git a/modules/android_demos/coco_detection_android_demo/README.md b/modules/android_demos/coco_detection_android_demo/README.md new file mode 100644 index 000000000..db31e809f --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/README.md @@ -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. diff --git a/modules/android_demos/coco_detection_android_demo/app/build.gradle b/modules/android_demos/coco_detection_android_demo/app/build.gradle new file mode 100644 index 000000000..816ca98b3 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/build.gradle @@ -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') +} diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/AndroidManifest.xml b/modules/android_demos/coco_detection_android_demo/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..5582c58e7 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/assets/labels.txt b/modules/android_demos/coco_detection_android_demo/app/src/main/assets/labels.txt new file mode 100644 index 000000000..4b5fc4fed --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/assets/labels.txt @@ -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 \ No newline at end of file diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/java/org/intel/openvino/MainActivity.java b/modules/android_demos/coco_detection_android_demo/app/src/main/java/org/intel/openvino/MainActivity.java new file mode 100644 index 000000000..d15035757 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/java/org/intel/openvino/MainActivity.java @@ -0,0 +1,290 @@ +package org.intel.openvino; + +import android.Manifest; +import android.app.ActivityManager; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.os.Environment; +import android.util.Log; + +import org.opencv.android.CameraActivity; +import org.opencv.android.CameraBridgeViewBase; +import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame; +import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2; +import org.opencv.core.Mat; +import org.opencv.core.MatOfFloat; +import org.opencv.core.MatOfInt; +import org.opencv.core.MatOfRect2d; +import org.opencv.core.Point; +import org.opencv.core.Rect2d; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.core.TickMeter; +import org.opencv.dnn.Dnn; +import org.opencv.imgproc.Imgproc; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * This is the object detection demo for ARM CPUs Android (for OpenVINO Java API 2.0). + * + *

The demo loads a network (including SSD, Pelee, EfficientDet) and read image from camera to + * Inference Engine device. The screen will show the inference result and speed in frame. + */ +public class MainActivity extends CameraActivity implements CvCameraViewListener2 { + private CameraBridgeViewBase mOpenCvCameraView; + private InferRequest inferRequest; + private String modelDir; + public TickMeter tm; + public Scalar[] randomColor; + + private static final String APPTAG = MainActivity.class.getName(); + public static final float CONFIDENCE_THRESHOLD = 0.6F; + public static final float NMS_THRESHOLD = 0.6F; + public static final String OPENCV_LIBRARY_NAME = "opencv_java4"; + public static final String MODEL_XML = "ssd_mobilenet_v2_coco.xml"; + public static final String COCO_LABELS = "labels.txt"; + public static final String MODEL_BIN = "ssd_mobilenet_v2_coco.bin"; + public static final String DEVICE_NAME = "CPU"; + public static String[] COCO_CLASSES_91; + + private void copyFiles() { + String[] fileNames = {MODEL_BIN, MODEL_XML, COCO_LABELS}; + for (String fileName : fileNames) { + String outputFilePath = modelDir + "/" + fileName; + File outputFile = new File(outputFilePath); + if (!outputFile.exists()) { + try { + InputStream inputStream = getApplicationContext().getAssets().open(fileName); + OutputStream outputStream = new FileOutputStream(outputFilePath); + byte[] buffer = new byte[5120]; + int length = inputStream.read(buffer); + while (length > 0) { + outputStream.write(buffer, 0, length); + length = inputStream.read(buffer); + } + outputStream.flush(); + outputStream.close(); + inputStream.close(); + } catch (Exception e) { + Log.e("CopyError", "Copying model has failed."); + System.exit(1); + } + } + } + } + + private void createRandomColor(int length) { + Random r = new Random(999); + randomColor = new Scalar[length]; + + for (int i = 0; i < length; i++) { + randomColor[i] = + new Scalar(r.nextDouble() * 255, r.nextDouble() * 255, r.nextDouble() * 255); + } + } + + private void processNetwork() { + // Set up camera listener + mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.CameraView); + mOpenCvCameraView.setVisibility(CameraBridgeViewBase.VISIBLE); + mOpenCvCameraView.setCvCameraViewListener(this); + mOpenCvCameraView.setCameraPermissionGranted(); + mOpenCvCameraView.enableFpsMeter(); + mOpenCvCameraView.setMaxFrameSize(320, 240); + + // Initialize model + copyFiles(); + + List listOfStrings = new ArrayList(); + try { + BufferedReader bf = null; + bf = new BufferedReader(new FileReader(modelDir + "/" + COCO_LABELS)); + String line = bf.readLine(); + while (line != null) { + listOfStrings.add(line); + line = bf.readLine(); + } + bf.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + COCO_CLASSES_91 = listOfStrings.toArray(new String[0]); + + Core core = new Core(); + Model net = core.read_model(modelDir + "/" + MODEL_XML); + Log.i(APPTAG, "load ok..."); + + // Set config of the network + PrePostProcessor p = new PrePostProcessor(net); + p.input().tensor().set_element_type(ElementType.u8).set_layout(new Layout("NCHW")); + + p.input().preprocess().resize(ResizeAlgorithm.RESIZE_LINEAR); + p.input().model().set_layout(new Layout("NCHW")); + p.build(); + + CompiledModel compiledModel = core.compile_model(net, DEVICE_NAME); + inferRequest = compiledModel.create_infer_request(); + + // System info + ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); + ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo(); + activityManager.getMemoryInfo(info); + Log.i(APPTAG, "residue memory : " + (info.availMem >> 20) + "M"); + + tm = new TickMeter(); + createRandomColor(COCO_CLASSES_91.length); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + try { + System.loadLibrary(OPENCV_LIBRARY_NAME); + } catch (UnsatisfiedLinkError e) { + Log.e( + "UnsatisfiedLinkError", + "Failed to load native OpenCV libraries\n" + e.toString()); + System.exit(1); + } + modelDir = this.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath(); + if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(new String[] {Manifest.permission.CAMERA}, 0); + } else { + processNetwork(); + } + } + + @Override + public void onRequestPermissionsResult( + int requestCode, String[] permissions, int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (grantResults.length > 0 && grantResults[0] != PackageManager.PERMISSION_GRANTED) { + Log.e("PermissionError", "The application can't work without camera permissions"); + System.exit(1); + } + processNetwork(); + } + + @Override + public void onResume() { + super.onResume(); + mOpenCvCameraView.enableView(); + } + + @Override + public void onCameraViewStarted(int width, int height) {} + + @Override + public void onCameraViewStopped() {} + + @Override + public Mat onCameraFrame(CvCameraViewFrame inputFrame) { + // Use TickMeter to calculate fps + tm.start(); + Mat frame = inputFrame.rgba(); + Imgproc.cvtColor(frame, frame, Imgproc.COLOR_RGBA2RGB); + Mat currentFrame = frame.clone(); + frame.release(); + + // Preprocess the frame + Imgproc.resize(currentFrame, currentFrame, new Size(300, 300)); + int[] dimsArr = {1, currentFrame.rows(), currentFrame.cols(), 3}; + Tensor input_tensor = new Tensor(ElementType.u8, dimsArr, currentFrame.dataAddr()); + + // Set input data + inferRequest.set_input_tensor(input_tensor); + inferRequest.infer(); + + // Get output data from model + Tensor output_tensor = inferRequest.get_output_tensor(); + Imgproc.resize(currentFrame, currentFrame, new Size(320, 240)); + + float[] detection = output_tensor.data(); + int maxProposalCount = detection.length / 7; + + // Construct the input to the NMS algorithm + List rect2dList = new ArrayList<>(); + List confList = new ArrayList<>(); + List objIndexList = new ArrayList<>(); + + for (int i = 0; i < maxProposalCount; i++) { + float label = detection[i * 7 + 1]; + float conf = detection[i * 7 + 2]; + float xMin = detection[i * 7 + 3] * currentFrame.cols(); + float yMin = detection[i * 7 + 4] * currentFrame.rows(); + float xMax = detection[i * 7 + 5] * currentFrame.cols(); + float yMax = detection[i * 7 + 6] * currentFrame.rows(); + + confList.add(conf); + objIndexList.add((int) label); + rect2dList.add(new Rect2d(xMin, yMin, (xMax - xMin), (yMax - yMin))); + } + + MatOfInt indices = new MatOfInt(); + MatOfRect2d boxes = new MatOfRect2d(rect2dList.toArray(new Rect2d[0])); + float[] confArr = new float[confList.size()]; + for (int i = 0; i < confList.size(); i++) { + confArr[i] = confList.get(i); + } + MatOfFloat confs = new MatOfFloat(confArr); + Dnn.NMSBoxes(boxes, confs, CONFIDENCE_THRESHOLD, NMS_THRESHOLD, indices); + + if (indices.empty()) { + tm.stop(); + // Fps for inference + double worksFps = tm.getAvgTimeSec(); + String inferFps = "Inference fps: " + String.format("%.3f", worksFps); + Imgproc.putText( + currentFrame, inferFps, new Point(10, 15), 0, 0.5, new Scalar(0, 255, 0), 1); + + Log.i(APPTAG, "No boxes here!"); + return currentFrame; + } + + int[] idxes = indices.toArray(); + for (int idx : idxes) { + Rect2d rect2d = rect2dList.get(idx); + Integer obj = objIndexList.get(idx); + Float conf = confList.get(idx); + Imgproc.rectangle( + currentFrame, + new Point(rect2d.x, rect2d.y), + new Point((rect2d.x + rect2d.width), (rect2d.y + rect2d.height)), + randomColor[obj], + 1); + Imgproc.putText( + currentFrame, + COCO_CLASSES_91[obj] + " " + conf, + new Point(rect2d.x, rect2d.y - 10), + Imgproc.FONT_HERSHEY_COMPLEX, + 0.5, + randomColor[obj], + 1); + } + + tm.stop(); + // Fps for inference + double avgTime = tm.getAvgTimeSec() * 1000; + double worksFps = tm.getFPS(); + String inferAvgTime = "Inference average time: " + String.format("%.3f", avgTime); + String inferFps = "Inference fps: " + String.format("%.3f", worksFps); + Imgproc.putText( + currentFrame, inferAvgTime, new Point(10, 15), 0, 0.3, new Scalar(0, 255, 0), 1); + Imgproc.putText( + currentFrame, inferFps, new Point(10, 25), 0, 0.3, new Scalar(0, 255, 0), 1); + + return currentFrame; + } +} diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/res/layout/activity_main.xml b/modules/android_demos/coco_detection_android_demo/app/src/main/res/layout/activity_main.xml new file mode 100644 index 000000000..3394bf389 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/res/values-night/themes.xml b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values-night/themes.xml new file mode 100644 index 000000000..23e121f69 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values-night/themes.xml @@ -0,0 +1,16 @@ + + + + diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/colors.xml b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/colors.xml new file mode 100644 index 000000000..ca1931bca --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/strings.xml b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/strings.xml new file mode 100644 index 000000000..6069948e3 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Coco Detection Android Demo + diff --git a/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/themes.xml b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/themes.xml new file mode 100644 index 000000000..e118668ca --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/app/src/main/res/values/themes.xml @@ -0,0 +1,16 @@ + + + + diff --git a/modules/android_demos/coco_detection_android_demo/build.gradle b/modules/android_demos/coco_detection_android_demo/build.gradle new file mode 100644 index 000000000..c1e23bcf5 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/build.gradle @@ -0,0 +1,5 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.jetbrains.kotlin.android) apply false +} diff --git a/modules/android_demos/coco_detection_android_demo/gradle.properties b/modules/android_demos/coco_detection_android_demo/gradle.properties new file mode 100644 index 000000000..132244e5b --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true diff --git a/modules/android_demos/coco_detection_android_demo/gradle/libs.versions.toml b/modules/android_demos/coco_detection_android_demo/gradle/libs.versions.toml new file mode 100644 index 000000000..34a7bb164 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/gradle/libs.versions.toml @@ -0,0 +1,32 @@ +[versions] +agp = "8.4.2" +kotlin = "1.9.0" +coreKtx = "1.13.1" +junit = "4.13.2" +junitVersion = "1.1.5" +espressoCore = "3.5.1" +lifecycleRuntimeKtx = "2.8.1" +activityCompose = "1.9.0" +composeBom = "2023.08.00" +constraintlayout = "2.1.4" + +[libraries] +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +androidx-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } +androidx-material3 = { group = "androidx.compose.material3", name = "material3" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } diff --git a/modules/android_demos/coco_detection_android_demo/gradle/wrapper/gradle-wrapper.properties b/modules/android_demos/coco_detection_android_demo/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..82715403f --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Jun 12 17:09:09 CEST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/modules/android_demos/coco_detection_android_demo/settings.gradle b/modules/android_demos/coco_detection_android_demo/settings.gradle new file mode 100644 index 000000000..1409faad3 --- /dev/null +++ b/modules/android_demos/coco_detection_android_demo/settings.gradle @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "coco_detection_android_demo" +include ':app' +include ':OpenCV'