swiftavfoundationcosmicmindavcam

Capture API works bad in dark especially in night time or in previewing dark corners through camera


I was using this library which is https://github.com/CosmicMind/Material. Everything is already working well aside from one which requires a bit of optimization,

I've tried this one which works pretty well with improved lighting in the dark, it is pretty much useful for devices that don't have flash such as iPads.

https://github.com/ooper-shlab/AVCamManual-Swift

I can't seem to get where the lighting optimization happens in the code. I would've help if I have figured out.

The preview really would look a lot darker using the Capture API of material.

Screenshots of each can be seen below: The demo for Material's Capture Api: Cosmicmind's Capture demo

The demo for AVFoundation:AVCamManual Demo screenshot


Solution

  • So after trying to do some trial and error on the code of AVFoundation. Commenting codes until I could see which block of code is responsible for the lighting. I was able to find out that it was the AVCaptureSession.sessionPreset which was originally set to = AVCaptureSessionPresetHigh, after setting it to

    AVCaptureSession.sessionPreset = AVCaptureSessionPresetPhoto

    Now it's better and looks like the default on ios camera app.