Swift中如何检查iOS设备是否具有LiDAR功能

6

在Swift中有没有一种方法可以检查设备是否具有LiDAR传感器?不幸的是我在官方的Apple文档和互联网搜索中都没有找到任何信息。

我目前的解决方法是像这篇帖子中描述的那样确定设备类型: 如何确定当前iPhone/设备型号?

谢谢


Dipika Kansara 发布了一个回答,说:“Apple LIDAR扫描文档”。 - Scratte
2个回答

10

1

被接受的答案很好,这里还有另一种解决方案:

您可以检查来自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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接