'How to check if ARKit camera movement is too fast in iOS

I am working on apple's ARKit with RealityKit and I want to guide the user not to move the device too fast. I am trying to detect movement using this delegate method.

func session(_ session: ARSession, 
               cameraDidChangeTrackingState camera: ARCamera) {
    switch camera.trackingState {
        case .limited(let reason):
            switch reason {
                case .excessiveMotion: print("too fast") // then update UI
                default: break
            }
        default: break
    } 
}

But the thing is, this method is not that accurate when I try to move my device quickly.

Is there any other way to detect fast movement?



Solution 1:[1]

ARKit's subcase .excessiveMotion of trackingState instance property is very subjective because tracking results may vary depending on lighting conditions, environment, rich/poor textures of real-world objects, number of reflective/refractive surfaces, presence/absence of a LiDAR scanner, presence/absence of a ARWorldMap, etc. This case is used for a general (i.e. inaccurate) analysis of the tracking situation.

In my opinion, you can accurately detect fast camera movement only under ideal tracking conditions (for a novice AR user, this is an impossible task). Today robust solution (started from iOS 13) is a quick preliminary tracking session with onboarding instructions to direct users toward a specific goal. It's called ARCoachingOverlayView.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1