iPhone 5: AVCaptureExposureModeAutoFocus not suppo

2019-07-16 10:30发布

I am trying to implement a camera application using AVFoundation. I want to use the AVCaptureExposureModeAutoFocus to set the exposurePointOfInterest at a point, and then lock the exposure as explained by Apple's documentation:

AVCaptureExposureModeAutoExpose: the device automatically adjusts the exposure once and then changes the exposure mode to AVCaptureExposureModeLocked.

This is the function that I used:

-(void)autoExposeAtPoint:(CGPoint)point
{
    AVCaptureDevice *device = [videoInput device];
    if([device isExposurePointOfInterestSupported] && [device isExposureModeSupported:AVCaptureExposureModeAutoExpose]){
        if([device lockForConfiguration:NULL]){
            [device setExposurePointOfInterest:point];
            [device setExposureMode:AVCaptureExposureModeAutoExpose];
            [device unlockForConfiguration];
            NSLog(@"Exposure point of intereset has been set to (%f,%f)",point.x, point.y);
        }
    }
}

However, the auto exposure at the desired point just never happened. As I debugged using the NSLog below, it turned out that AVCaputreExposureModeAutoExpose is not supported. Whereas, if I used AVCaptureExposureModeContinuousAutoExpose, it would run perfectly.

I don't understand this; is this true that this AVCaputreExposureModeAutoExpose is not supported in iPhone 5's back camera running iOS7? Anyone has any clue? THANKS!

Debug Code:

NSLog(@"issupported: %hhd", [device isExposurePointOfInterestSupported]);
NSLog(@"ismodesupported: %hhd" ,[device isExposureModeSupported:AVCaptureExposureModeAutoExpose]);

**Result:**
issupported: 1
ismodesupported: 0

1条回答
走好不送
2楼-- · 2019-07-16 11:00

I posted this question on Apple developer forum and got answered by Brad Ford (Core Media Engineering) the speaker for Camera with AV Foundation in Apple's WWDC.

Here's his answer:

Correct. AVCaptureExposureModeAutoExpose, while defined in the header, is not currently implemented on any iOS device.

You can however implement it in your own code by setting your desired point of interest, then calling setExposureMode:AVCaptureExposureModeContinuousAutoExposure, and then listen (key-value observe) the "isAdjustingExposure" property of AVCaptureDevice to know when the exposure finishes adjusting. As soon as it does, setExposureMode to AVCaptureExposureModeLocked.

查看更多
登录 后发表回答