portraitEffectsMatte is still nil in iOS 12.1

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"); 
     } 
}

Replies

We do thank you for the bug report, evolrof. I can confirm that this is a bug. The fix is not in iOS 12.1 but is coming in a future update. As a workaround for now, you can get a portrait effects matte when using JPEG or HEIC as the output format.

I still use the file output to get portrait effect matte in current version of my app. I'll test it later when you release an update of iOS. Thank you.