相机图片元数据
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
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);
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eARCore's \u003ccode\u003eArImageMetadata\u003c/code\u003e allows access to camera image metadata like focal length, timestamps, and lighting information.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can retrieve specific metadata values, such as exposure time, using \u003ccode\u003eArImageMetadata_getConstEntry()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eArImageMetadata_getAllKeys()\u003c/code\u003e provides a list of all metadata tags available for a given frame.\u003c/p\u003e\n"],["\u003cp\u003eThe Android \u003ccode\u003eCamera\u003c/code\u003e module can record extensive image parameters, with a full list available in the NDK documentation.\u003c/p\u003e\n"]]],[],null,["# Camera image metadata\n\nARCore lets you use [`ArImageMetadata`](/ar/reference/c/group/ar-image-metadata)\nto access metadata key values from the camera image capture result. Some\ncommon types of camera image metadata you might want to access are focal length,\nimage timestamp data, or lighting information.\n\nThe Android `Camera` module can record 160 or more parameters about the image\nfor each frame captured, depending on a device's capabilities. For a list of all\npossible metadata keys, see the [NDK `Camera` documentation](https://developer.android.com/ndk/reference/group/camera).\n\nGet the value of an individual metadata tag\n-------------------------------------------\n\nUse [`ArImageMetadata_getConstEntry()`](/ar/reference/c/group/ar-image-metadata#arimagemetadata_getconstentry)\nto get a specific metadata tag value. The following example shows obtaining the `ACAMERA_SENSOR_EXPOSURE_TIME` metadata value: \n\n```c\nArSession_update(session, frame);\n\n// Obtain the metadata object from the frame.\nArImageMetadata* ar_metadata;\nArFrame_acquireImageMetadata(session, frame, &ar_metadata);\n\n// Get the exposure time metadata (using ACAMERA_SENSOR_EXPOSURE_TIME in this\n// example).\nArImageMetadata_const_entry exposure_entry;\nArImageMetadata_getConstEntry(session, ar_metadata,\n ACAMERA_SENSOR_EXPOSURE_TIME, &exposure_entry);\n```\n\nGet a list of all metadata tags for a given frame\n-------------------------------------------------\n\nUse [`ArImageMetadata_getAllKeys()`](/ar/reference/c/group/ar-image-metadata#arimagemetadata_getallkeys) to get a list of all metadata keys captured\nfor a given frame. \n\n```c\nArSession_update(session, frame);\n\n// Obtain the metadata object from the frame.\nArImageMetadata* ar_metadata;\nArFrame_acquireImageMetadata(session, frame, &ar_metadata);\n\n// Obtain the list of all the metadata for a given frame.\nconst uint32_t* all_tags = NULL;\nint32_t number_of_tags = -1;\n\nArImageMetadata_getAllKeys(session, ar_metadata, &number_of_tags, &all_tags);\n```"]]