Google is committed to advancing racial equity for Black communities. See how.

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) {
  ImageMetadata metadata = frame.getImageMetadata();
  try {
    // Get the exposure time metadata, and if it's not available catch the
    // MetadataNotFoundException.
    return metadata.getLong(ImageMetadata.SENSOR_EXPOSURE_TIME);
  } catch (MetadataNotFoundException exception) {
    throw new RuntimeException("Unable to obtain sensor exposure time.", exception);
  }
}

Kotlin

// Obtain the SENSOR_EXPOSURE_TIME metadata value from the frame.
fun getSensorExposureTime(frame: Frame): Long {
  val metadata = frame.imageMetadata
  try {
    // Get the exposure time metadata, and if it's not available catch the
    // MetadataNotFoundException.
    return metadata.getLong(ImageMetadata.SENSOR_EXPOSURE_TIME)
  } catch (exception: MetadataNotFoundException) {
    throw RuntimeException("Unable to obtain sensor exposure time.", exception)
  }
}