google-ar / arcore-unreal-sdk

ARCore SDK for Unreal
https://developers.google.com/ar/
Apache License 2.0
277 stars 122 forks source link

OnArTrackingStateChanged only returns "tracking" and has weird behaviors #42

Open FernandoCCNunes opened 5 years ago

FernandoCCNunes commented 5 years ago

I am using the source code from google with latest version of ArCore 1.6 and working on a blueprints project. Issue: Image gets detected by the camera but it's tracking state return always "tracking" and i expected a behavior such as if it's no longer visible/in camera view it would return "not tracking" or "stop tracking". My workaround was to spawn an actor at a tracked image location, used the Pin Component and bind the event "OnArTrackingStateChanged". I then proceeded to print the "EARTrackingState" from the "OnArTrackingStateChanged" event and only returns "tracking" and fires multiple times like it was running off of event tick (when looking at the imaged pinned) , when i move the camera away from the image the event is never fired (expected a "stop tracking" atleast) Knowing that the event only fires when I'm looking at the image i tried another workaround where i added a timer by event that fires 1 second after the event "OnArTrackingStateChanged" is fired and if "OnArTrackingStateChanged" is not fired again within that 1 second i set tracking to false because from debugging this event only gets called when looking at it, expected this to work but by adding the blueprint "set timer by event" run on "OnArTrackingStateChanged", the event is never called, not even when I'm looking at it.

PS: Everything is running off of tick event although I'm careful to not bind the event nor spawn actor and pin the tracked image to it more then once. I am gonna try running this functionality in a timer

Edit 1. - Forgot to mention that, if I put my hand in front of the phone's camera or rest the phone with the camera facing a solid object where the camera is fully black, the event "OnArTrackingStateChanged" returns "Not Tracking" only in the example on the first image, if I include the workaround of the second one the event never fires as well.

Images to better explain the issue:

  1. This will return "tracking" non stop while I'm looking at the image and when I move away from the image stops firing having the last return be "tracking". ue4tracking00

  2. Once i had this functionality the event never fires, not 1 single time. ue4tracking01

  3. How i pin the image tracked to a spawned actor's scene component ue4tracking02

bopangzz commented 5 years ago

I believe that is the expected behavior in ARCore right now. The Not Tracking state is only used when ARCore detected the image but couldn't estimated it's size.

Can you describe your used case there? Are you trying to hide some content that is attach to the image when the image is not visible?

FernandoCCNunes commented 5 years ago

You say that the expected behaviour is that, but what I said about the event only returns sometimes is part of the behaviour or a bug? What I am trying to do is to set a text in a UMG widget words "tracking" or "not tracking" depending wether Im looking at the image or not, I got some workarounds but was hoping to get it working this way

Invius commented 4 years ago

I want to know if the image is being detected on screen or not, is there a way to know that?

MatzeOGH commented 4 years ago

I have the same problem. With 2.21 there was the time since last update that stopped updating when the tracked image dissapeared. With 2.23 prev 4 that variable updates whether the marker is visible or not.