iPhone相机曝光/对焦锁定:它不会保持锁定状态

发布于 2024-11-15 12:05:20 字数 1172 浏览 2 评论 0原文

我正在尝试以编程方式使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Hello爱情风 2024-11-22 12:05:20

我认为您缺少提交配置:

在代码放置之前:

captureSession = [[AVCaptureSession alloc] init];
[captureSession beginConfiguration];

之后:

[captureSession commitConfiguration];

希望这有帮助。

I think you're missing to commit the configuration:

Before your code put:

captureSession = [[AVCaptureSession alloc] init];
[captureSession beginConfiguration];

After:

[captureSession commitConfiguration];

Hope this helped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文