Detect AR foundation tracking quality?
I made an basic AR testing app that puts a box at phone starting position. user can look around with camera to capture feature points to increase stability. when AR foundation get enough feature points, user can walk further and see the box staying at starting position accurately.
those are very basic AR foundation features.
My problem is, how to benchmark the quality of tracking so I can know the quality of feature point is good enough?
I don't want user walk too early before getting enough feature point or walk too fast and lose tracking. at least I need a method to detect bad tracking state.
any ideas?
I am also looking for an answer to this question for 3 months. There is a session state enum that should be "SessionTracking" when there are enough features. But enough features still does not mean the tracking quality is good. https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.0/manual/index.html#session-state
Answer by KirillKuzyk · May 26, 2020 at 07:34 AM
XRSessionSubsystem has a trackingState property. This way you can know if tracking state is limited or tracking.
If you want to know the reason why your session is not tracking, there is a notTrackingReason property.
var arSession = FindObjectOfType<ARSession>(); // todo cache or assign reference via Inspector
var xrSessionSubsystem = arSession.subsystem;
if (xrSessionSubsystem != null) {
TrackingState trackingState = xrSessionSubsystem.trackingState;
NotTrackingReason notTrackingReason = xrSessionSubsystem.notTrackingReason;
}
I suggested the same answer as a comment but like I said it only detects that it is tracking not that the tracking quality is actually good. The state is almost always "SessionTracking" and only turn to "Limited" if you cover the Camera completely.
Your answer
Follow this Question
Related Questions
force a camera to be the main camera 0 Answers
AR Camera shows only a black screen. 0 Answers
How to stop plane detection using ARKit 2 Answers
AR Tracked Image Manager descriptor is null 1 Answer
Vuforia on HoloLens 2 1 Answer