Siêu dữ liệu hình ảnh của máy ảnh

ARCore cho phép bạn sử dụng ArImageMetadata để truy cập các giá trị khoá siêu dữ liệu từ kết quả chụp ảnh bằng máy ảnh. Hơi nhiều các loại siêu dữ liệu hình ảnh phổ biến của camera mà bạn có thể muốn truy cập là tiêu cự, dữ liệu dấu thời gian của hình ảnh hoặc thông tin về ánh sáng.

Mô-đun Camera của Android có thể ghi lại 160 tham số trở lên về hình ảnh cho mỗi khung hình được chụp, tuỳ thuộc vào khả năng của thiết bị. Để xem danh sách tất cả các khoá siêu dữ liệu có thể dùng, hãy xem tài liệu Camera về NDK.

Lấy giá trị của từng thẻ siêu dữ liệu

Sử dụng ArImageMetadata_getConstEntry() để lấy một giá trị thẻ siêu dữ liệu cụ thể. Ví dụ sau đây cho thấy cách lấy giá trị siêu dữ liệu ACAMERA_SENSOR_EXPOSURE_TIME:

ArSession_update(session, frame);

// Obtain the metadata object from the frame.
ArImageMetadata* ar_metadata;
ArFrame_acquireImageMetadata(session, frame, &ar_metadata);

// Get the exposure time metadata (using ACAMERA_SENSOR_EXPOSURE_TIME in this
// example).
ArImageMetadata_const_entry exposure_entry;
ArImageMetadata_getConstEntry(session, ar_metadata,
                              ACAMERA_SENSOR_EXPOSURE_TIME, &exposure_entry);

Lấy danh sách tất cả các thẻ siêu dữ liệu của một khung hình cụ thể

Sử dụng ArImageMetadata_getAllKeys() để nhận danh sách tất cả các khoá siêu dữ liệu đã ghi lại cho một khung hình cụ thể.

ArSession_update(session, frame);

// Obtain the metadata object from the frame.
ArImageMetadata* ar_metadata;
ArFrame_acquireImageMetadata(session, frame, &ar_metadata);

// Obtain the list of all the metadata for a given frame.
const uint32_t* all_tags = NULL;
int32_t number_of_tags = -1;

ArImageMetadata_getAllKeys(session, ar_metadata, &number_of_tags, &all_tags);