I am not sure if this is the best solution since I struggled with this as you. I did this to listen to the exposure bias changes and adjust the ISO from them until you reach an acceptable exposure level. Most of this code was taken from Apple's sample code.
So, first of all, you are listening to the changes in the ExposureTargetOffset. Add to the class declaration:
static void *ExposureTargetOffsetContext = &ExposureTargetOffsetContext;
Then, once you have configured your device setup correctly:
[self addObserver:self forKeyPath:@"captureDevice.exposureTargetOffset" options:NSKeyValueObservingOptionNew context:ExposureTargetOffsetContext];
(Instead of captureDevice, use your property for the device) Then implement a callback for KVO in your class:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ if (context == ExposureTargetOffsetContext){ float newExposureTargetOffset = [change[NSKeyValueChangeNewKey] floatValue]; NSLog(@"Offset is : %f",newExposureTargetOffset); if(!self.device) return; CGFloat currentISO = self.device.ISO; CGFloat biasISO = 0;
With this code, the shutter speed will remain constant and the ISO will be adjusted so that the image is not too overexposed or overexposed.
Remember to remove the observer whenever necessary. Hope this suits you.
Hurrah!
khose source share