-
📸 Camera Feed Integration
- Integrated CameraX API for efficient camera frame capture
- Configured image analyzer to extract YUV frames in real-time
-
🔁 Frame Processing via OpenCV (C++)
- Implemented JNI bridge to process frames in native C++ code
- Applied Canny Edge Detection using OpenCV's efficient algorithms
- Gaussian blur preprocessing to improve edge detection quality
-
🔄 Toggle View
- Added FAB button to switch between raw camera feed and processed edge view
- Properly handles visibility and camera pipeline reconfiguration
-
📊 Performance Monitoring
- Real-time FPS counter displayed on screen
- Optimized processing with dedicated high-priority threads
-
🎨 Visual Effects with OpenGL Shaders
- Normal mode: white edges on black background
- Invert mode: black edges on white background
-
🔍 OpenCV Processing
- Gaussian blur applied before edge detection to reduce noise
- Optimal Canny threshold parameters for clear edge visualization
- Android Studio: Arctic Fox or newer
- Android SDK: API level 24+
- Android NDK: r24+ (required for native C++ code)
- OpenCV for Android SDK: version 4.5.0+
Download and Install NDK (Side by side) and CMake from SDK tools tab in Android Studio
- Download OpenCV Android SDK from OpenCV Releases
- Extract the ZIP file
- Copy the
sdkfolder toapp/src/maindirectory - Ensure the OpenCV path in
app/src/main/cpp/CMakeLists.txtis correctly set:set(OpenCV_DIR ../sdk/native/jni)
- Clone this repository:
git clone https://github.com/ubermensch04/Canny_OpenGL.git - Open the project in Android Studio
- Wait for Gradle to sync and build
- Run the app on a physical device (camera required)
The application uses JNI (Java Native Interface) to bridge between the Kotlin/Java layer and C++ code:
- Native Method Declaration:
external fun preprocessFrame(data: ByteArray, width: Int, height: Int): ByteArrayin MainActivity - Native Implementation: C++ function in
native-lib.cppusing the JNI naming convention - Library Loading:
System.loadLibrary("myapplication")loads the compiled C++ library


