Using Chunk Data in CVB

There are multiple ways to use Chunk Data in CVB. First of all it is depending on the device(s) that you are using and the options they are supporting.
In the following example a Teledyne Dalsa Genie Nano GigE Vision camera is used to acquire Chunk Timestamps from every image frame transmitted.

Generally there ar the following preconditions required.

  1. The used Device needs to support Chunk Data:
    For the Teledyne Dalsa Genie Nano, the acailable Chunk Nodes can be read from the NodeMap. Available Chunk Data are regularly described in the device manual.

  2. On the camera side Chunk Data need to be enabled to be attached to the image buffer. For the Teledyne Dalsa Genie Nano the displayed name is Metadata Mode while the node can be reached by Std::ChunkModeActive as the standard determines.

  3. Last condition to receive Chunk Data is that on the software side CVB is set to acqire Chunk Data as well. This can be done in the driver settings.

The following post will show how to acquire Chunk Data in CVB using the API without having to access the raw buffer memory as described for example here. Using different devices may result in slight changes to the examples.


Here is an example on using Chunk Data in Python. Using the Chunk Timestamp from the Nodemap is valid as this statement is part of the buffer until the stream.wait() stement ends.
All requirements for enabling ChunkMode on the camera and the driver settings can be performed from code.

import cvb

devices = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)

with[0].access_token, cvb.AcquisitionStack.GenTL) as device:
    stream =    
    device_nodemap = device.node_maps["Device"]
    ChunkModeActive = device_nodemap["Std::ChunkModeActive"]
    ChunkModeActive.value = True       
    TimestampPrevious = 0
    for i in range(10):        
        image, status, node_maps = stream.wait()        
        # this is valid, well defined until new wait returns
        Chunk_Timestamp = device_nodemap["Std::ChunkTimestamp"]        
        TSP_Diff = Chunk_Timestamp.value - TimestampPrevious
        TimestampPrevious = Chunk_Timestamp.value
        with image:
            print("Acquired image: {0} | Timestamp: {1} | Chunk Timestamp: {2} | Difference to previous Frame: {3}".format(i, image.raw_timestamp, Chunk_Timestamp.value, TSP_Diff))

The same example in .NET:

using System;
using Stemmer.Cvb;
using Stemmer.Cvb.Driver;
using Stemmer.Cvb.GenApi;

namespace CVB_UsingChunkDataFromNodemap
  internal class Program
    static void Main(string[] args)
      DiscoveryInformationList discoveryList = DeviceFactory.Discover(DiscoverFlags.IgnoreVins);
      //Enable ChunkMode on Driver
      discoveryList[0].SetParameter("AttachChunk", "1");
      using (Device device = DeviceFactory.Open(discoveryList[0].AccessToken))
        Stream stream = device.Stream;
        NodeMap deviceNodeMap = device.NodeMaps[NodeMapNames.Device];

        //Enable ChunkMode in device NodeMap
        BooleanNode ChunkModeActive = deviceNodeMap["Std::ChunkModeActive"] as BooleanNode;
        ChunkModeActive.Value = true;

        long TimestampPrevious = 0;
        for (int i = 0; i < 10; i++)
          using (var image = stream.Wait(out WaitStatus status))
            //this is valid, well defined until new wait returns
            IntegerNode ChunkTimestampNode = deviceNodeMap["Std::ChunkTimestamp"] as IntegerNode;
            long Chunk_Timestamp = ChunkTimestampNode.Value;
            long TSP_Diff = Chunk_Timestamp - TimestampPrevious;
            TimestampPrevious = Chunk_Timestamp;
            Console.WriteLine("FrameID: " + i + " Timestamp: " + image.RawTimestamp + " Chunk Timestamp: " + Chunk_Timestamp + " Difference to previous Frame: " + TSP_Diff);