I reported this bug to your guys. And I test it today with iOS 12.1, but the portrait matte is still nil with pixelformat output. So I'm here to ask when this issue could be fixed. Thank you.
First I enable the depth and portrait matte in AVCapturePhotoOutput.
if (photoOutput.isDepthDataDeliverySupported)
{
[photoOutput setDepthDataDeliveryEnabled:YES];
}
if (@available(iOS 12.0, *))
{
if (photoOutput.isPortraitEffectsMatteDeliverySupported)
{
[photoOutput setPortraitEffectsMatteDeliveryEnabled:YES];
}
}
And I wrote this when I press the capture button.
AVCapturePhotoSettings * photoSettings = [AVCapturePhotoSettings photoSettingsWithFormat:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey, nil]];
if (photoOutput.isDepthDataDeliverySupported)
{
[photoSettings setDepthDataDeliveryEnabled:YES];
photoSettings.embedsDepthDataInPhoto = NO;
}
if (@available(iOS 12.0, *))
{
if (photoOutput.isPortraitEffectsMatteDeliverySupported)
{
[photoSettings setPortraitEffectsMatteDeliveryEnabled:YES];
photoSettings.embedsPortraitEffectsMatteInPhoto = NO;
}
}
[photoOutput capturePhotoWithSettings:photoSettings delegate:self];
Finally get this callback.
- (void)captureOutput:(AVCapturePhotoOutput *)output didFinishProcessingPhoto:(AVCapturePhoto *)photo error:(nullable NSError *)error
{
if (@available(iOS 12.0, *))
{
NSLog(@"%@", photo.portraitEffectsMatte ? @"Matte": @"nil");
}
}