Skip to content

Latest commit

Β 

History

History
170 lines (113 loc) Β· 4.6 KB

File metadata and controls

170 lines (113 loc) Β· 4.6 KB

#APK link: https://drive.google.com/file/d/1Zm0X-yP8oDmcPf9aibUZxIxlfe0nlkZf/view?usp=sharing

🧠 Real-Time Edge Detection Viewer

Android + OpenCV (C++) + OpenGL ES + TypeScript Web Viewer

A real-time edge detection system that captures live camera frames, processes them using OpenCV in C++ via JNI, and renders the processed frames using OpenGL ES 2.0. Additionally, a lightweight TypeScript web viewer displays a sample processed frame, showcasing integration between native image processing and web visualization.


πŸš€ Features Implemented

πŸ“± Android Application

  • Live Camera Feed using TextureView (Camera2 API).
  • JNI-based Frame Processing β€” each frame is sent to native C++ code for processing.
  • Canny Edge Detection & Grayscale Filters implemented with OpenCV C++.
  • OpenGL ES Renderer β€” displays the processed frames as textures in real time.
  • Achieved smooth 10–20 FPS performance during processing and rendering.
  • Optional toggle between raw feed and edge-detected view.
  • FPS Counter overlay for performance monitoring.

🌐 TypeScript Web Viewer

  • Minimal TypeScript + HTML web app that displays a sample processed frame (static/base64).
  • Shows basic frame metadata β€” FPS, resolution, processing time.
  • Demonstrates ability to connect native output to a web visualization layer.

🧩 Project Structure

πŸ“¦ RealTime-EdgeDetection β”œβ”€β”€ app/ # Java/Kotlin Android code (UI + Camera) β”‚ β”œβ”€β”€ MainActivity.kt β”‚ β”œβ”€β”€ CameraHandler.kt β”‚ └── JNIInterface.kt β”œβ”€β”€ jni/ # Native C++ OpenCV processing the project in Android Studio (Hedgehog or newer):

Launch Android Studio.

Select File β†’ Open and choose the project directory.

Wait for Gradle to sync.

Install NDK and CMake via SDK Manager:

Go to Tools β†’ SDK Manager β†’ SDK Tools tab.

Check and install:

βœ… NDK (Side by side) βœ… CMake βœ… LLDB (optional for debugging native code)

Click Apply and wait for installation to complete.

Download and Link OpenCV SDK:

Go to the official OpenCV releases page: πŸ‘‰ https://opencv.org/releases/

Download the latest OpenCV Android SDK (ZIP file).

Extract it anywhere (for example: C:/OpenCV-android-sdk/).

In Android Studio, update your CMakeLists.txt to include OpenCV paths:

Add OpenCV include directories

    set(OpenCV_DIR "C:/OpenCV-android-sdk/sdk/native/jni")
    find_package(OpenCV REQUIRED)
    include_directories(${OpenCV_INCLUDE_DIRS})
    target_link_libraries(native-lib ${OpenCV_LIBS} log)

Also make sure build.gradle includes:

externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" } }

Run the Project:

Connect your Android device or launch an emulator.

Click ▢️ Run in Android Studio.

You should see a real-time camera feed with edges highlighted.

πŸ’» Web Viewer Setup

Navigate to the web folder:

    cd web
    npm install typescript
    tsc

Open index.html in your browser to view the sample processed frame.

The viewer displays:

Static base64 image (representing processed frame)

Frame metadata, such as FPS and resolution

🧠 Architecture Overview

Camera Feed (Java/Kotlin) β†’ Captured frames passed to native via JNI.

Native Processing (C++) β†’ OpenCV applies Canny Edge Detection or Grayscale filter.

Rendering (OpenGL ES) β†’ Processed frames displayed as textures in real-time.

Web Layer (TypeScript) β†’ Displays a sample processed frame, simulating result transmission to web.

Data Flow:

Camera Frame β†’ JNI Bridge β†’ OpenCV (C++) β†’ Processed Output β†’ OpenGL Texture β†’ Display

🧩 Technologies Used

Android SDK (Kotlin/Java) NDK + JNI (C++) OpenCV (C++ for image processing) OpenGL ES 2.0 (for rendering)

TypeScript (for web visualization)β”‚ β”œβ”€β”€ CMakeLists.txt β”‚ β”œβ”€β”€ edge_processor.cpp β”‚ └── native-lib.cpp β”œβ”€β”€ gl/ # OpenGL renderer classes β”‚ β”œβ”€β”€ GLRenderer.cpp β”‚ β”œβ”€β”€ GLRenderer.h β”‚ └── shaders/ β”‚ └── basic_fragment.glsl β”œβ”€β”€ web/ # TypeScript-based web viewer β”‚ β”œβ”€β”€ index.html β”‚ β”œβ”€β”€ main.ts β”‚ └── tsconfig.json └── README.md


βš™οΈ Setup Instructions

🧱 Android Build Setup

  1. Clone the repository:
    git clone https://github.com/RealCifer/edgeviewer.git
    cd edgeviewer
    

πŸ“Έ Working Model Screenshots

Raw Image Processed Image
Raw Image Processed Image

|Web Site SS| web initial web final