O ARCore permite usar ImageMetadata
para acessar chaves-valor de metadados do
resultado da captura de imagem da câmera. Alguns tipos comuns de metadados de imagem da câmera que
você pode querer acessar são distância focal, dados de carimbo de data/hora da imagem ou informações de
iluminação.
O módulo Camera
do Android pode gravar 160 ou mais parâmetros sobre a imagem
para cada frame capturado, dependendo dos recursos do dispositivo. Para ver uma lista de todas
as chaves de metadados possíveis, consulte ImageMetadata
.
Receber o valor de uma chave de metadados individual
Use getImageMetadata()
para receber um valor de chave de metadados específico e capture o MetadataNotFoundException
se ele não estiver disponível. Veja no exemplo a seguir como conseguir o valor da chave de metadados SENSOR_EXPOSURE_TIME
.
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() }