Question

I'm confused!

I'm trying to manually adjust the exposure to fit the CGPoint in the center of the preview. I'm taking the device object and using setExposureMode and setExposurePointOfInterest in order to do the manipulation. The first thing I do is check to see if exposure mode is supported by the device. If not supported then return. If it is supported then set the values. My confusion is stemming from the fact that the value for device isExposureModeSupported:exposureMode returns NO. But it is supported! I have an iPhone 5c. If I ignore the return statement I do not receive any errors.

- (void)device:(AVCaptureDevice *)device exposureMode:(AVCaptureExposureMode)exposureMode  atPoint:(CGPoint)point
{
    BOOL exposureModeSupported = [device isExposureModeSupported:exposureMode];
    if (!exposureModeSupported)
        return;

    if ([device lockForConfiguration:&error]) {
        [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
        [device setExposurePointOfInterest:point];

        CALayer *exposeRect = [CALayer layer];
        exposeRect.frame = CGRectMake(self.center.x-30, self.center.y-30, 60, 60);
        exposeRect.borderColor = [UIColor whiteColor].CGColor;
        exposeRect.borderWidth = 2;
        exposeRect.name = @"exposeRect";
        [self.previewLayer addSublayer:exposeRect];
        [NSTimer scheduledTimerWithTimeInterval: 1
                                         target: self
                                       selector: @selector(dismissExposeRect)
                                       userInfo: nil
                                        repeats: NO];
        [device setExposureMode:AVCaptureExposureModeContinuousAutoExposure];
        [device unlockForConfiguration];
    }
}

How can I check if exposure mode is supported if I can't trust the value returned?

I ended up AND-ing the check, but I'm not sure this is the correct way to check. The condition now looks like this:

if (![device isExposurePointOfInterestSupported] && ![device isExposureModeSupported:exposureMode])
    return;

Has anyone else come across this and does anyone know how to properly handle this?

Thank you in advance.

Was it helpful?

Solution 2

I guess nobody wanted to chime in on this one. I ended up AND-ing the check, but I'm not sure this is the correct way to check but it worked.

OTHER TIPS

Yes, you should check for exposurePointOfInterestSupported AND isExposureModeSupported:.

In your case, you are checking if the AVCaptureExposureMode given as an argument in your function is supported, but set the exposure to AVCaptureExposureModeContinuousAutoExposure, which is not necessarily supported.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top