第一次发帖。
我正在尝试保存在运行时制作的增强图像数据库,以便在以后的会话中使用。我环顾四周,但没有发现与此有关的问题。
提前致谢。
编辑应该提到,我使用Unity(抱歉,我是新的)。
您可以使用serialize函数创建字节数组或输出流,具体取决于您使用的是Android还是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只支持这两种格式。
Texture2D empty = new Texture2D(ImportedImage.width,ImportedImage.height, TextureFormat.RGBA32, false);
empty.SetPixels(ImportedImage.GetPixels());
empty.Apply();
然后你可以使用databaseTest.AddImage("first",empty);
但是,这个数据库必须在你的ARCoreSessionConfig增强图像数据库字段中使用,如下所示:
否则app挂起我不知道为什么。祝好运!