Skip to content

Instantly share code, notes, and snippets.

@iosdevie
Last active June 29, 2021 12:54
Show Gist options
  • Save iosdevie/a613c2d42468d7974559f0b67ab13e18 to your computer and use it in GitHub Desktop.
Save iosdevie/a613c2d42468d7974559f0b67ab13e18 to your computer and use it in GitHub Desktop.
func runVisionRequest(){
let request = VNGeneratePersonSegmentationRequest()
request.qualityLevel = .accurate
request.outputPixelFormat = kCVPixelFormatType_OneComponent8
let handler = VNImageRequestHandler(cgImage: inputImage.cgImage!, options: [:])
do {
try handler.perform([request])
let mask = request.results!.first!
let maskBuffer = mask.pixelBuffer
maskInputImage(maskBuffer)
}catch {
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment