Utilizing OpenCV with Android’s Camera2 API through JavaCamera2View
This android project is barebone setting up OpenCV 4.13.0 (and other 4.x.y versions) for Android in Android Studio with Native Development Kit (NDK) support. Android NDK enables you to implement your OpenCV image processing pipeline in C++ and call that C++ code from Android Kotlin/Java code through JNI (Java Native Interface). This provides a live camera feed with the ability to dynamically switch between front and back cameras. It includes a custom cvFpsMeter for enhanced text visibility. Also features a basic setup for Android NDK and OpenCV, as well as a CV filter with a toggle button for camera switching.
Ensure you have JDK 21 installed (required for this project)
File -> New -> Project from Version Control -> GitUnzip downloaded file and put OpenCV-android-sdk directory next your project and rename folder opencvsdk4130. If you want to place somewhere else please change path in settings.gradle
gradle/libs.versions.toml..kts for better type safety and IDE support../gradlew spotlessApply to format code.FaceDetector class.Kotlin, OpenCV 4, Android, Android Studio, Native, NDK, JNI, C++, Version Catalog, Kotlin DSL, Spotless