4

is there a way in Swift to check if the device has a LiDAR sensor? Unfortunately I've didn't find anything in the official Apple documentary nor with internet search.

My current workaround is to determine the device type like described in this post: How to determine the current iPhone/device model?

Thanks

TRS
  • 228
  • 4
  • 15
  • [Dipika Kansara](https://stackoverflow.com/users/14318274) posted an [Answer](https://stackoverflow.com/a/69444311) saying "[Apple Documentation of LIDAR Scanning](https://developer.apple.com/news/?id=qwhaoe0x)" – Scratte Oct 05 '21 at 17:11

2 Answers2

9

Use this code:-

import ARKit

let supportLiDAR = ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)
guard supportLiDAR else {
    print("LiDAR isn't supported here")
    return
}

Scene reconstruction requires a device with a LiDAR Scanner, such as the fourth-generation iPad Pro.

reference:- https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration/3521377-supportsscenereconstruction

Datt Patel
  • 1,203
  • 1
  • 11
  • 10
1

The Accepted answer is fine and here is another solution :

you can check for the availability of depth data from LiDAR, we need to check whether our device supports this sensor and enable its flag ‘.sceneDepth’ in ARConfiguration.

Use This Func

 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
}

from Apple Docs :

Call this function before attempting to enable a frame semantic on your app's configuration. For example, if you call supportsFrameSemantic(.sceneDepth) on ARWorldTrackingConfiguration, the function returns true on devices that support the LiDAR scanner's depth buffer.

Ref : https://developer.apple.com/documentation/arkit/arconfiguration/3089122-supportsframesemantics

Islam Alshnawey
  • 692
  • 10
  • 15