MS-1496 Frame provider implementation in ocr capture - #1767
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the MFID OCR capture flow in :feature:external-credential from a feature-local CameraX + bitmap pre-processing pipeline to the shared :infra:camera frame provider and post-processing crop use case, aligning OCR capture with the new camera architecture.
Changes:
- Replace per-frame bitmap normalization/cropping with
CameraFrameProvider+FrameCropToTargetUseCase. - Move OCR config readiness to an awaited flow (
awaitOcrConfig) and initialise the camera once the preview/target bounds are known. - Remove obsolete OCR camera/crop config use cases and their unit tests; update ViewModel tests to use
Frameinput.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| feature/external-credential/src/test/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/NormalizeBitmapToPreviewUseCaseTest.kt | Removed tests for feature-local bitmap normalization (now handled elsewhere). |
| feature/external-credential/src/test/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/CropDocumentFromPreviewUseCaseTest.kt | Removed tests for feature-local cropping (cropping moved to post-processing use case). |
| feature/external-credential/src/test/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/BuildOcrCropConfigUseCaseTest.kt | Removed tests for feature-local crop-config building (target rect now provided to frame provider). |
| feature/external-credential/src/test/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrViewModelTest.kt | Updated tests to pass Frame and mock FrameCropToTargetUseCase. |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/ProvideCameraListenerUseCase.kt | Removed obsolete CameraX binding wrapper (replaced by CameraFrameProvider). |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/NormalizeBitmapToPreviewUseCase.kt | Removed feature-local bitmap normalization (now using new pipeline). |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/CropDocumentFromPreviewUseCase.kt | Removed feature-local cropping (delegated to post-processing). |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/usecase/BuildOcrCropConfigUseCase.kt | Removed feature-local crop config builder (target bounds now computed once). |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/model/OcrCropConfig.kt | Removed crop config model (no longer needed in new flow). |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrViewModel.kt | Switched processing to Frame input + post-process crop; moved config to flow; refactored processing state flag. |
| feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrFragment.kt | Initialises CameraFrameProvider with target bounds; processes emitted frames and gates emission based on processing flag. |
| feature/external-credential/build.gradle.kts | Adds :infra:camera dependency needed for the new frame provider flow. |
Suppressed comments (2)
feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrViewModel.kt:169
finishOcrEvent.send(...)won’t compile becausesend(...)is an extension onMutableLiveData<LiveDataEventWithContent<T>>, not onLiveData. Use the backingMutableLiveData(e.g._finishOcrEvent).
viewModelScope.launch {
val scannedCredentialResult = buildScannedCredentialResultUseCase(scannedMfidDocuments, ocrDocumentType, startTime)
finishOcrEvent.send(scannedCredentialResult)
scannedMfidDocuments = emptyList()
feature/external-credential/src/main/java/com/simprints/feature/externalcredential/screens/scanocr/ExternalCredentialScanOcrFragment.kt:102
cameraFocusManagerFactoryandbgDispatcherare injected but no longer used after switching toCameraFrameProvider(focus setup is handled insideCameraFrameProvider.initialiseCamera(...)). Removing these avoids unused DI bindings (and lets you drop the now-unused imports/annotation).
@Inject
lateinit var cameraFocusManagerFactory: CameraFocusManager.Factory
@Inject
@DispatcherBG
lateinit var bgDispatcher: CoroutineDispatcher
24c5b38 to
e3c42f8
Compare
e3c42f8 to
d1367e5
Compare
8a56cb4 to
e5107cb
Compare
e5107cb to
2d3971f
Compare
|



JIRA ticket
Will be released in: 2026.3.0
Notable changes
Testing guidance
Additional work checklist