Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Camera Application For Image Processing Using openCV

A professional Android camera application developed as part of the ** Android assignment**.

The application utilizes Kotlin, Jetpack Compose, CameraView, OpenCV, MVVM, Clean Architecture, and Hilt to provide a high-performance camera experience featuring real-time Black & White filtering, precision manual cropping, and advanced image adjustments.


🚀 Features

📸 Camera Preview

  • Real-time camera feed using the CameraView library.
  • Robust lifecycle management integrated with Jetpack Compose.
  • Seamless camera permission handling.
  • Support for both Front and Back cameras.
  • Dual-mode preview: Color and Black & White.

🌑 Black & White Filter

  • Native grayscale filter applied via CameraView's filter API.
  • Instant toggle between Color and B&W modes.
  • Filters are applied in real-time to the live feed before capture.

🖼️ OpenCV Image Cropping

  • High-precision cropping powered by OpenCV 4.10.0.
  • Manual area selection via intuitive drag gestures.
  • Coordinate Mapping: Accurately translates screen touch coordinates to high-resolution bitmap pixels.
  • Safety validation: Automatically rejects invalid or extremely small selections.

🪄 Image Editing (Bonus)

  • Fine-tune captured images with native OpenCV processing:
    • Brightness Adjustment: Enhance visibility in low-light shots.
    • Contrast Adjustment: Make your Black & White photos pop.
  • Real-time slider-based controls for instant feedback.

💾 Save to Gallery

  • Direct integration with Android MediaStore.
  • Optimized for Scoped Storage (Android 10+): Uses RELATIVE_PATH to save in the public Pictures folder.
  • Background processing: All storage operations run on the IO Dispatcher to ensure zero UI lag.

🛡️ Error Handling & UX

  • Input Validation: Material3 AlertDialog guides the user if a crop selection is too small.
  • Fail-safe Logic: Hardware-level error catching for camera and storage exceptions.
  • Feedback Loop: Integrated Loading states with Circular Progress Indicators.
  • Professional Alerts: Global SnackbarHost for non-intrusive error reporting.

🛠 Tech Stack

Technology Usage
Kotlin Core programming language
Jetpack Compose Modern Declarative UI
CameraView Robust camera engine and preview
OpenCV Professional-grade image processing and cropping
Hilt Dependency Injection for modularity
Coroutines & Flow Asynchronous operations and State management
Navigation Jetpack Compose Navigation
MediaStore Industry-standard gallery storage

🏗 Architecture

The application follows Clean Architecture with MVVM, ensuring a strict separation of concerns.

Presentation Layer (UI & ViewModels)
     ↓
Domain Layer (Business Logic & Use Cases)
     ↓
Data Layer (Processors & Repository Implementations)

📂 Project Structure

com.example.cameraapplication
│
├── common/              # Shared utilities (ResultState, BitmapUtils)
├── data/
│   ├── processor/       # OpenCV native implementation
│   └── repository/      # Storage and hardware implementations
├── domain/
│   ├── repository/      # Interface contracts
│   └── usecase/         # Pure business logic (Crop, Save, Adjust)
└── presentation/
    ├── Navigation/      # Type-safe NavGraph
    └── screen/
        └── camerascreen/
            ├── CameraViewModel  # Single source of truth
            └── components/      # Modularized UI components

🎨 UI / UX Enhancements

  • Professional Shutter: DSLA-style concentric ring button design.
  • Live Animations: Infinite pulsing effects on active filter toggles.
  • Focus Dimming: Shadow overlays during cropping to highlight the selection.
  • Glassmorphism: Semi-transparent frosted-glass control panels.

📱 Permissions

The application requires the following permissions to function correctly, which are declared in the AndroidManifest.xml:

  • Camera: Required to access and display the live camera feed.
  • Record Audio: Required by the CameraView library's internal safety checks (Audio is explicitly disabled in code, but declaration is required for hardware initialization).
  • Read/Write External Storage: Required to save and retrieve processed images from the device gallery (Scoped storage rules applied for Android 10+).
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />

🧪 Testing & Validation

The application has been thoroughly tested for:

  • Permission Flow: Graceful handling of camera and storage access.
  • Hardware Stability: Explicit resource release to prevent "Camera Server Died" errors.
  • Edge Cases: Validating tiny crop areas, storage-full scenarios, and rapid screen transitions.
  • Responsiveness: Tested across various screen sizes and orientations.

📦 Prerequisites & Setup

Requirements

  • Android Studio Ladybug | 2024.2.1 or newer.
  • Minimum SDK 24 (Android 7.0).
  • Target SDK 37 (Android 15).
  • Physical Device recommended for optimal camera and OpenCV performance.

Installation

  1. Clone the repository.
  2. Open in Android Studio.
  3. Perform a Gradle Sync to download dependencies (OpenCV 4.10.0 and CameraView 2.7.2 are pulled automatically via Maven).
  4. Run on your device.

📄 License

This project was developed as part of an Android Development Assignment.

About

Android Camera Application built with Kotlin, Jetpack Compose, CameraView, and OpenCV. Features real-time B&W filtering, precision image cropping with screen-to-bitmap coordinate mapping, brightness/contrast adjustment, and MediaStore gallery saving. Uses MVVM, Clean Architecture, Hilt, Coroutines, and Flow.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages