Can I save ar data for reuse?

2020-07-26 05:06发布

问题:

My goal is to place a object on a arcore plane in a room, then I save the plane and object's data in file. After app exit and start again, the object had been saved can be loaded from file, then it can be displayed at the same position just like last time.

回答1:

To persist virtual objects, we probably can use VPS (visual positioning service, not released yet) to localize the device with an room.

However there's no API to achieve this in the developer preview version of ARCore.



回答2:

You can save anchor positions in ARCore using Augmented Images.

All you have to do is place your objects wherever you want go back to an/more Augmented Images and save positions of corners of your Augmented Images into a text or a binary file in your device.

Then in the next Session, lets say you used one Augmented Image and 4 points(corners of the image), you load these positions and calculate a Transformation Matrix between two sessions using these 2 group of 4 points which are common in each Session. The reason why you need this is due to the fact that ARCore's coordinate system changes in every session depending on device's initial position and rotation.

At the end, you can calculate positions and rotations of anchors in new session using this Transformation Matrix. It will be placed at the same physical location with an error margin caused by accuracy of Augmented Image tracking. If you use more points this error margin will be relatively lower.

I have tested this with 4 points in each group and it is quite accurate considering my anchors were placed on Arbitrary locations not attached to any Trackable.

In order to calculate the Transformation Matrix you can refer to this



标签: arcore