Delete or clear tracked geometry and images when using ARKIT?

Is there a way to delete the tracked geometry and tracked images?

I’m using an augmented image as a trigger for another object being placed somewhere else in the scene and I need to be able to restart the whole process without closing the app. Stop AR Session doesn’t seem to clear the tracked planes because when I start the AR session again it immediately has the previously detected planes, and the image as well, causing my object to be created before the user has actually looked at it.

What is the best way to flush out the current ARKit tracked data and force it to begin again?

You could do a “Line Trace Tracked Objects” per frame and see if any of the trace results match your tracked images, instead of querying whether or not something is in the list of tracked geometry? At least that’s what I’m attempting to do right now, since I ran into a similar problem.

EDIT: It seems like Line tracing for tracked objects does not return images at this time, only normal tracked planes unfortunately.

Were you able to figure this out?

Not OP, but what I ended up doing is spawning a blueprint actor that I can find via a line trace (since you can’t use an AR line trace to find tracked images) as soon as the image is recognized, and then run the trigger once a line trace grabs that item successfully. For my purposes running the check fairly infrequently is fine, so every half second I first line trace for any “trigger” blueprints that have been spawned, and then I check if there are any new images in the list of tracked geometry and spawn trigger blueprints for those images. Waiting a half second gives the system a little time to correct the location of the AR image and fix jitter if needed before running the trigger.

Okay! Thanks for the info!

Did anyone solve this? I am trying to create an AR book and need the spawned geometry to disappear when the tracked image is no longer visible.

I’ve not found a solution to this yet. However in 4.21.1 the Image only session type now works and I think this would mitigate my need to purge the tracked data. It doesn’t answer my previous question but it is an option that may work for your book project.

I’ve still not found a solution to this issue. Stopping and starting the AR session seems to clear the detected planes but the images seem to still exist in some form. I’ve still not found a way to clear this image cache

This is in 4.21 now

Same boat. Unfortunately had to move the project over to Unity. There is still too much lacking/not completely implemented for us to use it for development. It is unfortunate since all of our VR work is done in Unreal. Can’t wait for them to get it sorted!

So, this isn’t an answer to my question but it is a method to get around it.

At the start of an AR session create and array of the current tracked geometries. Each tick, or however often you are running your updates, compare that array to the current list of all geometries. Those that aren’t in that array are new so add them to a second array. Then do your position checks or whatever you need to do from that new array, not from Get all AR Geometries.

Now the only way this works is if you update that existing geometries array. For me I just stop the AR session, reopen my level and start the session again. I think stopping the session is required for it to recognise image as a “new” geometry for it to track, while the previous iteration of that image is now in the ignored list. If you can’t just reopen your map you may need a more creative solution for deciding which tracked elements get put into your ignore list and when they are added.

Hopefully this helps someone else. I was maybe just being lazy about how I was using the Image detection system haha

You could do a “Line Trace Tracked Objects” per frame and see if any of the trace results match your tracked images, instead of querying whether or not something is in the list of tracked geometry? At least that’s what I’m attempting to do right now, since I ran into a similar problem. https://cleanmaster.me/ ,Adam4Adam - adam4adam.com - ooVoo, https://mathway.vip/

Hi!
I am currently working in a AR image trigger project, and I am having the same problem, I would like to try your way but I would appriciate if you can show the rest of the Blueprint.

The proper way is to use a Session Config.

Tracked geometry and tracked images do not get deleted, but reset.
Run another “Start AR Session” (no need to stop the current one) with a session config that has “reset tracked objects” enabled.

This can also be enabled at runtime for a session config using “Set Reset Tracked Objects” in Blueprints. (Don’t forget to run another “Start AR Session” with the same session config after that!)

Note that this is of course for tracked objects not spawned world objects.

Stop AR session
Collect garbage
Start a new session