AVCaptureDevice.Position=AVCaptureDevice位置类型



我正在为一个函数使用AVCaptureDevice.Position命令,该函数将AVCaptureDevice.Position作为其参数之一。由于某种原因,我得到错误

无法将类型为"AVCaptureDevice.Position.type"的值转换为预期的参数类型"AVCapureDevice.Position">

我不确定为什么会出现这个错误,但这是我调用函数的过程,我还将包括函数的代码:

let visionImage = VisionImage(buffer: sampleBuffer)
visionImage.orientation = imageOrientation(deviceOrientation: UIDevice.current.orientation, cameraPosition: AVCaptureDevice.Position)

这是我的功能代码:

func imageOrientation(
deviceOrientation: UIDeviceOrientation,
cameraPosition: AVCaptureDevice.Position
) -> UIImage.Orientation {
switch deviceOrientation {
case .portrait:
return cameraPosition == .front ? .leftMirrored : .right
case .landscapeLeft:
return cameraPosition == .front ? .downMirrored : .up
case .portraitUpsideDown:
return cameraPosition == .front ? .rightMirrored : .left
case .landscapeRight:
return cameraPosition == .front ? .upMirrored : .down
case .faceDown, .faceUp, .unknown:
return .up
}
}

如有任何帮助,我们将不胜感激!

AVCaptureDevice.Position枚举https://developer.apple.com/documentation/avfoundation/avcapturedevice/position

设置.前、.后或.未指定:

visionImage.orientation = imageOrientation(deviceOrientation: UIDevice.current.orientation, cameraPosition: AVCaptureDevice.Position.back)

相关内容

  • 没有找到相关文章

最新更新