Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
2.98k stars 1.11k forks source link

Session Drift on similar marker. #1064

Closed nextechar-hardik closed 9 months ago

nextechar-hardik commented 1 year ago

Hello Folks , I am using AR Foundation with AR Image tracking and Plane tracking functionality. I am using QR code as marker (Dynamic library). When we scan marker (QR code ) I am able to get event like Found and lost. after that if I am trying to scan Wrong marker (Same Type of QR but not added on Image Tracking Library ) then AR Session drift to that Marker without any event or error.

First I was thinking due to Image tracking is enable so I have disable Tracking and all its component using this code

` void StopAllTrackable() { foreach (var trackedImage in m_TrackedImageManager.trackables) { LogHandler.Instance.Log("Markers : " + trackedImage.referenceImage.name); trackedImage.gameObject.SetActive(false); }

        m_TrackedImageManager.referenceLibrary = m_TrackedImageManager.CreateRuntimeLibrary();
        m_TrackedImageManager.requestedMaxNumberOfMovingImages = 0;
        m_TrackedImageManager.enabled = false;
    }

` Still I am facing same issue.

I am attaching issue video here

https://youtube.com/shorts/62ixko96bI8

In video i am Tracking first marker , then loading content. then after trying to scan another marker. i can see content on place.

First both marker are added in Dynamic Library. last one is same way generated QR but not added in Library. at that time Session shift at that marker i can see rest of content is also move accordingly

Any suggestion for this kind of issue ?

nextechar-hardik commented 1 year ago

I have test this flow on AR foundation version - 4.2.7 , 5.0.2 , 5.0.3

andyb-unity commented 1 year ago

I'm not sure exactly what the issue is here, but I have some ideas.

First of all, setting requestedMaxNumberOfMovingImages to 0 will result in a tracking configuration change in ARKit as explained here: https://developer.apple.com/documentation/arkit/arworldtrackingconfiguration/2968182-maximumnumberoftrackedimages?language=objc

The default value is 0, which disables image tracking. If you add reference images to detectionImages with this property set to 0, ARKit creates image anchors for observed reference images but their positions only update infrequently, such as once every couple of seconds.

This configuration change could be responsible for your issue, and I would recommend testing with this line commented out.

Another note is that QR Codes are poor images for ARKit image tracking. You might want to consider viewing your image quality in Xcode to confirm whether the image is suitable for tracking, as explained here: https://developer.apple.com/forums/thread/685469

Not all images are equally suited for using them as ARReferenceImages. Good reference images typically have high contrast, good texture, clear edges, and are printed on a flat, non-glossy surface. Low-texture and low-contrast images will likely not work so well. When you add reference images to an ARResourceGroup in an Xcode asset catalog, Xcode will show quality estimation warnings, which may provide additional insights about the specific issue with that particular image.

nextechar-hardik commented 1 year ago

@andyb-unity Thank you for replay.. this issue not face on only iOS its also reproducible in Android.

Sure will try to update code as per your suggestion and test flow. Tracking is also good With QR only..very fast.

I thought issue accrue due to Plane tracking.. while finding marker Plane Tracking is also enable at that time plane is created on Marker as well , so if we scan similar look image at that time due to plane tracking similar environment found AR Foundation reset session anchor...

May be I am wrong on this theory.. I got this theory because AR Session has capability to improve session pose automatically. SO want to know is there any way to stop that kind of behaviour ? can we stop auto improvement in session pose ?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

andyb-unity commented 1 year ago

SO want to know is there any way to stop that kind of behaviour ? can we stop auto improvement in session pose ?

In short, no. The definition of an AR Session being enabled is that it tracks the device's position in the environment to the best of its ability. How it does so is platform-specific, but no platform offers anything like you describe.

andyb-unity commented 9 months ago

Closing this issue as asked and answered. Feel free to re-open it if you have further questions.