Main Content

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
            ChunkData             Enabled
    __________________________    _______

    "Image"                       "True" 
    "CRC"                         "True" 
    "FrameID"                     "False"
    "OffsetX"                     "False"
    "OffsetY"                     "False"
    "Width"                       "False"
    "Height"                      "False"
    "ExposureTime"                "True" 
    "Gain"                        "False"
    "BlackLevel"                  "False"
    "PixelFormat"                 "False"
    "SequencerSetActive"          "False"
    "Timestamp"                   "True" 
    "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
            ChunkData             Enabled
    __________________________    _______

    "Image"                       "True" 
    "CRC"                         "True" 
    "FrameID"                     "False"
    "OffsetX"                     "False"
    "OffsetY"                     "False"
    "Width"                       "False"
    "Height"                      "False"
    "ExposureTime"                "True" 
    "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 5 17 13 32 7.3093]
      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: 1527840335
    ExposureTime: 6873
       Timestamp: 1918815722568

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      
    _____________    ____________    _________________

    1918815722568        6873        {3000×4096 uint8}
    1918915630408        6873        {3000×4096 uint8}
    1919015538000        6873        {3000×4096 uint8}
    1919115445000        6807        {3000×4096 uint8}
    1919215353592        6775        {3000×4096 uint8}
    1919315261056        6742        {3000×4096 uint8}
    1919415168352        6742        {3000×4096 uint8}
    1919515076544        6742        {3000×4096 uint8}
    1919614984192        6742        {3000×4096 uint8}
    1919714891976        6742        {3000×4096 uint8}

See Also

Functions