【发布时间】:2021-05-28 16:26:17
【问题描述】:
在 Swift 中有没有办法检查设备是否有 LiDAR 传感器?不幸的是,我在 Apple 官方纪录片和互联网搜索中都没有找到任何内容。
我目前的解决方法是确定设备类型,如本文所述: How to determine the current iPhone/device model?
谢谢
【问题讨论】:
标签: ios swift augmented-reality lidar
在 Swift 中有没有办法检查设备是否有 LiDAR 传感器?不幸的是,我在 Apple 官方纪录片和互联网搜索中都没有找到任何内容。
我目前的解决方法是确定设备类型,如本文所述: How to determine the current iPhone/device model?
谢谢
【问题讨论】:
标签: ios swift augmented-reality lidar
使用此代码:-
import ARKit
let supportLiDAR = ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)
guard supportLiDAR else {
print("LiDAR isn't supported here")
return
}
场景重建需要配备激光雷达扫描仪的设备,例如第四代 iPad Pro。
【讨论】:
接受的答案很好,这是另一个解决方案:
您可以检查来自 LiDAR 的深度数据的可用性,我们需要检查我们的设备是否支持此传感器 并在 ARConfiguration 中启用其标志“.sceneDepth”。
使用这个函数
func setupARConfiguration() -> ARConfiguration{
let configuration = ARWorldTrackingConfiguration()
// add specific configurations
if ARWorldTrackingConfiguration.supportsFrameSemantics(.sceneDepth) {
configuration.frameSemantics = .sceneDepth
}else {
print("Device is not support lidar sensor")
}
return configuration
}
来自 Apple 文档:
在尝试在您的应用配置中启用框架语义之前调用此函数。例如,如果您在 ARWorldTrackingConfiguration 上调用 supportsFrameSemantic(.sceneDepth),则该函数在支持 LiDAR 扫描仪深度缓冲区的设备上返回 true。
参考: https://developer.apple.com/documentation/arkit/arconfiguration/3089122-supportsframesemantics
【讨论】: