-
Notifications
You must be signed in to change notification settings - Fork 68
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
Conversation
There was a problem hiding this 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?
There was a problem hiding this 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
CardScan/Classes/Ocr.swift
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
CardScan/Classes/Ocr.swift
Outdated
@@ -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? { |
There was a problem hiding this comment.
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)") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you got it
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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).
CardScan/Classes/Ocr.swift
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#shipit
OCR
'sperformWithErrorCorrection()
uponPredictedCardNumber()
allows clients to handle the case where the predicted number and expected number do not align with their own implementation