Skip to content

Instantly share code, notes, and snippets.

@hietalajulius
Last active August 24, 2022 09:09
Show Gist options
  • Save hietalajulius/bee479f2f819ed113cb36f820c6bad05 to your computer and use it in GitHub Desktop.
Save hietalajulius/bee479f2f819ed113cb36f820c6bad05 to your computer and use it in GitHub Desktop.
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
guard let pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) else {
return
}
let imageRequestHandler = VNImageRequestHandler(cvPixelBuffer: pixelBuffer, orientation: .right, options: [:])
do {
let start = CACurrentMediaTime()
try imageRequestHandler.perform(self.requests)
inferenceTime = (CACurrentMediaTime() - start)
} catch {
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment