在Swift中有没有办法检查设备是否有LiDAR传感器?不幸的是,我在苹果的官方纪录片和互联网搜索中都没有找到任何东西。
我目前的解决方法是确定设备类型,如本文所述:How to determine the current iPhone/device model?
谢谢
发布于 2021-02-26 18:58:45
使用以下代码:-
import ARKit
let supportLiDAR = ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)
guard supportLiDAR else {
print("LiDAR isn't supported here")
return
}场景重建需要配备专业版扫描仪的设备,例如第四代iPad LiDAR。
发布于 2021-09-11 11:20:45
公认的答案是好的,这里是另一个解决方案:
您可以检查来自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 Docs:
在尝试在应用程序的配置上启用框架语义之前,请调用此函数。例如,如果在ARWorldTrackingConfiguration上调用supportsFrameSemantic(.sceneDepth),则该函数在支持LiDAR扫描仪的深度缓冲区的设备上返回true。
参考:https://developer.apple.com/documentation/arkit/arconfiguration/3089122-supportsframesemantics
https://stackoverflow.com/questions/66383288
复制相似问题