Skip to content

gitunes/ruhsat_capture

Repository files navigation

ruhsat_capture

Flutter package for capturing vehicle registration documents (ruhsat) using the device camera with ML-based auto-detection. The package uses Google ML Kit Text Recognition to detect the document in the camera frame and automatically captures the photo when the document is stable.

Screenshots

Camera Screen    Auto Capture

Camera Screen                      Auto-Capture

Demo

Features

  • Auto-detection: Recognizes Turkish vehicle registration documents (ruhsat) via keyword matching using Google ML Kit OCR.
  • Auto-capture: Automatically takes a photo after the document has been steadily detected for a configurable duration.
  • Manual capture: Optional manual shutter button for fallback capture.
  • Overlay frame: Customizable frame overlay with corner accents, center divider, and page labels (1. Sayfa / 2. Sayfa).
  • Fully configurable: Detection keywords, frame appearance, timing, and UI texts are all customizable via RuhsatCaptureConfig.
  • BLoC-based state management: Uses flutter_bloc for clean state handling.

Getting Started

Prerequisites

  • Flutter SDK >=3.8.0
  • Camera permission must be granted before navigating to the capture screen.
  • This package uses google_ml_kit for text recognition. Please review the full requirements for platform-specific setup.

Android

  • minSdkVersion: 21
  • targetSdkVersion: 35
  • compileSdkVersion: 35

In your android/app/build.gradle:

android {
    compileSdkVersion 35

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 35
    }
}

Add camera permission to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />

iOS

  • Minimum iOS Deployment Target: 15.5
  • Xcode 15.3.0 or newer
  • Swift 5
  • ML Kit does not support 32-bit architectures (i386 and armv7). You need to exclude armv7 in Xcode: Project > Runner > Build Settings > Excluded Architectures > Any SDK > armv7

Update your ios/Podfile:

platform :ios, '15.5'  # or newer version

# add this line:
$iOSVersion = '15.5'  # or newer version

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
  end

  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
      end
    end
  end
end

Add camera permission to ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>Ruhsat fotoğrafı çekmek için kamera izni gereklidir.</string>

Installation

Add the package to your pubspec.yaml:

dependencies:
  ruhsat_capture:
    path: ruhsat_capture

Usage

Example App

Repository icinde tum ozellikleri kullanan bir ornek uygulama bulunur:

cd example
flutter pub get
flutter run

Ornek uygulama icinde asagidaki tum konfig ayarlari canli olarak degistirilebilir:

  • RuhsatCaptureTexts
  • RuhsatFrameConfig
  • RuhsatCaptureTimingConfig
  • DetectionKeywords
  • autoCapture ve showManualCapture

Basic Usage

import 'package:ruhsat_capture/ruhsat_capture.dart';

Navigator.of(context).push(
  MaterialPageRoute(
    builder: (_) => RuhsatCaptureScreen(
      onCapture: (file) {
        // file is an XFile — handle the captured image
        debugPrint('Captured: ${file.path}');
      },
    ),
  ),
);

Custom Configuration

Navigator.of(context).push(
  MaterialPageRoute(
    builder: (_) => RuhsatCaptureScreen(
      config: const RuhsatCaptureConfig(
        autoCapture: true,
        showManualCapture: true,
        texts: RuhsatCaptureTexts(
          title: 'Ruhsat Çekimi',
          instructionText: 'Ruhsatınızı çerçeve içine yerleştirin',
        ),
        frame: RuhsatFrameConfig(
          frameAspectRatio: 1.6,
          activeBorderColor: Colors.green,
        ),
        cameraResolutionPreset: ResolutionPreset.veryHigh,
        preferWideAngleLens: true,
        initialZoom: 1.0,
        cropCapturedImageToFrame: true,
        frameCropPaddingRatio: 0.08,
        timing: RuhsatCaptureTimingConfig(
          holdDuration: Duration(milliseconds: 1500),
          captureDelay: Duration(milliseconds: 500),
        ),
        keywords: DetectionKeywords(
          required: ['şase', 'motor', 'plaka', 'marka', 'model'],
          bonus: ['tescil', 'ruhsat', 'araç'],
          minRequiredMatches: 3,
        ),
      ),
      onCapture: (file) {
        // Handle captured file
      },
    ),
  ),
);

API Reference

RuhsatCaptureScreen

The main widget. Push it as a full-screen route.

Parameter Type Description
config RuhsatCaptureConfig Configuration options (optional).
onCapture void Function(XFile) Callback when a photo is captured.

RuhsatCaptureConfig

Property Type Default
texts RuhsatCaptureTexts Turkish defaults
frame RuhsatFrameConfig White border, green active
keywords DetectionKeywords Turkish ruhsat keywords
timing RuhsatCaptureTimingConfig 1.2s hold, 0.5s delay
autoCapture bool true
showManualCapture bool true
cameraResolutionPreset ResolutionPreset ResolutionPreset.veryHigh
preferWideAngleLens bool true
initialZoom double 1.0
enableAutoFocus bool true
enableAutoExposure bool true
cropCapturedImageToFrame bool true
frameCropPaddingRatio double 0.08

DetectionKeywords

Controls which OCR keywords trigger document detection. Configure required and bonus keyword lists with match thresholds.

RuhsatFrameConfig

Controls the overlay frame appearance: aspect ratio, corner radius, border colors, center divider, and page labels.

RuhsatCaptureTimingConfig

Controls auto-capture timing: holdDuration (how long document must be visible) and captureDelay (delay before taking photo).

Dependencies

Package Version
camera ^0.11.2+1
google_ml_kit ^0.21.0
flutter_bloc ^9.1.0
equatable ^2.0.7

License

This project is licensed under the MIT License — see the LICENSE file for details.

About

Flutter package for capturing Turkish vehicle registration documents (ruhsat) with ML-based auto-detection using Google ML Kit OCR.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages