-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
LucQuebec edited this page Jul 5, 2026
·
1 revision
The fastest path — no NDK, no source build.
// build.gradle.kts (module)
dependencies {
implementation("org.opencv:opencv:5.0.0.1")
}mavenCentral() is already in a default Android project's repositories.
Call this once before using OpenCV (e.g. in Application.onCreate):
import org.opencv.android.OpenCVLoader
if (!OpenCVLoader.initLocal()) {
Log.e("OpenCV", "OpenCV initialisation failed")
}The AAR bundles the native .so — nothing to copy manually.
import org.opencv.android.Utils
import org.opencv.core.Mat
import org.opencv.imgproc.Imgproc
val src = Mat()
Utils.bitmapToMat(bitmap, src)
Imgproc.cvtColor(src, src, Imgproc.COLOR_RGBA2GRAY)
Imgproc.Canny(src, src, 80.0, 160.0)See examples/ for full snippets (edge detection, DNN face detection).
The official AAR covers core: core, imgproc, imgcodecs, video, calib,
features, dnn, objdetect, photo, stitching.
Not included: the opencv_contrib modules (face recognition, tracking, ArUco,
text, ml, Haar/HOG, gapi, …). See Official vs Contrib.
For those without rebuilding, see Pro Integration.