Skip to content

Mardhav6/-android-opencv-opengl-assessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§ͺ Android + OpenCV + OpenGL + TypeScript Assessment

A real-time edge detection viewer that demonstrates integration between Android native development, OpenCV C++ processing, OpenGL ES rendering, and TypeScript web components.

πŸ“‹ Features Implemented

βœ… Android App

  • Camera Integration: Real-time camera feed using CameraX API
  • JNI Bridge: Seamless Java ↔ C++ communication
  • OpenCV Processing: Canny edge detection implemented in C++
  • OpenGL ES Rendering: Hardware-accelerated frame rendering
  • FPS Counter: Real-time performance monitoring
  • Toggle Controls: Switch between raw and processed views

βœ… Web Viewer (TypeScript)

  • Frame Display: HTML5 Canvas-based frame rendering
  • Performance Stats: Real-time FPS, resolution, and processing time display
  • Interactive Controls: Toggle between raw/processed views
  • Frame Saving: Export processed frames as PNG
  • Responsive Design: Mobile-friendly interface

βœ… Architecture

  • Modular Structure: Clean separation of concerns
  • Native Performance: C++ OpenCV processing for optimal speed
  • Cross-Platform: Android native + web viewer
  • Real-time Processing: 10-15 FPS target performance

πŸ—οΈ Project Structure

android-opencv-opengl-assessment/
β”œβ”€β”€ app/                          # Android Application
β”‚   β”œβ”€β”€ src/main/
β”‚   β”‚   β”œβ”€β”€ java/com/example/opencvapp/
β”‚   β”‚   β”‚   β”œβ”€β”€ MainActivity.kt           # Main Android activity
β”‚   β”‚   β”‚   └── jni/OpenCVProcessor.kt   # JNI bridge
β”‚   β”‚   β”œβ”€β”€ cpp/
β”‚   β”‚   β”‚   └── CMakeLists.txt           # CMake configuration
β”‚   β”‚   β”œβ”€β”€ res/                         # Android resources
β”‚   β”‚   └── AndroidManifest.xml
β”‚   └── build.gradle                     # App build configuration
β”œβ”€β”€ jni/                          # Native C++ Code
β”‚   └── opencv_processor.cpp      # OpenCV processing implementation
β”œβ”€β”€ gl/                           # OpenGL Renderer
β”‚   └── OpenGLRenderer.kt         # OpenGL ES 2.0 renderer
β”œβ”€β”€ web/                          # TypeScript Web Viewer
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ index.ts              # Main web application
β”‚   β”‚   β”œβ”€β”€ FrameViewer.ts        # Frame display logic
β”‚   β”‚   └── StatsDisplay.ts       # Performance statistics
β”‚   β”œβ”€β”€ index.html                # Web interface
β”‚   β”œβ”€β”€ package.json              # Web dependencies
β”‚   └── tsconfig.json             # TypeScript configuration
└── README.md                     # This file

βš™οΈ Setup Instructions

Prerequisites

  1. Android Studio (latest version)
  2. Android NDK (r25c or later)
  3. OpenCV for Android (4.8.0 or later)
  4. Node.js (18+ for web viewer)
  5. TypeScript (5.0+)

Android Setup

  1. Clone and Open Project

    git clone <repository-url>
    cd android-opencv-opengl-assessment
  2. Open in Android Studio

    • Open Android Studio
    • Select "Open an existing project"
    • Navigate to the project directory
  3. Configure OpenCV

    • Download OpenCV for Android from opencv.org
    • Extract to app/libs/opencv
    • Update app/build.gradle to include OpenCV module:
      implementation project(':opencv')
  4. Configure NDK

    • Ensure Android NDK is installed
    • Set NDK path in Android Studio: File β†’ Project Structure β†’ SDK Location
  5. Build and Run

    ./gradlew assembleDebug

Web Viewer Setup

  1. Navigate to Web Directory

    cd web
  2. Install Dependencies

    npm install
  3. Build TypeScript

    npm run build
  4. Start Web Server

    npm start
  5. Open in Browser

    • Navigate to http://localhost:8080
    • View the web interface

🧠 Architecture Explanation

Data Flow

  1. Camera Capture β†’ Android CameraX captures frames
  2. JNI Bridge β†’ Frames passed to native C++ code
  3. OpenCV Processing β†’ Canny edge detection applied
  4. OpenGL Rendering β†’ Processed frames rendered using OpenGL ES
  5. Web Integration β†’ Frame data can be sent to web viewer

Key Components

JNI Integration (25% weight)

  • Java Side: OpenCVProcessor.kt handles frame conversion and JNI calls
  • C++ Side: opencv_processor.cpp implements OpenCV algorithms
  • Bridge: Seamless data transfer between Java and C++

OpenCV Usage (20% weight)

  • Canny Edge Detection: Primary processing algorithm
  • Gaussian Blur: Noise reduction preprocessing
  • Memory Management: Efficient frame buffer handling
  • Performance: Optimized for real-time processing

OpenGL Rendering (20% weight)

  • OpenGL ES 2.0: Hardware-accelerated rendering
  • Shader Programs: Vertex and fragment shaders
  • Texture Management: Efficient frame-to-texture conversion
  • Real-time Performance: 10-15 FPS target

TypeScript Web Viewer (20% weight)

  • Modular Design: Clean separation of concerns
  • Canvas Rendering: HTML5 Canvas for frame display
  • Performance Monitoring: Real-time statistics
  • Interactive Controls: User interface for testing

Project Structure (15% weight)

  • Modular Architecture: Clear separation of Android, native, and web code
  • Documentation: Comprehensive setup and usage instructions
  • Git History: Meaningful commit messages and development process

πŸ“± Screenshots

Android App

  • Real-time camera feed with edge detection overlay
  • FPS counter and performance metrics
  • Toggle button for raw/processed view switching

Web Viewer

  • Clean, modern interface with performance statistics
  • Interactive frame display with toggle controls
  • Responsive design for various screen sizes

πŸš€ Performance Targets

  • Frame Rate: 10-15 FPS minimum
  • Processing Time: < 50ms per frame
  • Memory Usage: Optimized for mobile devices
  • Battery Life: Efficient processing to minimize drain

πŸ”§ Troubleshooting

Common Issues

  1. OpenCV Not Found

    • Ensure OpenCV is properly linked in build.gradle
    • Check that native libraries are in correct location
  2. NDK Build Errors

    • Verify NDK version compatibility
    • Check CMakeLists.txt configuration
  3. Camera Permissions

    • Ensure camera permission is granted
    • Check AndroidManifest.xml permissions
  4. Web Viewer Not Loading

    • Verify TypeScript compilation
    • Check browser console for errors

πŸ“ Development Notes

Git Commit Strategy

  • Modular commits for each feature
  • Clear, descriptive commit messages
  • Separate commits for Android, native, and web components

Testing Approach

  • Unit tests for individual components
  • Integration tests for JNI bridge
  • Performance testing for real-time processing
  • Cross-platform compatibility testing

About

Real-time edge detection viewer with Android OpenCV OpenGL and TypeScript web viewer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •