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 are the following preconditions required.
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.
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.
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)
devices[0].set_parameter("AttachChunk","1")
with cvb.DeviceFactory.open(devices[0].access_token, cvb.AcquisitionStack.GenTL) as device:
stream = device.stream(cvb.ImageStream)
device_nodemap = device.node_maps["Device"]
ChunkModeActive = device_nodemap["Std::ChunkModeActive"]
ChunkModeActive.value = True
TimestampPrevious = 0
stream.start()
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))
stream.abort()