Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card scanner module - Business layer #2008

Open
wants to merge 13 commits into
base: COIOS-826_OCR_feature
Choose a base branch
from

Conversation

nauaros
Copy link
Contributor

@nauaros nauaros commented Feb 10, 2025

Summary

This PR introduces the core UI and business logic for the card scanner, following the MVVM architectural pattern.

CardScannerViewModel

  • Configures and manages the AVCaptureSession:
    • Starts and stops the session in sync with the view lifecycle.
    • Sets up input and output sources.
  • Configures the AVCaptureDevice:
    • Adjusts minimum and maximum frame rates.
    • Sets focus and exposure modes.
  • Processes captured images:
    • Extracts and scales the region of interest using cropRegionOfInterest.

CardScannerViewController

  • Acts as the main view controller for the card scanner.
  • Contains CardScannerOverlayView, which renders the mask and highlights the region of interest.

Next Steps

  • Implement the assembler layer and SDK entry point.
  • Add unit tests for CardImageParser.
    • The idea is to have a series of card images against we can write automated tests.
  • Add unit tests for the MVVM module.

Ticket

COIOS-826

@nauaros nauaros self-assigned this Feb 10, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['new', 'changed', 'fixed', 'removed', 'deprecated', 'chore', 'improvement']

@nauaros nauaros marked this pull request as ready for review February 11, 2025 11:46
@atmamont atmamont added chore a pull request that has chore changes that shouldn't be in the release notes new a pull request that adds a new feature and removed chore a pull request that has chore changes that shouldn't be in the release notes labels Feb 11, 2025
@nauaros nauaros added chore a pull request that has chore changes that shouldn't be in the release notes and removed new a pull request that adds a new feature labels Feb 11, 2025
@goergisn goergisn self-requested a review February 11, 2025 15:23
@nauaros nauaros requested a review from atmamont February 14, 2025 12:36
Copy link
Contributor

✅ No changes detected

Comparing card-scanner-mvp to COIOS-826_OCR_feature


Analyzed targets: Adyen, AdyenActions, AdyenCard, AdyenCashAppPay, AdyenComponents, AdyenDelegatedAuthentication, AdyenDropIn, AdyenEncryption, AdyenSession, AdyenSwiftUI, AdyenTwint, AdyenWeChatPay

private func configureCaptureSession() throws {
captureSession.beginConfiguration()

// Set up input
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments are redundant, code speaks better

}

private func configureCaptureDevice(_ device: AVCaptureDevice) {
try? device.lockForConfiguration()
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if this fails?

@@ -46,17 +46,17 @@ class CardScannerViewController: UIViewController {
addOverlayView()
observeRoiLayoutChanges()

viewModel.configureSession()
viewModel.viewDidLoad()
Copy link
Contributor

Choose a reason for hiding this comment

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

These are lifecycle methods of a UIViewController, what is the reason to leak them to the view model layer? This approach might be fragile if we ever decide using this outside of UIKit (think of SwiftUI for example).

try? device.lockForConfiguration()

// Adjust Frame Rate
device.activeVideoMinFrameDuration = CMTime(value: 1, timescale: 15) // 15 fps
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it move to Constants?

case .portrait:
return .portrait
case .landscapeRight:
return .landscapeLeft // Camera flips the orientation
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we flip it for both left and right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a pull request that has chore changes that shouldn't be in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants