I thought of this reference lib mechanism. But I don’t wanted to go this way because this is for sure gonna be effecting the performance at runtime. So for tracking one image at a time, Like what vuforia does,
After a lot of thoughts and time investments I came up with the following findings and solution.
- Set device as the Tracking origin mode on the XROrigin Component.
- Create a customized tracked image status manager script and use the
ARTrackedImageMange’s “trackedImagesChanged” action to get
ARTrackedImagesChangedEventArgs added, updated and removed list of trackables.
Consider TrackedImageInfoManager in the samples as a starting point for this.
- If you are familiar with existing third party image recognitions like vuforia, wikitude, easyAR, zappar etc.
ARFoundation’s image tracker can be mapped as …
Added - First Seen. This list will get filled with a specific trackable when it was found for the first time in an ARSession. It will be removed the moment it gets added to the updated list and will never get add again to this list in the same session.
Updated - Tracked OR Limited (You can consider limited as Track lost) : This will need a logic to manage the states. Apart from added, this will have items coming in and out throughout the experience. When a trackable is in the camera view and being tracked it will be available in the updated list with a trackingState.
Removed - Is probably happened once the session ends. I never personally had this item updated.
So talking about the updated list. Until and unless there is only 1 image in the camera view at a time, this updated list will have that single image trackable in the list. The moment a second image comes to the camera view, this list will have that second trackable as the second element in the list. And both will have the trackingState as tracking. Now if you move the camera to get ride of one of them and focus only on one, Then this list will again go back to the 1 count with the current tracking item but in that change call back you can get a tracking limited state for the ignored item. This limited state update happens only once but tracking callback is continuous.
Now what can be done is this updated list could be used to compare the trackables with their ids and their tracking states. Once we have this handy, to manage the one image at a time scenario, need to add a logic to find the nearest image to the device by calculating the distance of each tracking trackables with the device position. This is why I mentioned to make the device as the origin in the first point. This makes the distance more precise.
NB: I have come up with all these findings using the XRSimulator and the ARFoundation samples only. Please mind rectifying anything mentioned above.
So as a conclusion, this way of doing will perform no harm on the existing ARFoundation and we can leverage the full potential of using cross platform openXR runtime features for AR Apps we create. I am working on the one image at a time logic will post soon after testing them on the actual devices with some actual images.
@andyb-unity Thanks for the quick reply. A humble suggestion would be to include more details about the
ARTrackedImagesChangedEventArgs in the documentation.