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

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

display.py:

# @brief Example for QML based streaming display.
import os, sys
import cvb
import cvb.ui
if sys.version_info >= (3, 11):
from PySide6.QtCore import QObject, QUrl
from PySide6.QtQml import qmlRegisterType
from PySide6.QtWidgets import QApplication, QWidget
from PySide6.QtQuick import QQuickView, QQuickPaintedItem
from PySide6.QtGui import QIcon
else:
from PySide2.QtCore import QObject, QUrl
from PySide2.QtQml import qmlRegisterType
from PySide2.QtWidgets import QApplication, QWidget
from PySide2.QtQuick import QQuickView, QQuickPaintedItem
from PySide2.QtGui import QIcon
if __name__ == "__main__":
app = QApplication([])
app.setOrganizationName('STEMMER IMAGING')
app.setOrganizationDomain('https://www.stemmer-imaging.com/')
app.setApplicationName('Display Python tutorial')
# tell Windows the correct AppUserModelID for this process (shows icon in the taskbar)
if sys.platform == 'win32':
import ctypes
myappid = u'stemmerimaging.commonvisionblox.pystreamdisplay.0'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
script_dir = os.path.dirname(os.path.realpath(__file__))
icon_path = os.path.join(script_dir, 'Tutorial-Python_32x32.png')
app.setWindowIcon(QIcon(icon_path))
# load the device
os.path.join(cvb.install_path(), "drivers", "CVMock.vin"),
cvb.AcquisitionStack.Vin)
# use a single stream handler to setup an acquisition thread and acquire images
handler = cvb.SingleStreamHandler(device.stream())
# create an image controller to interact with the UI
image_controller = cvb.ui.ImageController()
# register the display component with QML
# setup the QML UI
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
context = view.rootContext()
context.setContextProperty("mainImage", image_controller)
filepath = os.path.dirname(os.path.realpath(__file__))
view.setSource(QUrl.fromLocalFile(os.path.join(filepath,"main.qml")))
view.resize(640, 480)
view.show()
# register the device image with UI controller to trigger automatic refreshes
image_controller.refresh(device.device_image, cvb.ui.AutoRefresh.On)
# start the acquisition thread
handler.run()
# start the UI event handler
app.exec_()
# stop the acquisition after UI exits
handler.try_finish()
Union[cvb.GenICamDevice, cvb.VinDevice, cvb.EmuDevice, cvb.VideoDevice, cvb.NonStreamingDevice] open(str provider, int acquisition_stack=cvb.AcquisitionStack.PreferVin)
None register(cls, str uri="CvbQuick", int version_major=1, int version_minor=0, str qml_name="ImageView")
str install_path()