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

查看:16
本文介绍了在会话之间保存 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).

推荐答案

您可以使用 serialize 函数创建字节数组或输出流,具体取决于您使用的是 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
    )

安卓:

public void serialize (OutputStream outputStream)

对于 Unity:首先您必须导入您的图像,并且在导入设置中您应该选中 Read/Write Enabled.然后,您必须将图像转换为 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天全站免登陆