Search code examples
iosavfoundation

How to get ultra wide camera calibration data?


Is it possible to get calibration data AVCapturePhoto::cameraCalibrationData for ultra wide camera?

Documentation says:

Camera calibration data is present only if you specified the cameraCalibrationDataDeliveryEnabled and dualCameraDualPhotoDeliveryEnabled settings when requesting capture.

but dualCameraDualPhotoDeliveryEnabled was deprecated.

I tried to set cameraCalibrationDataDeliveryEnabled for builtInDualWideCamera and builtInUltraWideCamera without any success.


Solution

  • The calibration data is meant to give you information about the intrinsics of multiple cameras in a virtual camera capture scenario. This used to be the dual camera (introduced with the iPhone X), but with the release of the iPhone 11 Pro, the API switched it's naming. It's now called isVirtualDeviceConstituentPhotoDeliveryEnabled and you can now specify the set of cameras that should be involved in the capture with virtualDeviceConstituentPhotoDeliveryEnabledDevices.

    Note that the calibration data only seem to be available for virtual devices with at least two cameras involved (so builtInDualCamera, builtInDualWideCamera and builtInTripleCamera).

    Furthermore, if using a virtual device which includes the ultra wide camera (only have tested with builtInDualWideCamera), you need to disable geometric distortion via captureDevice.isGeometricDistortionCorrectionEnabled=false to disable the distortion correction on the ultra wide in order to enable camera calibration data delivery.