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

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

multi_stream.py:

# @brief Example for acquiring multiple streams.
# CVBpy Example Script for multistream
#
# 1. Open the device with 3rd generation acq stack.
# 2. Get multiple streams
# 3. Acquire images with separate engine and device start / abort
#
# Requires: A connected and configured GenICam device which has multiple
# streams, or the official CVB mock GenTL producer file. Note that it is not
# necessary to know which is the CTI file or where the CTI file
# is located since the CVB installer installs the file in the
# right place for you.
#
# If you prefer to execute this tutorial with the mock device, please pass
# the "--mock" switch to the executable.
import sys
import cvb
execute_with_mock = True if sys.argv[1] == '--mock' else False
flags = cvb.DiscoverFlags.IgnoreVins
if execute_with_mock:
flags |= cvb.DiscoverFlags.IncludeMockTL
deviceInfoList = cvb.DeviceFactory.discover_from_root(flags)
if len(deviceInfoList) < 1:
print("No devices found.")
sys.exit()
access_token = deviceInfoList[0].access_token
if execute_with_mock:
found_mock = False
for info in deviceInfoList:
if info.access_token.find('MockTL'):
found_mock = True
access_token = info.access_token
break
if not found_mock:
print("Could not find CVMockTL.")
sys.exit()
with cvb.DeviceFactory.open(access_token, cvb.AcquisitionStack.GenTL) as device:
streams = [device.stream(cvb.ImageStream, i) for i in range(device.stream_count)]
print(f"Stream Count: {len(streams)}")
for stream in streams:
stream.engine_start()
for stream in streams:
stream.device_start()
for image_index in range(10):
for stream_index, stream in enumerate(streams):
image, status, nodes = stream.wait()
try:
pass
finally:
with image:
print(f"Stream #{stream_index}, "
f"Image #{str(image_index)}, "
f"Width: {image.width}, "
f"Height: {image.height}")
for stream in streams:
stream.device_abort()
for stream in streams:
stream.engine_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)