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