Using Chunk Mode Data with CVB.NET


I have been following the Getting Started with CVB.NET tutorial. I am running a C5-4090 camera in chunk data mode (see page 45 of C5 Series User Manual - is it possible to access this additional data using the new API?

So far I have been very impressed by the API’s ease of use!



Hi @AGrafton,

for this example you need to configure the C5 being the first camera and image data being delivered as raw:

using (var device = DeviceFactory.Open(""))
  var nodemap = device.NodeMaps[NodeMapNames.Device];
  var chunkModeActive = nodemap["ChunkModeActive"] as BooleanNode;
  chunkModeActive.Value = true;

  var stream = device.Stream;
    var deviceImage = device.DeviceImage;

    var chunks = GevChunkParser.Parse(deviceImage);
    var info = DereferenceAcqInfoOn(deviceImage, chunks.First(chunk => chunk.ID == ATC5AcqInfoChunk.ID));

    Console.WriteLine($"FrameCount: {info.FrameCount}");

With this helper method and struct:

private static unsafe ATC5AcqInfoChunk DereferenceAcqInfoOn(DeviceImage image, GevChunk chunk)
  Debug.Assert(chunk.ID == ATC5AcqInfoChunk.ID);
  Debug.Assert(chunk.Length >= sizeof(ATC5AcqInfoChunk));

  var chunkPtr = new IntPtr(image.GetBufferBasePtr().ToInt64() + chunk.Offset);
  return *(ATC5AcqInfoChunk*)chunkPtr;

[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ATC5AcqInfoChunk
  public const uint ID = 0x66669999;

  public uint TimeStampLow;
  public uint TimeStampHigh;
  public uint FrameCount;
  public int TriggerCoordinate;
  public byte TriggerStatus;
  public ushort DAC;
  public ushort ADC;
  public byte IntIdX;
  public byte AoiIdX;
  public ushort AoiYs;
  public ushort AoiDy;
  public ushort AoiXs;
  public ushort AoiThreshold;
  public byte AOIAlgorithm;

For this to work you need these three new classes I put on github:


And by the way (I was in bit of a hurry on Friday :slight_smile:): thank you!

Your feed-back is very important to us. I intend to integrate the parser into a future version of the CVB .Net wrappers.

Thank you for the detailed response. I notice that you access the payload size and delivered payload size using addresses 0x1900 and 0x1B00 on the device; I cannot find references to these in the genicam spec or the camera’s xml description file - could you point me to meanings of these values? (I have had issues where the image goes into a buffer and no longer matches the device’s up to date payload size).

Many thanks again for your help!

These are releated to the GigE Vision Protocol. The Payload-Size is the allocated buffer size (can be retrieved via the GenICam Std::PayloadSize feature). The delivered payload size is determined by the acquisition engine (the actual amount of delivered packages).

There is also an additional limitation: the acquisition engine can only store as many bytes as are allocated. For that it reads out the PayloadSize upon creation. If you changed it because you e.g. changed the Width, Height, PixelFormat, or the number of chunks, you can update the buffer by calling:


(when the Stream is not running: .IsRunning == false).