Get Hardware Metadata from GenICam Device
The example shows how to acquire 10 images with hardware timestamps, CRC, and exposure time from a GenICam™ compliant camera using the gentl
adaptor. The terminology for hardware metadata used by the GenICam standard is "chunk data."
Create a videoinput
object, then configure it to acquire 10 frames and retrieve the videosource
source object.
vid = videoinput("gentl", 1);
vid.FramesPerTrigger = 10;
src = getselectedsource(vid);
Use the chunkDataInfo
function to view available chunk data that can be enabled for configuration.
chunkInfo = chunkDataInfo(src)
chunkInfo=15×2 table
Chunk Data Enabled
__________________________ _______
"ExposureTime" "False"
"Image" "True"
"CRC" "True"
"FrameID" "False"
"OffsetX" "False"
"OffsetY" "False"
"Width" "False"
"Height" "False"
"Gain" "False"
"BlackLevel" "False"
"PixelFormat" "False"
"SequencerSetActive" "False"
"Timestamp" "False"
"SerialData" "False"
"ExposureEndLineStatusAll" "False"
Note that the Image and CRC Chunk Data are always enabled by default by the manufacturer of this particular camera.
Configure the camera to acquire timestamps and exposure times during acquisition.
% Activate chunk mode in the camera src.ChunkModeActive = "True"; % Select the timestamp src.ChunkSelector = "Timestamp"; % Enable timestamps src.ChunkEnable = "True"; % Select exposure time src.ChunkSelector = "ExposureTime"; % Enable exposure time src.ChunkEnable = "True";
Use chunkDataInfo
to verify that chunk data is configured correctly in the camera.
chunkInfo = chunkDataInfo(src)
chunkInfo=15×2 table
Chunk Data Enabled
__________________________ _______
"ExposureTime" "True"
"Image" "True"
"CRC" "True"
"FrameID" "False"
"OffsetX" "False"
"OffsetY" "False"
"Width" "False"
"Height" "False"
"Gain" "False"
"BlackLevel" "False"
"PixelFormat" "False"
"SequencerSetActive" "False"
"Timestamp" "True"
"SerialData" "False"
"ExposureEndLineStatusAll" "False"
Start the acquisition and read the acquired data into the MATLAB workspace.
start(vid) [image, time, metadata] = getdata(vid);
Access the metadata of the first frame.
mData = metadata(1)
mData = struct with fields:
AbsTime: [2024 1 3 14 59 25.0336]
FrameNumber: 1
RelativeFrame: 1
TriggerIndex: 1
ChunkData: [1×1 struct]
Check the chunk data values for the first frame.
chunkMetaData = mData.ChunkData
chunkMetaData = struct with fields:
CRC: 2948315233
ExposureTime: 14963
Timestamp: 1292485432754104
Display all chunk data for each frame in a table.
frames = []; timeStamps = []; exposureTime = []; for i = 1:10 img = image(:,:,:,i); frames = [frames; {img}]; timeStamps = [timeStamps; metadata(i).ChunkData.Timestamp]; exposureTime = [exposureTime; metadata(i).ChunkData.ExposureTime]; end resultTable = table(timeStamps,exposureTime,frames)
resultTable=10×3 table
timeStamps exposureTime frames
________________ ____________ _________________
1292485432754104 14963 {3000×4096 uint8}
1292485532661568 14963 {3000×4096 uint8}
1292485632569328 14963 {3000×4096 uint8}
1292485732476568 14963 {3000×4096 uint8}
1292485832384408 14963 {3000×4096 uint8}
1292485932291568 14963 {3000×4096 uint8}
1292486032199944 14963 {3000×4096 uint8}
1292486132107456 14963 {3000×4096 uint8}
1292486232014592 14963 {3000×4096 uint8}
1292486331922328 14963 {3000×4096 uint8}