Our team of experts is ready to answer!
You can contact us directly
Telegram iconFacebook messenger iconWhatApp icon
Fill in the form below and you will receive an answer within 2 working days.
Or fill in the form below and you will receive an answer within 2 working days.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Reading Time
5 Minutes
Alexander Smorkalov
Software Developer at OpenCV.ai
OpenCV 4.9.0 Launch: Enhanced Android Support and ARM Device Performance

OpenCV For Android Distribution

The OpenCV.ai team, creators of the essential OpenCV library for computer vision, has launched version 4.9.0 in partnership with ARM Holdings. This update is a big step for Android developers, simplifying how OpenCV is used in Android apps and boosting performance on ARM devices.
April 11, 2024

Easier access to OpenCV for Android through Maven Central

In December, we released OpenCV 4.9.0. As part of that release, we made Android builds available through the Maven Central repository for the first time. This work is supported by Arm company, the authors of the computer architecture on which Android and the world’s smartphones are built.

OpenCV is the open-source library for developing and deploying computer vision (CV) workloads. Its availability for Android will make it easier to develop and maintain CV applications for Android systems, lowering the barrier of entry for developers to build high-quality CV algorithms for supporting AI and image processing algorithms.

Managing your application’s OpenCV dependency through Maven Central is simple, with support built into Android Studio and many other tools. Doing so also enables you to easily keep up to date with bug fixes, new features, and performance improvements as new versions of OpenCV are released. The OpenCV team maintains source compatibility for releases, and the update is safe. Using Maven Central also ensures that you get a build of OpenCV configured correctly for performance and for using the correct dependencies.

We are working with Arm on continuous improvements to OpenCV’s performance across the broad reach of Arm-based devices, from sensors to servers and supercomputers. This includes leveraging improvements from algorithmic changes or using new Arm CPU features.

We will update Maven Central with the latest versions of OpenCV as they are released and continue to update our support for Android, ensuring that developers can integrate OpenCV into their workflows alongside other Android functionality.

We would like to thank Arm for supporting this work.

Using OpenCV in your Android application

To start working with OpenCV, you do not need to download the SDK. Just create a new Application in Android Studio (or open an existing one), open your application’s build.gradle of your application where the “android” section is located, and add OpenCV to the dependencies section of the global scope like this:


apply plugin: 'com.android.application'
android {
   namespace 'org.opencv.samples.puzzle15'
   compileSdkVersion 31
   defaultConfig {
       applicationId "org.opencv.samples.puzzle15"
       minSdkVersion 21
       targetSdkVersion 31
       versionCode 301
       versionName "3.01"
   }
   // … more options here
}                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                        
dependencies {                                                                                                                                                                                                                                                                 
       implementation 'org.opencv:opencv:4.9.0'                                                                                                                                                                                                                               
   }                                                                                                                                                                                                                                                                          
}

The OpenCV package will be downloaded and linked automatically by Gradle during the application build. Native libraries are also added to APK automatically. You just need to add a run-time call to load the OpenCV native part before the first library usage like this:


@Override                                                                                                                                                                                                                                                                  
   public void onCreate(Bundle savedInstanceState) {                                                                                                                                                                                                                          
       super.onCreate(savedInstanceState);                                                                                                                                                                                                                                    
       if (OpenCVLoader.initLocal()) {                                                                                                                                                                                                                                        
           Log.i(TAG, "OpenCV loaded successfully");                                                                                                                                                                                                                          
       } else {                                                                                                                                                                                                                                                               
           Log.e(TAG, "OpenCV initialization failed!");                                                                                                                                                                                                                       
           (Toast.makeText(this, "OpenCV initialization failed!", Toast.LENGTH_LONG)).show();                                                                                                                                                                                 
           return;                                                                                                                                                                                                                                                            
       }                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                              
       // application initialization logic                                                                                                                                                                                                                                         
   }

It is also possible to use OpenCV with your native code libraries in your Android application. The OpenCV AAR package includes a prefab part and allows developers to develop native parts for Android, too. The OpenCV tutorial Tutorial2-mixed processing provides an example of this.

In summary, as well as the normal Gradle steps outlined above, you must update your native code to link against the OpenCV libraries. In CMake, this can be done as follows:


find_package(OpenCV REQUIRED COMPONENTS OpenCV::opencv_java4)                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                              
file(GLOB srcs *.cpp *.c)                                                                                                                                                                                                                                                      
file(GLOB hdrs *.hpp *.h)                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                              
add_library(${target} SHARED …)
target_link_libraries(${target} OpenCV::opencv_java4)

We look forward to seeing what you achieve with OpenCV

Finally, as a reminder, the OpenCV package is available here:

https://central.sonatype.com/artifact/org.opencv/opencv.

OpenCV is an open-source project distributed with Apache 2.0 license. Feel free to contribute on GitHub!

I’m not a developer; what could I do? Donations are welcome!

If you need custom development and consulting in computer vision, feel free to leave a request at opencv.ai

Let's discuss your project

Book a complimentary consultation

Read also

May 15, 2024

AI in football

Football is not only the most popular sport, watched by more than 4 billion people around the world — it is also a huge market. Some of the strongest clubs in Europe are businesses with annual revenues of $8 billion and more than 100,000 employees in different countries. Football is also a competition field for the latest technologies in computer vision and artificial intelligence. Let's take a look at what AI and CV are doing in football!
May 7, 2024

Computer Vision in Sports: People Train and Compete — Machines Watch and Help

At the upcoming 2024 Olympic Games in Paris, the world will see the most advanced AI and computer vision systems for sports developed by Intel. These systems will not only help capture athletic performance with millimeter and millisecond accuracy but also create 3D models of athletes for replays and analyzing complex situations. The data and models will be available to both referees and spectators. Artificial intelligence and computer vision systems in sports are no longer a high-tech novelty but an everyday reality. People train, challenge, and watch others compete — and hundreds of tech companies are helping to make it safer and more efficient. And more fun, too!
April 16, 2024

Which GPUs are the most relevant for Computer Vision

In the field of CV, selecting the appropriate hardware can be tricky due to the variety of usable machine-learning models and their significantly different architectures. Today’s article explores the criteria for selecting the best GPU for computer vision, outlines the GPUs suited for different model types, and provides a performance comparison to guide engineers in making informed decisions.