Member-only story

Setup OpenCv Android without install OpenCv manager apk

Nhan Cao
1 min readJul 6, 2018

--

1. Download opencv sdk for android at: https://opencv.org/releases.html

2. Unzip opencv sdk and place it in the same root project folder

/Projects
/ADVisionProject
/OpenCV-android-sdk

3. In your project (ex ADVisionProject), open settings.gradle file and add config below

def opencvsdk = '<path_to_opencv_android_sdk_rootdir>'include ':opencv'project(':opencv').projectDir = new File(opencvsdk + '/sdk')

Example with my settings.gradle file

include ':app'

def opencvsdk = '../OpenCV-android-sdk'
include ':opencv'
project(':opencv').projectDir = new File(opencvsdk + '/sdk')

4. In app/build.gradle, add opencv module to dependencies

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
....
implementation project(':opencv')
}

5. Write some codes for testing. About below code, it read drawable image to Mat and convert color to gray mode, convert Mat to Bitmap and display Bitmap into ImageView.

--

--

Responses (3)

Write a response