Capturing raw image type in Swift

723 views Asked by At

To capture raw images, I am setting this

AVCapturePhotoSettings(rawPixelFormatType: kCVPixelFormatType_24RGB)

But I am getting an invalid argument exception like as

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* +[AVCapturePhotoSettings photoSettingsWithRawPixelFormatType:] Unrecognized raw pixel format type'

The documentation states

If rawPhotoPixelFormatType is non-zero, it must be present in the receiver's -availableRawPhotoPixelFormatTypes array.

How do I add to this array?

What am I missing here?

1

There are 1 answers

0
SafeFastExpressive On

You can't add a format type to availableRawPhotoPixelFormatTypes.

availableRawPhotoPixelFormatTypes describes the types the current camera can support. For example, the front camera and dual cameras don't support raw types at all. You need to search availableRawPhotoPixelFormatTypes for the type you want before trying to use it, and if it's not available use a different format or inform your user.