Configuring CaptureVideoDelegate to avoid gamma/transfer function

I'm working on an application that uses the iPhone camera for scientific purposes - and, as a result would like to receive video in as unprocessed format as possible.

In particular, I'm interested in getting pixel buffers that contain pretty much the bayer data as the sensor sees it - with the minimum processing of color possible.

Currently we configure the AVCaptureDevice to fix the focus and exposure, use a low ISO with no gain and set the white balance gains to 1. AVCaptureVideoDataOutput is using 32BGRA.

What I'd like to do is remove any additional color and brightness processing such that the data is effectively processed with a linear transfer function (i.e. gamma function is 1).

I thought that this might be down to using the AVCaptureDevice activeColorSpace - we currently use P3_D65 for this. But there only seems to be a few choices (e.g. sRGB, HLG_BT2020) all of which I think affect the gamma.

So:

  1. is it possible to control or specify the gamma / transfer function when using CaptureVideoDelegate?
  2. if not, does one of the color space settings have a defined gamma function that I can effectively reverse it from the pixel data without losing too much information?
  3. or is there a better way to capture video-ish speed images (15-30fps) from the camera sensor that skips processing like this?

Many thanks for any suggestions.

Hi woodcoder, Sounds like the closest thing we can offer you is the use of AppleLog, which has a defined and published log curve. You can get this from AVCaptureVideoDataOutput when you set your source format to x422 (which is only available on some phones — pro phones). You'd also need to set your AVCaptureSession's automaticallyConfiguresCaptureDeviceForWideColor property to NO, and then set your AVCaptureDevice's activeColorSpace to AVCaptureColorSpace_AppleLog.

Another alternative is to use the AVCapturePhotoOutput to take Bayer RAW stills at some moderate cadence, such as 5-10 fps. Bayer RAW has no color space / transfer function associated with it.

Thank you so much for the information. We're unfortunately currently using an iPhone SE (3rd gen) although likely to upgrade to a 16e shortly - so that probably rules out the AppleLog approach.

Is the second approach (AVCapturePhotoOutput to take Bayer RAW) likely to work on either or both devices do you know?

Configuring CaptureVideoDelegate to avoid gamma/transfer function
 
 
Q