相機圖片中繼資料
ARCore 可讓您使用 ImageMetadata
從
。常見的相機圖片中繼資料類型
您可以採用焦點、圖片時間戳記資料或亮度
可能不準確或不適當
Android Camera
模組可以記錄 160 以上的圖片參數
根據裝置功能而定。完整的清單
可能的中繼資料鍵,請參閱 ImageMetadata
。
使用 getImageMetadata()
取得特定中繼資料鍵/值,並擷取 MetadataNotFoundException
(如果無法使用的話)。以下範例說明如何取得
SENSOR_EXPOSURE_TIME
中繼資料鍵值。
// 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;
}
}
// 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()
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-10-14 (世界標準時間)。
[null,null,["上次更新時間:2024-10-14 (世界標準時間)。"],[[["ARCore provides access to camera image metadata like focal length, timestamp, and lighting information using `ImageMetadata`."],["Android's `Camera` module can record over 160 image parameters, which can be accessed through the `ImageMetadata` class."],["Developers can retrieve specific metadata values using `getImageMetadata()`, while handling potential exceptions like `MetadataNotFoundException`."],["The provided Java and Kotlin code snippets demonstrate how to obtain the `SENSOR_EXPOSURE_TIME` metadata value from a frame."]]],["ARCore utilizes `ImageMetadata` to access camera image capture metadata, such as focal length, timestamps, and lighting. The Android `Camera` module can record over 160 parameters per frame. To retrieve a specific key value, use `getImageMetadata()`, handling `MetadataNotFoundException`. The example demonstrates fetching the `SENSOR_EXPOSURE_TIME` metadata, using `getLong()` method and handling `NotYetAvailableException` if sensor data is unavailable. Refer to the `ImageMetadata` documentation for the complete list of available keys.\n"]]