Unable to edit camera settings using AVCaptureDevice, AVFoundation

Unable to edit camera settings using AVCaptureDevice

Want to edit camera settings before photo capture using iPhone camera, I had used AVCaptureDevice class to edit camera setting, but new settings had not applied to camera and photo taken with random camera settings value. Why this camera setting values not changing, final image produced with some random values?

Find Framework and functions used for the same.


Is Apple dont allow to configure camera settings with custom values? I had checked apples sample app called AVCamValue which also give same result. For eg if we set ISO value 100, it takes 50 as input, and produce image with random value 80.


Framework - AVFoundation


static var myDevice:AVCaptureDevice! = nil



static func ISOValueChanged() {

do {

if ((try myDevice?.lockForConfiguration()) != nil) {

myDevice?.setExposureModeCustom(duration: AVCaptureDevice.currentExposureDuration, iso: 100, completionHandler: nil)

myDevice?.unlockForConfiguration()

}

}catch{}

}

Replies

You have to wait for the ISO setting to be applied. That's why setExposureModeCustom allows you to provide a completion handler. The ISO you provide will only be in effect after the completion handler has been called.


Also: You should put some code in the

catch {}

block. If you just leave it empty, all errors will be ignored and you won't even be notified... at least add a print statement and place a breakpoint on it.