-
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
modifying testing image protocol to return square and full-screen images #102
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8388512
mod testing image protocol/ add squared image
617c5e3
adapt to iOS 9
igor-makarov 644a3d7
mod testing image protocol/ add squared image
f2196f2
Merge branch 'squared_full_images' of https://github.com/getbouncer/c…
b4fc244
merge
d14eda1
[RFC] added extension
f32d972
merge
fc4955c
nextSquareAndFullCardImage protocol
e094b08
add objc back to protocol
7304509
hopefully the last commit
171634b
rid of all whitespace i hope
a6799db
missed one whitespace
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,8 @@ import AVKit | |
import VideoToolbox | ||
import Vision | ||
|
||
|
||
@objc public protocol TestingImageDataSource { | ||
@objc func nextImage() -> CGImage? | ||
public protocol TestingImageDataSource: AnyObject { | ||
func nextSquareAndFullImage() -> (CGImage, CGImage)? | ||
} | ||
|
||
@objc open class ScanBaseViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate, ScanEvents, AfterPermissions { | ||
|
@@ -17,8 +16,7 @@ import Vision | |
// this shouldn't get called | ||
} | ||
|
||
|
||
@objc public weak var testingImageDataSource: TestingImageDataSource? | ||
public weak var testingImageDataSource: TestingImageDataSource? | ||
@objc public var errorCorrectionDuration = 1.5 | ||
@objc public var includeCardImage = false | ||
@objc public var showDebugImageView = false | ||
|
@@ -273,29 +271,6 @@ import Vision | |
} | ||
|
||
|
||
/* We're not ready for bardcodes again yet | ||
@available(iOS 11.0, *) | ||
func handleBarcodeResults(_ results: [Any]) { | ||
for result in results { | ||
// Cast the result to a barcode-observation | ||
|
||
if let barcode = result as? VNBarcodeObservation, barcode.symbology == .QR { | ||
|
||
if let payload = barcode.payloadStringValue { | ||
DispatchQueue.main.async { | ||
// XXX FIXME get QR Codes working again | ||
if self.calledDelegate { | ||
return | ||
} | ||
self.calledDelegate = true | ||
self.scanDelegate?.userDidScanQrCode.map { $0(self, payload) } | ||
|
||
} | ||
} | ||
} | ||
} | ||
}*/ | ||
|
||
@available(iOS 11.2, *) | ||
func blockingQrModel(pixelBuffer: CVPixelBuffer) { | ||
let semaphore = DispatchSemaphore(value: 0) | ||
|
@@ -423,7 +398,7 @@ import Vision | |
self.machineLearningSemaphore.signal() | ||
return | ||
} | ||
|
||
guard let fullCardImage = self.toCGImage(pixelBuffer: pixelBuffer) else { | ||
print("could not get the cgImage from the pixel buffer") | ||
self.machineLearningSemaphore.signal() | ||
|
@@ -438,13 +413,13 @@ import Vision | |
|
||
// we allow apps that integrate to supply their own sequence of images | ||
// for use in testing | ||
//let image = self.testingImageDataSource?.nextImage() ?? squareCardImage | ||
let squareAndFullCardImage = self.testingImageDataSource?.nextSquareAndFullImage() ?? (squareCardImage, fullCardImage) | ||
|
||
if #available(iOS 11.2, *) { | ||
if self.scanQrCode { | ||
self.blockingQrModel(pixelBuffer: pixelBuffer) | ||
} else { | ||
self.blockingOcrModel(squareCardImage: squareCardImage, fullCardImage: fullCardImage) | ||
self.blockingOcrModel(squareCardImage: squareAndFullCardImage.0, fullCardImage: squareAndFullCardImage.1) | ||
} | ||
} | ||
|
||
|
@@ -521,7 +496,6 @@ import Vision | |
let rect = CGRect(x: cx - width / 2.0, y: cy - height / 2.0, width: width, height: height) | ||
|
||
self.currentImageRect = rect | ||
jaimejiyepark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove whitespace changes from here and the few other places that they show up? |
||
return image.cropping(to: rect) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
naming individual tuple elements here doesn't seem great people would need to know that .0 is square and .1 is full. For squareAndFullCardImage why not have variables directly, something like
let (square, full) = self.testingImageDataSource...