CVBpy 15.0
cvb/MultiStream
1# CVBpy Example Script for multistream
2#
3# 1. Open the device with 3rd generation acq stack.
4# 2. Get multiple streams
5# 3. Acquire images with separate engine and device start / abort
6#
7# Requires: A connected and configured GenICam device which has multiple
8# streams, or the official CVB mock GenTL producer file. Note that it is not
9# necessary to know which is the CTI file or where the CTI file
10# is located since the CVB installer installs the file in the
11# right place for you.
12#
13# If you prefer to execute this tutorial with the mock device, please pass
14# the "--mock" switch to the executable.
15
16import sys
17
18import cvb
19
20
21execute_with_mock = True if sys.argv[1] == '--mock' else False
22flags = cvb.DiscoverFlags.IgnoreVins
23if execute_with_mock:
24 flags |= cvb.DiscoverFlags.IncludeMockTL
25
26deviceInfoList = cvb.DeviceFactory.discover_from_root(flags)
27if len(deviceInfoList) < 1:
28 print("No devices found.")
29 sys.exit()
30
31access_token = deviceInfoList[0].access_token
32if execute_with_mock:
33 found_mock = False
34 for info in deviceInfoList:
35 if info.access_token.find('MockTL'):
36 found_mock = True
37 access_token = info.access_token
38 break
39 if not found_mock:
40 print("Could not find CVMockTL.")
41 sys.exit()
42
43with cvb.DeviceFactory.open(access_token, cvb.AcquisitionStack.GenTL) as device:
44 streams = [device.stream(cvb.ImageStream, i) for i in range(device.stream_count)]
45 print(f"Stream Count: {len(streams)}")
46 for stream in streams:
47 stream.engine_start()
48 for stream in streams:
49 stream.device_start()
50 for image_index in range(10):
51 for stream_index, stream in enumerate(streams):
52 image, status, nodes = stream.wait()
53 try:
54 pass
55 finally:
56 with image:
57 print(f"Stream #{stream_index}, "
58 f"Image #{str(image_index)}, "
59 f"Width: {image.width}, "
60 f"Height: {image.height}")
61 for stream in streams:
62 stream.device_abort()
63 for stream in streams:
64 stream.engine_abort()
65
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
Opens a device with the given provider and acquisition stack.
Definition: __init__.py:1629
List[cvb.DiscoveryInformation] discover_from_root(int flags=cvb.DiscoverFlags.FindAll, int time_span=300)
Discovers available devices / nodes depending on the given flags.
Definition: __init__.py:1609
The image stream class.
Definition: __init__.py:2521