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

providing client-side function with current frames number and predicted number #111

Merged
merged 7 commits into from
Jan 19, 2020

Conversation

jaimejiyepark
Copy link
Collaborator

  • Exposed the current frame's card number to the return of OCR's performWithErrorCorrection()
  • The function uponPredictedCardNumber() allows clients to handle the case where the predicted number and expected number do not align with their own implementation

Copy link
Collaborator

@kingst kingst left a comment

Choose a reason for hiding this comment

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

One concern I have about this direction is that when you predict it has a bunch of side effects and cleaning those up is going to be messy. How about something like passing a predicate that ScanBase implements, subclasses can override, and nullifies a prediction before it has any side effects in Ocr.swift?

Copy link
Collaborator

@kingst kingst left a comment

Choose a reason for hiding this comment

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

Logic looks good, left a few comments / questions

@@ -60,8 +60,8 @@ public class Ocr {
}

@available(iOS 11.2, *)
public func performWithErrorCorrection(for croppedCardImage: CGImage, squareCardImage: CGImage, fullCardImage: CGImage) -> (String?, Expiry?, Bool, Bool) {
let number = self.perform(croppedCardImage: croppedCardImage, squareCardImage: squareCardImage, fullCardImage: fullCardImage)
public func performWithErrorCorrection(for croppedCardImage: CGImage, squareCardImage: CGImage, fullCardImage: CGImage, predictedNumberPredicate: (String?, String) -> Bool ) -> (String?, Expiry?, Bool, Bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you look at if it's possible to have a default parameter for the predictedNumbersPredicate, something like { _, _ in true}

I don't know if this is possible with Swift or if there are any subtleties, so we should be thorough if we do go down this route

@@ -90,9 +90,17 @@ public class Ocr {
}

@available(iOS 11.2, *)
public func perform(croppedCardImage: CGImage, squareCardImage: CGImage?, fullCardImage: CGImage?) -> String? {
public func perform(croppedCardImage: CGImage, squareCardImage: CGImage?, fullCardImage: CGImage?, predictedNumberPredicate: (String? , String) -> Bool ) -> String? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here for default value

@@ -304,6 +304,12 @@ import UIKit
}
}

public override func usePredictedCardNumber(predictedNumber: String?, currentFrameNumber: String) -> Bool {
print("predicted number: \(predictedNumber)")
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you remove these print statements?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yup

@@ -304,6 +304,12 @@ import UIKit
}
}

public override func usePredictedCardNumber(predictedNumber: String?, currentFrameNumber: String) -> Bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe change the name to useCurrentFrameNumber since I think that the predictedNumber here is the error corrected number

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you got it

Copy link
Collaborator

@kingst kingst left a comment

Choose a reason for hiding this comment

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

Few more naming suggestions. Can you change the title of this PR also? You can definitely drop the [RFC] and I believe that it is now about something different then "Added current frame to ocr return"

@@ -304,6 +304,10 @@ import UIKit
}
}

public override func useCurrentFrameNumber(predictedNumber: String?, currentFrameNumber: String) -> Bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you change predictedNumber to errorCorrectedNumber to make the distinction more clear (the current frame number is also predicted).

@@ -60,8 +60,8 @@ public class Ocr {
}

@available(iOS 11.2, *)
public func performWithErrorCorrection(for croppedCardImage: CGImage, squareCardImage: CGImage, fullCardImage: CGImage) -> (String?, Expiry?, Bool, Bool) {
let number = self.perform(croppedCardImage: croppedCardImage, squareCardImage: squareCardImage, fullCardImage: fullCardImage)
public func performWithErrorCorrection(for croppedCardImage: CGImage, squareCardImage: CGImage, fullCardImage: CGImage, predictedNumberPredicate: (String?, String) -> Bool = { _,_ in true } ) -> (String?, Expiry?, Bool, Bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of predictedNumberPredicate how about useCurrentFrameNumber?

@jaimejiyepark jaimejiyepark changed the title [RFC] Added current frame to ocr return providing client-side function with current frames number and predicted number Jan 18, 2020
Copy link
Collaborator

@kingst kingst left a comment

Choose a reason for hiding this comment

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

#shipit

@jaimejiyepark jaimejiyepark merged commit aadaee7 into master Jan 19, 2020
@jaimejiyepark jaimejiyepark deleted the predict_number_functionality branch January 19, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants