How to read chunk data using C++ API

I’m wanting to bring some chunk data back with the image capture but can’t find any references to how to do this in the documentation.

Having enabled chunk data via the GeniCam browser I can see an area containing the chunk data tags lurking in the memory after what looks like image data (I’m using GetLinearAccess) but I don’t know how to parse this.

The only reference on this site that I’ve been able to find is Using Chunk Mode Data with CVB.NET which is for C#. I should be able to figure out what I need from the code there but I’m stuck with knowing where to get the payload size from in the following piece of code

23:  return Iterate((image.GetBufferBasePtr(), image.GetPayloadSize());

Can anyone point me in the right direction?


Hi @matt,

in the C# example, the GetPayloadSize does the following:

/// <summary>
/// Gets the valid size of the delivered buffer storing the image and 
/// additional data.
/// </summary>
/// <param name="image">This GenICam image.</param>
/// <returns>Number of valid bytes in the <paramref name="image"/>'s buffer.
/// </returns>
public static long GetPayloadSize(this DeviceImage image)
  if (image == null)
    throw new ArgumentNullException(nameof(image));

  long payloadSize = 0;
    DeviceControl(image).SendCommand(GetDeliveredPaylodSize, IntPtr.Zero, out payloadSize);
    if (payloadSize > 0)
      return payloadSize;
    // swallow

  DeviceControl(image).SendCommand(GetPaylodSize, IntPtr.Zero, out payloadSize);
  return payloadSize;


private static readonly DeviceControlCommand GetDeliveredPaylodSize = new DeviceControlCommand(DeviceControlOperation.Get, 0x1B00);

You can call the C++ DeviceControl (see as follows:

auto GetDeliveredPaylodSize = Cvb::DeviceControlCommand(0x1B00, Cvb::DeviceControlOperation::Get);
size_t deliveredPaylodSize = 0;
img->DeviceControl()->SendCommand(GetDeliveredPaylodSize, deliveredPaylodSize);

You can then adopt the rest of the C# example for C++ in the same manner and it should work.


1 Like

So it does! Thanks! I really should have spotted that. :frowning:

Maybe it needs an article or FAQ on the website somewhere.

1 Like

It is quite rare that the chunk data is used and thus it is not very frequently asked for. But you are right, maybe we can incorporate the example for C# and C++ in the documentation. In the meantime I hope the forum is a good means for exchange on these sort of problems :slight_smile:

I understand. I’m intending to use it to pull back the camera temperature instead of polling, as it seems like that should be a cleaner and quicker approach. Are there any subtle “gotchas” about the chunk data mechanism that I need to be aware of?