iPhone相机曝光/对焦锁定:它不会保持锁定状态
我正在尝试以编程方式使用 iPhone 相机从同一场景拍摄多张照片,并且我不希望在用户将其设置为第一张照片后曝光或焦点发生变化。 这是当用户从我的应用程序内启动拍照时执行的代码:
NSArray *devices = [AVCaptureDevice devices];
NSError *error;
for (AVCaptureDevice *device in devices) {
if (([device hasMediaType:AVMediaTypeVideo]) &&
([device position] == AVCaptureDevicePositionBack) ) {
[device lockForConfiguration:&error];
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeLocked]) {
device.whiteBalanceMode = AVCaptureWhiteBalanceModeLocked;
NSLog(@"Whitebalanced locked");
}
if ([device isExposureModeSupported:AVCaptureExposureModeLocked]) {
device.exposureMode = AVCaptureExposureModeLocked;
NSLog(@"Exposure locked");
}
if ([device isFocusModeSupported:AVCaptureFocusModeLocked]) {
device.focusMode = AVCaptureFocusModeLocked;
NSLog(@"Focus locked");
}
[device unlockForConfiguration];
}
}
问题:拍摄第一张照片后,相机会自动对焦和自动曝光。如何强制曝光和焦点保持锁定?
任何帮助表示赞赏。
I am try ing to take multiple pictures with iphone camera from the same scene programmatically and I don't want the exposure or focus to change after the user sets it for the first picture.
Here is my code that gets executed when the use initiates the picture taking from within my app:
NSArray *devices = [AVCaptureDevice devices];
NSError *error;
for (AVCaptureDevice *device in devices) {
if (([device hasMediaType:AVMediaTypeVideo]) &&
([device position] == AVCaptureDevicePositionBack) ) {
[device lockForConfiguration:&error];
if ([device isWhiteBalanceModeSupported:AVCaptureWhiteBalanceModeLocked]) {
device.whiteBalanceMode = AVCaptureWhiteBalanceModeLocked;
NSLog(@"Whitebalanced locked");
}
if ([device isExposureModeSupported:AVCaptureExposureModeLocked]) {
device.exposureMode = AVCaptureExposureModeLocked;
NSLog(@"Exposure locked");
}
if ([device isFocusModeSupported:AVCaptureFocusModeLocked]) {
device.focusMode = AVCaptureFocusModeLocked;
NSLog(@"Focus locked");
}
[device unlockForConfiguration];
}
}
The problem: Camera does auto-focus and auto-exposure after the first picture is taken. How can I force exposure and focus to stay locked?
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您缺少提交配置:
在代码放置之前:
之后:
希望这有帮助。
I think you're missing to commit the configuration:
Before your code put:
After:
Hope this helped.