fingerprint/MODIFICATION_IMPLEMENTATION.md
Aastha Shrivastava 3132b7e8cd first commit
2026-01-17 12:54:01 +05:30

3.7 KiB

Modification Implementation Plan: Camera Stream & Isolate Processing

Phase 1: Preparation & Dependencies

  • Add opencv_dart dependency to pubspec.yaml.
  • Run flutter pub get.
  • Run existing analysis to ensure a clean slate.

Phase 2: Domain & Isolate Logic

  • Create lib/domain/entities/quality_status.dart.
  • Create lib/core/services/image_processor_isolate.dart.
    • Implement the Isolate entry point spawn.
    • Implement the message handling loop.
    • Implement logic to convert CameraImage to cv.Mat.
    • Implement Laplacian variance (Sharpness).
    • Implement mean intensity (Luminance).
    • Implement ROI logic.
    • Return QualityStatus.

Phase 3: Data Layer Updates

  • Update lib/data/datasources/camera_datasource.dart:
    • Add startImageStream method signature and implementation.
    • Add stopImageStream method signature and implementation.
  • Update lib/domain/repositories/scanner_repository.dart interface.
  • Update lib/data/repositories/scanner_repository_impl.dart implementation.

Phase 4: Presentation Layer - State Management

  • Update lib/presentation/providers/scanner_provider.dart:
    • Update ScannerState to include QualityStatus.
    • Update ScannerNotifier:
      • Initialize and dispose the Isolate.
      • Implement startScanning to listen to camera stream.
      • Implement throttling logic (5-10 FPS).
      • Send frames to Isolate and update state with results.

Phase 5: Presentation Layer - UI

  • Create lib/presentation/widgets/fingerprint_guide_painter.dart:
    • Implement CustomPainter to draw the guide rectangle.
    • Accept color/status as parameters.
  • Update lib/presentation/widgets/camera_preview_widget.dart:
    • Replace static overlay with CustomPaint using FingerprintGuidePainter.
    • Connect to ScannerState for dynamic color updates.
  • Update lib/presentation/screens/scanner_screen.dart:
    • Update "Capture" button to be enabled/disabled based on QualityStatus.
    • Trigger startScanning on ready state.

Phase 6: Verification & Cleanup

  • Run dart_fix.
  • Run flutter analyze.
  • Run dart_format.
  • Verify functionality (requires physical device for full camera stream test, or mock for logic).

Phase 7: UI Refinements & Display Configuration

  • Create lib/presentation/providers/display_config_provider.dart for managing UI visibility.
  • Create lib/presentation/widgets/display_config_dialog.dart for settings.
  • Update lib/presentation/widgets/camera_preview_widget.dart:
    • Fix aspect ratio using Transform.scale to fill screen (Live View).
    • Integrate DisplayConfig to toggle guide, quality, and status text.
  • Update lib/presentation/screens/scanner_screen.dart:
    • Add Settings button to AppBar.

Phase 8: Quality Analysis Tuning

  • Update lib/core/services/quality_checker.dart:
    • Increase isBigEnough threshold from 5% to 25% to prevent background objects from validating the position check when the finger is removed.

Journal

  • Initial plan created.
  • Phase 1 complete: Added opencv_dart and verified dependencies.
  • Phase 2 complete: Implemented Isolate logic with opencv_dart.
  • Phase 3 complete: Updated Data and Domain layers for streaming.
  • Phase 4 complete: Implemented State Management with Throttled Stream.
  • Phase 5 complete: Implemented UI with CustomPainter and dynamic feedback.
  • Phase 6 complete: Verified and cleaned up.
  • Phase 7 complete: Fixed CameraPreview aspect ratio and added Display Settings dialog.
  • Phase 8 complete: Tuned quality checker to strictly enforce finger presence (25% area coverage).