在会话之间保存ARCore图像数据库 [英] Saving ARCore Image Database between sessions

查看:149
本文介绍了在会话之间保存ARCore图像数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首次发布.

我正在尝试保存运行时创建的增强图像数据库,以供以后的会话中使用.我环顾四周,但未发现与此相关的任何问题.

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.

先谢谢了.

EDIT 应该已经提到,我正在使用Unity(对不起,我是新手).

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

推荐答案

您可以使用序列化功能来创建字节数组或输出流,具体取决于您使用的是Android还是Android NDK.

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

对于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
    )

对于Android:

public void serialize (OutputStream outputStream)

对于Unity:首先必须导入图像,然后在导入设置中选中启用读/写". 然后,您必须将图像转换为RGBA32或RGB24.因为ARCore仅支持这两种格式.

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();

然后您可以使用databaseTest.AddImage("first",empty);.但是,必须在您的ARCoreSessionConfig增强图像数据库字段中使用该数据库,如下所示:

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!

这篇关于在会话之间保存ARCore图像数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