Skip to content

Commit cb88072

Browse files
committed
Addressing comments
1 parent 6d3106a commit cb88072

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

content/learning-paths/smartphones-and-mobile/android_opencv_kleidicv/background.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ OpenCV integrates well with Android development, leveraging Kotlin’s concise s
1919
OpenCV is optimized for high performance, utilizing native C++ code for efficient processing. This ensures real-time performance, particularly on mobile devices where computational resources may be limited. A critical component enabling these optimizations is the Hardware Acceleration Layer (HAL). HAL serves as an abstraction layer that enables hardware-specific acceleration by utilizing device-specific optimizations. This significantly boosts the performance of OpenCV functions on supported hardware, reducing processing time and power consumption. HAL makes OpenCV highly adaptable to modern multi-core processors and GPU architectures, vital for computationally intensive tasks like object detection and image recognition.
2020

2121
### ARM and KleidiCV
22-
To further enhance OpenCV’s capabilities on ARM-based devices, ARM developed KleidiCV, a specialized library that leverages OpenCV’s HAL for hardware acceleration. KleidiCV focuses on optimizing various OpenCV functions specifically for ARM processors, ensuring faster execution and lower power consumption. This integration is particularly beneficial for mobile and embedded systems where performance efficiency is critical. By utilizing HAL, KleidiCV allows developers to harness the full potential of ARM hardware, making it an ideal solution for applications requiring high-performance computer vision on ARM-based devices.
22+
To further enhance OpenCV’s capabilities on ARM-based devices, ARM developed KleidiCV, a specialized library that leverages OpenCV’s HAL for hardware acceleration. KleidiCV is an Arm Kleidi Library, a suite of highly performant open-source Arm routines. KleidiCV focuses on optimizing various OpenCV functions specifically for ARM processors, ensuring faster execution and lower power consumption. This integration is particularly beneficial for mobile and embedded systems where performance efficiency is critical. By utilizing HAL, KleidiCV allows developers to harness the full potential of ARM hardware, making it an ideal solution for applications requiring high-performance computer vision on ARM-based devices.
2323

2424
### OpenCV for Android Developers
2525
For Android developers, OpenCV offers an SDK designed for seamless integration with Android Studio, the primary development environment. The SDK simplifies the process of adding OpenCV libraries, managing dependencies, and configuring projects, enabling developers to incorporate sophisticated vision capabilities into their applications effortlessly.

content/learning-paths/smartphones-and-mobile/android_opencv_kleidicv/create-project.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Follow these steps to create a project and add OpenCV with KleidiCV support:
1818

1919
3. Configure the project as follows (see figure below):
2020
- Name: **Arm64.KleidiCV.Demo**.
21-
- Package name: **com.arm.arm64kleidicvdemoa**.
21+
- Package name: **com.arm.arm64kleidicvdemo**.
2222
- Save location: *Select relevant file location*.
2323
- Language: **Kotlin**.
2424
- Minimum SDK: **API 24**.
@@ -28,7 +28,7 @@ Follow these steps to create a project and add OpenCV with KleidiCV support:
2828

2929
4. Click the **Finish** button.
3030

31-
The project will be ready in a few moments, and Android Studio should appear as shown below:
31+
The project will be ready in a few moments. Afterward you can configure the project.
3232

