gpt4 book ai didi

ios - 如何使用 ARKit 打开/关闭相机闪光灯?

转载 作者:可可西里 更新时间:2023-10-31 23:56:13 24 4
gpt4 key购买 nike

我正在使用 ARSCNView 来显示 AR 体验,它使用 3D SceneKit 内容增强相机 View 。

ARSession管理设备摄像头的共享对象,但在 ARSession 中我找不到闪光灯的任何选项。

有什么方法可以打开/关闭相机闪光灯吗?

如何使用ARKit管理摄像头?

如何前后改变相机位置?

最佳答案

func toggleTorch(on: Bool) {
guard let device = AVCaptureDevice.default(for: AVMediaType.video)
else {return}

if device.hasTorch {
do {
try device.lockForConfiguration()

if on == true {
device.torchMode = .on // set on
} else {
device.torchMode = .off // set off
}

device.unlockForConfiguration()
} catch {
print("Torch could not be used")
}
} else {
print("Torch is not available")
}
}

称之为

toggleTorch(on: true) 或 toggleTorch(on: false)

引用:使用 Swift 进行黑客攻击

关于ios - 如何使用 ARKit 打开/关闭相机闪光灯?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47008256/

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