Skip to content

Instantly share code, notes, and snippets.

@jamesonthecrow
Created May 15, 2019 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesonthecrow/eccb7f45cf8fbe9155f70e7ad4cbb153 to your computer and use it in GitHub Desktop.
Save jamesonthecrow/eccb7f45cf8fbe9155f70e7ad4cbb153 to your computer and use it in GitHub Desktop.
Pet Segmentation iOS View Controller with Fritz (www.fritz.ai)
extension ViewController: AVCaptureVideoDataOutputSampleBufferDelegate {
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
let image = FritzVisionImage(buffer: sampleBuffer)
image.metadata = FritzVisionImageMetadata()
image.metadata?.orientation = FritzImageOrientation(from: connection)
guard let result = try? visionModel.predict(image) else { return }
let mask = result.buildSingleClassMask(
forClass: FritzVisionPetSegmentationClass.pet,
resize: false,
color: UIColor.red)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment