Saving ARCore Image Database between sessions

走远了吗. 提交于 2019-12-08 07:08:37

问题


first time posting.

I’m trying to save an augmented image database made during runtime, for using in a later session. I have looked around but found no questions related to this.

Thanks in advance.

EDIT should have mentioned, I am using Unity(sorry, I'm new).


回答1:


You can use serialize function to create a byte array or an output stream depending on whether you use Android or Android NDK.

For NDK:

void ArAugmentedImageDatabase_serialize(
      const ArSession *session,
      const ArAugmentedImageDatabase *augmented_image_database,
      uint8_t **out_image_database_raw_bytes,
      int64_t *out_image_database_raw_bytes_size
    )

For Android:

public void serialize (OutputStream outputStream)

For Unity: First you have to import your image and in import settings you should check Read/Write Enabled. Then, you have to convert your image to either RGBA32 or RGB24. Because ARCore only supports these two formats.

        Texture2D empty = new Texture2D(ImportedImage.width,ImportedImage.height, TextureFormat.RGBA32, false);
        empty.SetPixels(ImportedImage.GetPixels());
        empty.Apply();

Then you can use databaseTest.AddImage("first",empty); However, this database has to be used in your ARCoreSessionConfig Augmented Image Database field like this:

Otherwise app hangs i am not sure why. Good luck!



来源:https://stackoverflow.com/questions/52970270/saving-arcore-image-database-between-sessions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!