Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Image Manager/CVBpy/BufferHandling

This example program is located in your CVB installation under %CVB%Tutorial/Image Manager/CVBpy/BufferHandling.

flowsetpool.py:

# @brief Example for buffer handling.
# CVBpy Example Script for 3rd generation acquisition stack
# to show the new buffer handling
#
# 1. Loads a GenICam device.
# 2. Get the device node map.
# 3. Modify the pixel format
# 4. Update the buffers
#
# Requires: A connected and configured GenICam device
import cvb
devices = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)
with cvb.DeviceFactory.open(devices[0].access_token, cvb.AcquisitionStack.GenTL) as device:
stream = device.stream(cvb.ImageStream)
stream.register_managed_flow_set_pool(100)
print("Buffers allocated: {}".format(stream.flow_set_count))
stream.deregister_flow_set_pool()
stream.register_managed_flow_set_pool(200)
print("Buffers allocated: {}".format(stream.flow_set_count))
stream.start()
for i in range(10):
image, status, node_maps = stream.wait()
with image:
print("Acquired image: {}".format(i))
stream.abort()
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
List[cvb.DiscoveryInformation] discover_from_root(int flags=cvb.DiscoverFlags.FindAll, int time_span=300)

ringbuffer.py:

# CVBpy Example Script for 2nd generation acquisition stack
# to show the ring buffer handling with locking and unlocking
# buffers.
#
# 1. Load a GenICam device.
# 2. Allocate buffers.
# 3. Switch the lock mode on.
# 4. Store images to lock them.
# 5. Unlock images manually.
#
# Requires: A connected and configured GenICam device
import cvb
devices = cvb.DeviceFactory.discover_from_root(cvb.DiscoverFlags.IgnoreVins)
with cvb.DeviceFactory.open(devices[0].access_token, cvb.AcquisitionStack.Vin) as device:
stream = device.stream()
stream.ring_buffer.change_count(5, cvb.DeviceUpdateMode.UpdateDeviceImage)
stream.ring_buffer.lock_mode = cvb.RingBufferLockMode.On
print("Buffers allocated: {0} | Lock mode: {1}".format(stream.ring_buffer.count, stream.ring_buffer.lock_mode))
stream.start()
images = []
for _ in range(10):
image, status = stream.wait_for(5000)
if status == cvb.WaitStatus.Ok:
images.append(image)
print("Image list size: {}".format(len(images)))
elif (status == cvb.WaitStatus.Timeout and len(images) > 0):
first = images.pop(0)
first.unlock()
print("Image unlocked")
stream.abort()