Created
March 4, 2019 14:36
-
-
Save giln/1fd0d2a60f10474ba1e150956a871024 to your computer and use it in GitHub Desktop.
ARSessionDelegate
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
// MARK: - ARSessionDelegate | |
var currentBuffer: CVPixelBuffer? | |
func session(_: ARSession, didUpdate frame: ARFrame) { | |
// We return early if currentBuffer is not nil or the tracking state of camera is not normal | |
guard currentBuffer == nil, case .normal = frame.camera.trackingState else { | |
return | |
} | |
// Retain the image buffer for Vision processing. | |
currentBuffer = frame.capturedImage | |
startDetection() | |
} | |
// MARK: - Private functions | |
private func startDetection() { | |
// Here we will do our CoreML request on currentBuffer | |
// Release currentBuffer to allow processing next frame | |
currentBuffer = nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment