chgatla-microsoft / QRTracking

MRTK sample app for QRtracking
MIT License
74 stars 69 forks source link

QR-Code positions are cached or saved and reused at restart Reopen--issue#29 #41

Closed AndreaRettaroli closed 2 years ago

AndreaRettaroli commented 3 years ago

Hi,

I seem to have the behaviour, that on second (or later) execution the data from earlier runs is used. An example: I start the program in a room where 2 QR-Codes are placed. Now I go near them and let them be recognized by the Tracking tool. Now I close the program and remove one of the 2 QR-Codes. I open up the program again and even before any QR-Codes could be recognized by computer vision the positions are already marked (which means the Start() method of the QR-Code object was executed). After the QR-Code was recognized the position is adjusted to fit perfectly. However, the removed QR-Code stays and the pre-loaded/cached/saved position.

Im developing an application where I use QR-Codes to find objects and use the QR-Code data as identification. In the QR-Start method (after the QR-Code was recognized) I connect to the object. Therefore, it's an issue for me that object that are not here anymore still have their Start()-method executed.

Now to my question: Is this expected behaviour? I couldn't find any functions that would save the data. Or am I the only one to exeperience this. If this is expected, how can it be deactivated?

I think that the last QR code scanned remain in memory and when you re open your app it start with that QR code.

Further Information: Hololens2 Unity 2019 Visual Studio 2019

WikkidEdd commented 2 years ago

Yes, this is expected behaviour. A lot of people get caught out by this behaviour. The important bit from the documentation is this:

Windows Mixed Reality devices detect QR codes at the system level in the driver. When the device is rebooted, the detected QR codes are gone and will be redetected as new objects next time.

We recommend configuring your app to ignore QR codes older than a specific timestamp. Currently, the API doesn't support clearing QR code history.

Ref: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/platform-capabilities-and-apis/qr-code-tracking#managing-qr-code-data

The OS treats QR codes a bit like anchors, it will remember where it saw them last and even though the device can't see them now, it assumes it's still in the same position. The workaround is to only consider QR codes detected/updated since you started the app based on the timestamp.

chgatla-microsoft commented 2 years ago

This is by design. There is OnEnumertationComplete event which can be used to differentiate if qrcodes were detected before the start of the watcher. Also removing a QRcode from scene does not remove the QR object from the list by design as there are lot of valid scenarios where qr will be shown and then it can be removed ( or occluded ) and the pose can still be used by the app. There is updated event to handle this and to tell if qr is being observed vs last detected.