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

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

streaming_async.py:

# @brief Example for asynchronous streaming.
# CVBpy Example Script
#
# 1. Open the CVMock.vin driver.
# 2. Asynchronously acquire images.
# 3. Measure the frame rate and print results.
#
# Note: can be extended to multible cameras.
import os
import asyncio
import cvb
rate_counter = None
async def async_acquire(port):
global rate_counter
with cvb.DeviceFactory.open(os.path.join(cvb.install_path(), "drivers", "CVMock.vin"), port=port) as device:
stream = device.stream()
stream.start()
rate_counter = cvb.RateCounter()
for i in range(0, 100):
result = await stream.wait_async()
image, status = result.value
rate_counter.step()
if status == cvb.WaitStatus.Ok:
print("Buffer index: " + str(image.buffer_index) + " from stream: " + str(port))
stream.abort()
watch = cvb.StopWatch()
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.gather(
async_acquire(port=0)))
loop.close()
duration = watch.time_span
print("Acquired on port 0 with " + str(rate_counter.rate) + " fps")
print("Overall measurement time: " +str(duration / 1000) + " seconds")
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
str install_path()