gpt4 book ai didi

ios - AVFoundation videoZoomFactor 不工作(Swift)

转载 作者:行者123 更新时间:2023-11-28 15:13:41 26 4
gpt4 key购买 nike

除缩放系数外,我想使用的所有相机调整都有效。我不知道为什么会这样……有什么想法吗?自定义曝​​光和焦点设置工作正常。 iOS 中是否发生了一些我不知道的变化?

captureSession = AVCaptureSession()
captureSession?.sessionPreset = AVCaptureSessionPresetPhoto
stillImageOutput = AVCapturePhotoOutput()

let device = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)

do{
do{
try device?.lockForConfiguration()
device?.setFocusModeLockedWithLensPosition(focusValue, completionHandler: {(time) -> Void in})
device?.setExposureModeCustomWithDuration(CMTimeMake(1, exposureValue), iso: ISOValue, completionHandler: {(time) -> Void in})
let zoomFactor:CGFloat = 16
device?.videoZoomFactor = zoomFactor
device?.unlockForConfiguration()

}catch{
print(error)
}

stillImageOutput.isHighResolutionCaptureEnabled = true
let input = try AVCaptureDeviceInput(device: device)
if(captureSession.canAddInput(input)){
captureSession.addInput(input)
if(captureSession.canAddOutput(stillImageOutput)){
captureSession.addOutput(stillImageOutput)

captureSession.startRunning()
let captureVideoLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer.init(session: captureSession)
captureVideoLayer.frame = self.previewView.bounds
captureVideoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
self.previewView.layer.insertSublayer(captureVideoLayer, at: 0)
}
}
}catch{
print(error)
}

最佳答案

原来我只是在错误的位置设置了我的设备设置。如果将 lockconfig try block 移动到捕获 session 内容下方,它将按预期工作。

关于ios - AVFoundation videoZoomFactor 不工作(Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47230226/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com