Trying to use VNGeneratePersonSegmentationRequest.. it seems to work but the output mask isn't at the same resolution as the source image.. so comping the result with the source produces a bad result.
Not the full code, but hopefully enough to see what I'm doing.
var imageRect = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
let imageRef = image.cgImage(forProposedRect: &imageRect, context: nil, hints: nil)!
let request = VNGeneratePersonSegmentationRequest()
let handler = VNImageRequestHandler(cgImage: imageRef)
do {
try handler.perform([request])
guard let result = request.results?.first else {
return
}
//Is this the right way to do this?
let output = result.pixelBuffer
//This ciImage alpha mask is a different resolution than the source image
//So I don't know how to combine this with the source to cut out the foreground as they don't line up.. the res it's even the right aspect ratio.
let ciImage = CIImage(cvPixelBuffer: output)
.....
}