AVFoundation - How to control exposure

前端 未结 2 1614
Happy的楠姐
Happy的楠姐 2021-01-18 00:07

AFTER tapping to take picture, I want to lock exposure and turn off torch as soon as exposure is no longer adjusting. So, I added an observer to handle adj

2条回答
  •  执笔经年
    2021-01-18 00:22

    It is almost certainly a timing issue. Call captureStillImageAsynchronouslyFromConnection:completionHandler: inside your if block. Then the capture will always be executed after exposure has been locked.

    if ([self.inputDevice isExposureModeSupported:AVCaptureExposureModeLocked]) {
        dispatch_async(dispatch_get_main_queue(), 
            ^{
                NSError *error = nil;
                if ([self.inputDevice lockForConfiguration:&error]) {
                    //code to lock exposure here
                    //take photo here
                }
            });
    }
    

提交回复
热议问题