Before, OpenCV was integrated by NDK, so library needs to be compiled by ourselves, which is a very inefficient way of integration, many times you need to write JNI code, which is not a good choice, but through open CV official JAR can introduce a variety of commonly used APIS. Here’s how it works

First you need to download an OpenCV Android development SDK:

Create a New empty project and go to the Android Studio menu – >File – >New – >Import Module

1. Select the Java folder under the SDK folder. Module name: Android Studio will automatically populate this with openCVLibrary340. 3. Click Next and three checkboxes will appear. Select all of them and click Finish.

If it occurs during integration

ERROR: Failed to install the following Android SDK packages as some licences have not been accepted. build-tools; Android SDK build-tools platforms; android-14 Android SDK Platform 14 To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager. Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html Using Android SDK: D:\develop\AndroidSDK Install missing SDK package(s)Copy the code

Click Install Missing SDK Package (s) to download it

Then, we need to change the compilation parameters of Module to the same as the project:

In this case, create folder jniLibs under app/ SRC /main and copy all downloaded SDK /native/libs files of Opencv-Android-SDK to jniLibs