Last active
June 19, 2017 09:59
-
-
Save jknthn/2d4f1eff11f72dbee11dbde1d56e5885 to your computer and use it in GitHub Desktop.
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
private let classifier = Resnet50() | |
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) { | |
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) | |
let rescaled = rescaledImageRectangle(createUIImage(from: imageBuffer), dimension: inputImageScale) | |
let rescaledBuffer = createCVPixelBuffer(from: rescaled) | |
guard let prediction = try? classifier.prediction(image: rescaledBuffer!) else { return } | |
DispatchQueue.main.async { | |
self.predictionLabel.text = prediction.classLabel | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment