Camera image metadata

ARCore lets you use ImageMetadata to access metadata key values from the camera image capture result. Some common types of camera image metadata you might want to access are focal length, image timestamp data, or lighting information.

The Android Camera module can record 160 or more parameters about the image for each frame captured, depending on a device's capabilities. For a list of all possible metadata keys, see ImageMetadata.

Get the value of an individual metadata key

Use getImageMetadata() to get a specific metadata key value, and catch the MetadataNotFoundException if it's not available. The following example shows obtaining the SENSOR_EXPOSURE_TIME metadata key value.

Java

// Obtain the SENSOR_EXPOSURE_TIME metadata value from the frame.
Long getSensorExposureTime(Frame frame) {
  try {
    // Can throw NotYetAvailableException when sensors data is not yet available.
    ImageMetadata metadata = frame.getImageMetadata();

    // Get the exposure time metadata. Throws MetadataNotFoundException if it's not available.
    return metadata.getLong(ImageMetadata.SENSOR_EXPOSURE_TIME);
  } catch (MetadataNotFoundException | NotYetAvailableException exception) {
    return null;
  }
}

Kotlin

// Obtain the SENSOR_EXPOSURE_TIME metadata value from the frame.
fun getSensorExposureTime(frame: Frame): Long? {
  return runCatching {
      // Can throw NotYetAvailableException when sensors data is not yet available.
      val metadata = frame.imageMetadata

      // Get the exposure time metadata. Throws MetadataNotFoundException if it's not available.
      return metadata.getLong(ImageMetadata.SENSOR_EXPOSURE_TIME)
    }
    .getOrNull()
}