Video widgets

cv2PySide6.videowidgets provides convenience widgets with pre-built video pipelines.

class cv2PySide6.videowidgets.NDArrayVideoPlayerWidget(*args: Any, **kwargs: Any)[source]

Bases: QWidget

Convenience widget to process and display numpy arrays from local video file.

Notes

This widget processes the frames with single thread, therefore long processing blocks the GUI. Refer to the package examples for building multithread pipeline.

Examples

>>> from PySide6.QtCore import QUrl
>>> from PySide6.QtWidgets import QApplication
>>> import sys
>>> from cv2PySide6 import get_data_path, NDArrayVideoPlayerWidget
>>> vidpath = get_data_path('hello.mp4')
>>> def runGUI():
...     app = QApplication(sys.argv)
...     w = NDArrayVideoPlayerWidget()
...     w.videoPlayer().setSource(QUrl.fromLocalFile(vidpath))
...     w.show()
...     app.exec()
...     app.quit()
>>> runGUI() 
videoPlayer() NDArrayVideoPlayer[source]

Object to emit video frames as numpy arrays.

videoLabel() NDArrayLabel[source]

Label to display video image.

mediaController() MediaController[source]

Widget to control videoPlayer().

setArray(array: ndarray)

Process the array with processArray() and set to videoLabel().

processArray(array: ndarray) ndarray[source]

Perform array processing. Redefine this method if needed.

class cv2PySide6.videowidgets.NDArrayCameraWidget(*args: Any, **kwargs: Any)[source]

Bases: QWidget

Convenience widget to process and display numpy arrays from camera.

Notes

This widget processes the frames with single thread, therefore long processing blocks the GUI. Refer to the package examples for building multithread pipeline.

Examples

>>> from PySide6.QtWidgets import QApplication
>>> from PySide6.QtMultimedia import QCamera
>>> import sys
>>> from cv2PySide6 import NDArrayCameraWidget
>>> def runGUI():
...     app = QApplication(sys.argv)
...     widget = NDArrayCameraWidget()
...     camera = QCamera()
...     widget.mediaCaptureSession().setCamera(camera)
...     camera.start()
...     widget.show()
...     app.exec()
...     app.quit()
>>> runGUI() 
videoLabel() NDArrayLabel[source]

Label to display video image.

setArray(array: ndarray)

Process the array with processArray() and set to videoLabel().

processArray(array: ndarray) ndarray[source]

Perform array processing. Redefine this method if needed.