Using OpenCV library on Android
OpenCV (Open Source Computer Vision Library), a popular and widely used computer-vision library, supports a wide range of platforms.
If you want to implement any kind of moderately complex image processing, this is the best library to start with. In this post, we go through the steps to add the OpenCV library as a module to your Android application project.
Step 1: Download OpenCV SDK for Android
Head over to this link to download the Android pack from the releases page of OpenCV SDK for Android. Unzip the folder, which will have the following contents.
There are 2 folders of importance here.
native\libs contains the native code
Step 2: Import OpenCV Android library to your application
In Android Studio, go
File -> New -> Import Module
Step 3: Adjust relative paths of the OpenCV
build.gradle file and fix the paths.
jniLibs.srcDirs = ['../../jni']
java.srcDirs = ['src']
aidl.srcDirs = ['src']
res.srcDirs = ['res']
Step 4: Copy
the .so files to your application folder
sdk\native\libs folder to your applications folder,
src\main folder. Rename this folder to
Step 5: Load the
Before you can use any OpenCV related features, you will have to execute this command.
That’s it. You are ready to get started with OpenCV on Android.