相机图片元数据

ARCore 允许您使用 ArImageMetadata 访问相机图像拍摄结果中的元数据键值对。您可能希望访问的一些常见类型的相机图片元数据包括焦距、图片时间戳数据或光照信息。

Android Camera 模块可以为拍摄的每个帧记录 160 个或更多关于图片的参数,具体取决于设备的功能。如需查看所有可能的元数据键的列表,请参阅 NDK Camera 文档

获取单个元数据标记的值

使用 ArImageMetadata_getConstEntry() 获取特定的元数据标记值。以下示例展示了如何获取 ACAMERA_SENSOR_EXPOSURE_TIME 元数据值:

ArSession_update(session, frame);

// Obtain the metadata object from the frame.
ArImageMetadata* ar_metadata;
ArFrame_acquireImageMetadata(session, frame, &ar_metadata);

// Get the exposure time metadata (using ACAMERA_SENSOR_EXPOSURE_TIME in this
// example).
ArImageMetadata_const_entry exposure_entry;
ArImageMetadata_getConstEntry(session, ar_metadata,
                              ACAMERA_SENSOR_EXPOSURE_TIME, &exposure_entry);

获取给定帧的所有元数据标记的列表

使用 ArImageMetadata_getAllKeys() 获取为给定帧捕获的所有元数据键的列表。

ArSession_update(session, frame);

// Obtain the metadata object from the frame.
ArImageMetadata* ar_metadata;
ArFrame_acquireImageMetadata(session, frame, &ar_metadata);

// Obtain the list of all the metadata for a given frame.
const uint32_t* all_tags = NULL;
int32_t number_of_tags = -1;

ArImageMetadata_getAllKeys(session, ar_metadata, &number_of_tags, &all_tags);