ARCore を使用すると、ImageMetadata
を使用して、カメラ画像のキャプチャ結果のメタデータキー値にアクセスできます。アクセスが必要な一般的なカメラ画像メタデータには、焦点距離、画像のタイムスタンプ データ、照明情報などがあります。
Android Camera
モジュールは、デバイスの機能に応じて、キャプチャした各フレームの画像について 160 個以上のパラメータを記録できます。使用可能なすべてのメタデータキーの一覧については、ImageMetadata
をご覧ください。
個々のメタデータキーの値を取得する
getImageMetadata()
を使用して特定のメタデータ キー値を取得し、使用できない場合は MetadataNotFoundException
をキャッチします。次の例は、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() }