3.7 KiB
3.7 KiB
Modification Implementation Plan: Camera Stream & Isolate Processing
Phase 1: Preparation & Dependencies
- Add
opencv_dartdependency topubspec.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
CameraImagetocv.Mat. - Implement
Laplacianvariance (Sharpness). - Implement
meanintensity (Luminance). - Implement ROI logic.
- Return
QualityStatus.
- Implement the Isolate entry point
Phase 3: Data Layer Updates
- Update
lib/data/datasources/camera_datasource.dart:- Add
startImageStreammethod signature and implementation. - Add
stopImageStreammethod signature and implementation.
- Add
- Update
lib/domain/repositories/scanner_repository.dartinterface. - Update
lib/data/repositories/scanner_repository_impl.dartimplementation.
Phase 4: Presentation Layer - State Management
- Update
lib/presentation/providers/scanner_provider.dart:- Update
ScannerStateto includeQualityStatus. - Update
ScannerNotifier:- Initialize and dispose the Isolate.
- Implement
startScanningto listen to camera stream. - Implement throttling logic (5-10 FPS).
- Send frames to Isolate and update state with results.
- Update
Phase 5: Presentation Layer - UI
- Create
lib/presentation/widgets/fingerprint_guide_painter.dart:- Implement
CustomPainterto draw the guide rectangle. - Accept color/status as parameters.
- Implement
- Update
lib/presentation/widgets/camera_preview_widget.dart:- Replace static overlay with
CustomPaintusingFingerprintGuidePainter. - Connect to
ScannerStatefor dynamic color updates.
- Replace static overlay with
- Update
lib/presentation/screens/scanner_screen.dart:- Update "Capture" button to be enabled/disabled based on
QualityStatus. - Trigger
startScanningon ready state.
- Update "Capture" button to be enabled/disabled based on
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.dartfor managing UI visibility. - Create
lib/presentation/widgets/display_config_dialog.dartfor settings. - Update
lib/presentation/widgets/camera_preview_widget.dart:- Fix aspect ratio using
Transform.scaleto fill screen (Live View). - Integrate
DisplayConfigto toggle guide, quality, and status text.
- Fix aspect ratio using
- 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
isBigEnoughthreshold from 5% to 25% to prevent background objects from validating the position check when the finger is removed.
- Increase
Journal
- Initial plan created.
- Phase 1 complete: Added
opencv_dartand 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).