iPhone 5: AVCaptureExposureModeAutoFocus not supported in iOS 7

心不动则不痛 提交于 2019-12-24 06:16:10

问题


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:


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.



来源:https://stackoverflow.com/questions/21361087/iphone-5-avcaptureexposuremodeautofocus-not-supported-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!