Skip to content

MS-1494 Unified camera frame provider - #1766

Merged
luhmirin-s merged 3 commits into
mainfrom
feature/MS-1494-unified-camera-frame-provider
Aug 11, 2026
Merged

MS-1494 Unified camera frame provider#1766
luhmirin-s merged 3 commits into
mainfrom
feature/MS-1494-unified-camera-frame-provider

Conversation

@luhmirin-s

Copy link
Copy Markdown
Contributor

JIRA ticket
Will be released in: 2026.3.0

Notable changes

  • Implementation of a generalised camera helper module that takes care of camera initialisation and capture logic.
  • The actual camera frames are exposed via a single flow for easy consumption on the caller side.
  • Each returned frame contains the original bitmap and additional information required for post processing (mainly cropping to preview target size). Images are not pre-cropped since the spoofing check requires the original image, although a simple cropping use-case is provided as part of the module.
  • Frame provider also has a special "high resolution" mode that changes the direct analyser image emission to explicit image capture. Note that returned images are still normalised to match the dimensions of the preview to make target crop work correctly.
  • To avoid wasting resources, the caller can disable frame emission while it is busy processing a previous frame.
  • As a bonus, the module contains a basic post-processing use case to decode QRs, it will come in handy for MFID QR and login modules in upcoming PRs.

While this might seem as a complicated setup in isolation, it is the minimal amount of functionality that covers all existing use cases in our modules while providing a solid base for the test image injection. It will become clearer when more PRs are added to the stack.

Testing guidance

  • For now just unit tests and sanity checks, future PRs will have the actual changes in feature modules.

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new :infra:camera module intended to centralize CameraX initialization/capture and expose a unified stream of camera frames (with optional high-resolution capture mode), plus basic post-processing utilities (target crop + QR decode). This fits the infra layer by providing reusable camera and image-processing building blocks for upcoming feature-module changes.

Changes:

  • Added :infra:camera module with CameraFrameProvider, frame emission controller, focus helper, bitmap normalization, cropping, and QR detection use cases.
  • Added unit tests for bitmap normalization, target cropping, and frame emission gating.
  • Wired the new module into Gradle settings, CI path filters/matrix, and logging crash-report tags (CrashReportTag.CAMERA).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
settings.gradle.kts Includes the new :infra:camera module in the build.
infra/logging/src/main/java/com/simprints/infra/logging/LoggingConstants.kt Adds CAMERA crash-report tag for camera-related logging.
infra/camera/build.gradle.kts Defines the new infra camera module and its dependencies (CameraX + MLKit barcode).
infra/camera/src/main/AndroidManifest.xml Adds minimal manifest for the new Android library module.
infra/camera/.gitignore Ignores the module’s build outputs.
infra/camera/src/main/java/com/simprints/infra/camera/Frame.kt Introduces a frame model carrying bitmap + rotation + preview/target bounds.
infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt Implements unified frame emission + high-res capture mode over CameraX.
infra/camera/src/main/java/com/simprints/infra/camera/helpers/FrameEmissionHelper.kt Adds gating logic to pause/resume emission and serialize high-res captures.
infra/camera/src/main/java/com/simprints/infra/camera/helpers/CameraFocusHelper.kt Adds focus-on-tap and autofocus setup utilities for PreviewView.
infra/camera/src/main/java/com/simprints/infra/camera/usecase/NormalizeHighResBitmapToPreviewUseCase.kt Normalizes high-res captures to match preview aspect ratio and dimensions.
infra/camera/src/main/java/com/simprints/infra/camera/postprocess/FrameCropToTargetUseCase.kt Crops emitted frames to a target rectangle derived from preview overlay bounds.
infra/camera/src/main/java/com/simprints/infra/camera/postprocess/DetectQrCodeUseCase.kt Adds MLKit-based QR decoding from a frame bitmap with error logging.
infra/camera/src/test/java/com/simprints/infra/camera/usecase/NormalizeBitmapToPreviewUseCaseTest.kt Adds tests for high-res normalization (naming currently mismatched).
infra/camera/src/test/java/com/simprints/infra/camera/postprocess/FrameCropToTargetUseCaseTest.kt Adds tests validating cropping behavior across preview/image size scenarios.
infra/camera/src/test/java/com/simprints/infra/camera/helpers/FrameEmissionControllerTest.kt Adds tests for frame emission gating (file/class naming mismatch).
.github/workflows/pr-checks.yml Ensures infra/camera/** participates in CI change detection and unit test matrix.
Suppressed comments (1)

infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt:190

  • emitFrame() calls tryEmit on frames, but frames is exposed as Flow (read-only) and doesn’t provide tryEmit. Emit on the backing MutableSharedFlow instead.
        frames.tryEmit(Frame(bitmap = bitmap, rotation = rotation, previewBounds = previewRect, targetBounds = targetRect))

Comment thread infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt Outdated
Comment thread infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt Outdated
@luhmirin-s
luhmirin-s force-pushed the feature/MS-1494-unified-camera-frame-provider branch from 92bf21e to f8add24 Compare August 6, 2026 10:44
@luhmirin-s
luhmirin-s requested review from a team, BurningAXE, TristramN, alex-vt, alexandr-simprints, meladRaouf and ybourgery and removed request for a team August 6, 2026 11:05
class FrameCropToTargetUseCase @Inject constructor() {
operator fun invoke(frame: Frame): Bitmap {
if (frame.targetBounds.isEmpty) {
return frame.bitmap

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say we should log something here (exception, even?) - calling the cropping use case without target bounds doesn't seem to make sense, and probably indicates that some logic is wrong upstream

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but I am not sure how helpful it would be. This prevent a crash if something went extremely wrong. We are likely to catch the such issues while debugging preview than while looking at logs.

Comment thread infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt Outdated
Comment thread infra/camera/src/main/java/com/simprints/infra/camera/CameraFrameProvider.kt Outdated
@luhmirin-s
luhmirin-s force-pushed the feature/MS-1494-unified-camera-frame-provider branch 2 times, most recently from f868ae5 to 824ca4b Compare August 10, 2026 12:42
@luhmirin-s
luhmirin-s force-pushed the feature/MS-1494-unified-camera-frame-provider branch from 824ca4b to dca35ac Compare August 11, 2026 08:48
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
53.1% Coverage on New Code (required ≥ 80%)
5.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@luhmirin-s
luhmirin-s merged commit b31a1b3 into main Aug 11, 2026
12 of 14 checks passed
@luhmirin-s
luhmirin-s deleted the feature/MS-1494-unified-camera-frame-provider branch August 11, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants