CVBpy 15.0
All Classes Namespaces Functions Variables Enumerations Enumerator Properties Modules Pages
cvb/StreamingParallel
1# @brief Example for parallel streaming.
2
3# CVBpy Example Script
4#
5# 1. Open the GenICam.vin driver.
6# 2. Acquire images in a dedicated native thread through a stream handler.
7# 3. Measure the frame rate and print results.
8#
9# Requires: A connected and configured GenICam device
10
11import time
12import os
13import cvb
14
15
16class MyStreamHandler(cvb.SingleStreamHandler):
17
18 def __init__(self, stream):
19 super().__init__(stream)
20 self.rate_counter = cvb.RateCounter()
21
22 # called in the interpreter thread to setup additionla stuff.
23 def setup(self, stream):
24 super().setup(stream)
25 print("setup")
26
27 # called in the interpreter thread to tear down stuff from setup.
28 def tear_down(self, stream):
29 super().tear_down(stream)
30 print("tear_down")
31
32 # called from the aqusition thread
33 def handle_async_stream(self, stream):
34 super().handle_async_stream(stream)
35 print("handle_async_stream")
36
37 # called from the aqusition thread
38 def handle_async_wait_result(self, image, status):
39 super().handle_async_wait_result(image, status)
40 self.rate_counter.step()
41 print("New image: " + image.__class__.__name__ + " " + str(image) + " | Status: " + str(status) + " | Buffer Index: " + str(image.buffer_index))
42
43 # print messurement results
44 def eval(self):
45 print("Acquired with: " + str(self.rate_counter.rate) + " fps")
46
47
49 os.path.join(cvb.install_path(), "drivers", "CVMock.vin"),
50 cvb.AcquisitionStack.Vin) as device:
51 with MyStreamHandler(device.stream()) as handler:
52 handler.run()
53 time.sleep(10)
54 handler.finish()
55
56
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
Frame rate measurement counter with selectable averaging window.
Definition: __init__.py:5091
Handler object for a single stream.
Definition: __init__.py:5459
str install_path()
Directory Common Vision Blox has been installed to.
Definition: __init__.py:8318