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