在Swift中有没有一种方法可以检查设备是否具有LiDAR传感器?不幸的是我在官方的Apple文档和互联网搜索中都没有找到任何信息。
我目前的解决方法是像这篇帖子中描述的那样确定设备类型: 如何确定当前iPhone/设备型号?
谢谢
在Swift中有没有一种方法可以检查设备是否具有LiDAR传感器?不幸的是我在官方的Apple文档和互联网搜索中都没有找到任何信息。
我目前的解决方法是像这篇帖子中描述的那样确定设备类型: 如何确定当前iPhone/设备型号?
谢谢
import ARKit
let supportLiDAR = ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)
guard supportLiDAR else {
print("LiDAR isn't supported here")
return
}
场景重建需要带有LiDAR扫描仪的设备,例如第四代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
}
来自苹果文档:
在尝试启用应用程序配置的帧语义之前,请调用此函数。例如,如果您在ARWorldTrackingConfiguration上调用supportsFrameSemantic(.sceneDepth),则该函数将在支持激光雷达扫描仪深度缓冲区的设备上返回true。
参考: https://developer.apple.com/documentation/arkit/arconfiguration/3089122-supportsframesemantics