3333
## Add OpenCV support
3434
To add OpenCV for Arm64, open the *build.gradle.ts (Module: app)*, and add the following line under the dependencies:
@@ -37,7 +37,7 @@ To add OpenCV for Arm64, open the *build.gradle.ts (Module: app)*, and add the f
3737
implementation("org.opencv:opencv:4.11.0")
3838
```
3939

40-
Make sure that compileSdk is set to 35:
40+
Also, make sure that compileSdk is set to 35. The contents of the file should look something like this:
4141

4242
```JSON
4343
plugins {
@@ -78,7 +78,6 @@ android {
7878
}
7979

8080
dependencies {
81-
8281
implementation(libs.androidx.core.ktx)
8382
implementation(libs.androidx.appcompat)
8483
implementation(libs.material)

content/learning-paths/smartphones-and-mobile/android_opencv_kleidicv/process-images.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ layout: "learningpathall"
1010
## Process images
1111
In this final step, you will implement the application logic to process the images.
1212

13-
Start by adding a `assets` folder under `src/main`. Then, under `assets` folder add a `img.png` image. We will use this image for processing. Here, we use the cameraman image.
13+
Start by adding a `assets` folder under `src/main`. Then, under `assets` folder add a `img.png` image. This image can be any kind of image as it converted to the right type by the app. We will use this image for processing. Here, we use the [cameraman image](https://github.com/antimatter15/cameraman).
14+
15+
To make navigation betwee files easier in Android Studio, select "Project" from the project browser pane.
1416

1517
## ImageOperation
16-
You will now create an enumeration (enum class) for a set of image processing operations in an application that uses the OpenCV library. Under the `src/main/java` add the `ImageOperation.kt` file and modify it as follows:
18+
You will now create an enumeration (enum class) for a set of image processing operations in an application that uses the OpenCV library. Under the `src/main/java/com/arm/arm64kleidicvdemo` add the `ImageOperation.kt` file and modify it as follows:
1719

1820
```Kotlin
1921
package com.arm.arm64kleidicvdemo
@@ -72,15 +74,7 @@ Each enum constant must override the abstract method apply to define its specifi
7274

7375
We configured processing operations to align with current KleidiCV restrictions. Specifically, in-place changes are not supported, so the source and destination must be different images. In general, only single-channel images are supported (Gaussian blur is an exception). Sobel’s output type must be 16SC1; dx and dy must be either (1,0) or (0,1); and the border mode must be replicate. Gaussian blur supports a non-zero sigma, but its performance is best with sigma 0.0. Its uplift is most noticeable with a kernel size of 7×7.
7476

75-
There is also the companion object provides a utility method:
76-
```Kotlin
77-
companion object {
78-
fun fromDisplayName(name: String): ImageOperation? =
79-
values().find { it.displayName == name }
80-
}
81-
```
82-
83-
This function maps a string (displayName) to its corresponding enum constant by iterating through the list of all enum values and returns null if no match is found.
77+
There is also the companion object provides a utility method fromDisplayName. This function maps a string (displayName) to its corresponding enum constant by iterating through the list of all enum values and returns null if no match is found.
8478

8579
## ImageProcessor
8680
Similarly, add the ImageProcessor.kt:
@@ -232,9 +226,7 @@ class MainActivity : AppCompatActivity() {
232226
return Mat(bitmap.height, bitmap.width, CvType.CV_8UC1).also { mat ->
233227
bitmap.copy(Bitmap.Config.ARGB_8888, true).let { tempBitmap ->
234228
Utils.bitmapToMat(tempBitmap, mat)
235-
Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGBA2GRAY)
236-
assert(mat.channels() == 1)
237-
mat.convertTo(mat, CvType.CV_8U)
229+
Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGBA2GRAY)
238230
}
239231
}
240232
}
@@ -315,7 +307,7 @@ When the activity starts, it sets up the user interface, initializes OpenCV and
315307
The activity also implements several helper methods:
316308
1. setupSpinner - populates the spinner with the names of available ImageOperation enums.
317309
2. showToast - displays a short toast message for user feedback.
318-
3. loadImage - loads the test image (img.png) from the app’s assets. Then, the method converts the image into a Bitmap and stores it for display. The bitmap is also converted to an OpenCV Mat object and changed its color format to BGR (used in OpenCV).
310+
3. loadImage - loads the test image (img.png) from the app’s assets. Then, the method converts the image into a Bitmap and stores it for display. The bitmap is also converted to an OpenCV Mat object and changed its color format to grayscale (used in OpenCV).
319311
4. displayAndStoreBitmap - updates the app’s ImageView to display the loaded image.
320312
5. convertBitmapToMat - converts the Bitmap to a Mat using OpenCV utilities.
321313
6. processImage - this method performs the following:
@@ -421,4 +413,4 @@ We achieved the following performance uplift:
421413
| Resize | 0,02 | 0,04 | 2x |
422414
| Rotate | 0,02 | 0,06 | 3x |
423415

424-
As shown above, we achieved 4× faster computations for Gaussian blur and the Sobel filter, 3× faster for rotation, and 2× faster for resizing.
416+
As shown above, we achieved 4× faster computations for Gaussian blur and the Sobel filter, 3× faster for rotation, and 2× faster for resizing. Note that his numbers are noise (large standard deviation), and measurements for another device can vary.

content/learning-paths/smartphones-and-mobile/android_opencv_kleidicv/ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ layout: "learningpathall"
99
You will now define the application UI.
1010

1111
## Modify the application view
12-
To modify the application view, open `activity_main.xml` and replace the file contents with the following code:
12+
To modify the application view, open `app/src/main/res/layout/activity_main.xmlactivity_main.xml` and replace the file contents with the following code:
1313

1414
```XML
1515
<?xml version="1.0" encoding="utf-8"?>

0 commit comments

Comments
 (0)