Demos#

Runnable demo applications built on the QVideo framework.

Each demo composes a QCameraTree with one or more QVideo widgets into a standalone window. All demos use choose_camera() to present a camera-selection dialog at startup, so no camera-specific code is needed in the demo itself.

The default application is QCamcorder and can be launched via the package entry point:

python -m QVideo [-b|-c|-f|-i|-m|-p|-r|-v] [cameraID]

Each demo can also be launched directly:

python -m QVideo.demos.demo
python -m QVideo.demos.filterdemo
python -m QVideo.demos.filterrackdemo
python -m QVideo.demos.ROIdemo
python -m QVideo.demos.trackpydemo
python -m QVideo.demos.yolodemo
python -m QVideo.demos.compositedemo

All demos accept the same command-line flags to select a camera backend. If no flag is given, a noise camera is used as a fallback.

-b [cameraID]   Basler camera (requires pylon SDK)
-c [cameraID]   OpenCV camera
-f [cameraID]   FLIR camera (requires Spinnaker SDK)
-i [cameraID]   IDS Imaging camera (requires IDS peak SDK)
-m [cameraID]   MATRIX VISION mvGenTLProducer (universal GenICam, not FLIR)
-p [cameraID]   Raspberry Pi camera module (requires picamera2)
-v [cameraID]   Allied Vision VimbaX camera
-h              Show help and exit

Demo#

The base demo displays a live video screen alongside a camera control tree. It is the common superclass for all other demos and can be used as a minimal starting point for custom applications.

Minimal demo: live video screen alongside a camera control tree.

Run directly:

python -m QVideo.demos.demo
class QVideo.demos.demo.Demo(cameraTree, **kwargs)[source]#

Bases: QWidget

A demo widget that displays a video feed from a camera alongside a camera control tree.

Parameters:
  • cameraTree (QCameraTree) – The camera control tree widget to display alongside the video feed.

  • **kwargs – Additional keyword arguments forwarded to QWidget.

Notes

Sets up a horizontal layout containing a video screen on the left and a camera control tree on the right.

FilterDemo#

Extends the base Demo with an image-filter bank below the camera controls. All filters registered in QVideo.filters can be toggled and configured while the camera is streaming.

Demo combining a live video feed, camera controls, and an image-filter bank.

Run directly:

python -m QVideo.demos.filterdemo
class QVideo.demos.filterdemo.FilterDemo(cameraTree, filters, **kwargs)[source]#

Bases: Demo

Extends Demo with an image-filter bank.

Adds a QFilterBank panel below the camera control tree so that image-processing filters can be toggled and adjusted alongside the live feed.

Parameters:
  • cameraTree (QCameraTree) – The camera control tree widget to display alongside the video feed.

  • filters (list[str]) – Names of filter classes to register from QVideo.filters.

  • **kwargs – Additional keyword arguments forwarded to Demo.

addFilters(filters)[source]#

Register filters by name and show the filter bank.

Parameters:

filters (list[str]) – Names of filter classes to register from QVideo.filters.

Return type:

None

ROIdemo#

Extends QCamcorder with a draggable rectangular region-of-interest (ROI) overlay. When active, only the pixels inside the ROI are passed to the DVR, enabling high-rate recording of a cropped region without capturing the full frame.

Camcorder demo with a draggable ROI for recording a cropped video region.

Run directly:

python -m QVideo.demos.ROIdemo
class QVideo.demos.ROIdemo.ROIFilter(fps, *args, **kwargs)[source]#

Bases: RectROI

Draggable rectangular ROI that crops video frames to its bounds.

Subclasses pyqtgraph.RectROI and adds a newFrame signal and crop() slot, making it compatible with QVideoWriter as a frame source.

Parameters:
  • fps (float) – Frame rate of the video source [frames per second]. Stored as an attribute for QVideoWriter compatibility.

  • pos (list[float]) – Initial [x, y] position of the ROI.

  • size (list[float]) – Initial [width, height] of the ROI.

  • **kwargs – Additional keyword arguments forwarded to RectROI.

  • Signals

  • ——-

  • newFrame (np.ndarray) – Emitted with the cropped frame each time crop() is called.

newFrame#

Emitted with the cropped frame each time crop() is called.

crop(frame)[source]#

Crop frame to the current ROI bounds and emit newFrame.

Parameters:

frame (np.ndarray) – Input video frame to crop.

Return type:

None

class QVideo.demos.ROIdemo.ROIDemo(*args, **kwargs)[source]#

Bases: QCamcorder

Camcorder demo with a draggable ROI for recording cropped video.

Subclasses QCamcorder and overlays a resizable ROIFilter on the video screen. While recording, camera frames are routed through the ROI cropper before being saved by the DVR.

Parameters:
  • cameraTree (QCameraTree) – Camera control tree providing the video source.

  • **kwargs – Additional keyword arguments forwarded to QCamcorder.

DISPLAY_RATE#

Maximum display frame rate [fps]. Default: 30.

Type:

int

DISPLAY_RATE: int = 30#
recording(is_recording)[source]#

Respond to DVR recording state changes.

Locks the ROI and connects the camera source to the ROI cropper when recording starts; unlocks and disconnects when stopped.

Parameters:

is_recording (bool) – True when the DVR starts recording, False when stopped.

Return type:

None

TrackpyDemo#

Extends the base Demo with a QTrackpyWidget control panel. Detected particle positions are rendered as a scatter-plot directly on the live video screen using the Crocker–Grier algorithm via trackpy.

Demo combining a live video feed, camera controls, and a trackpy overlay.

Run directly:

python -m QVideo.demos.trackpydemo

See QVideo.overlays.trackpy for literature references.

class QVideo.demos.trackpydemo.TrackpyDemo(cameraTree, **kwargs)[source]#

Bases: Demo

Extends Demo with a trackpy overlay.

Adds a QTrackpyWidget control panel below the camera control tree. Detected particle positions are rendered in real time as a scatter-plot overlay on the video screen.

Parameters:
  • cameraTree (QCameraTree) – The camera control tree widget to display alongside the video feed.

  • **kwargs – Additional keyword arguments forwarded to Demo.

YoloDemo#

Extends the base Demo with a QYoloWidget control panel. Detected object bounding boxes are rendered as labeled rectangles on the live video screen using a YOLO model via the Ultralytics library.

Demo combining a live video feed, camera controls, and a YOLO overlay.

Run directly:

python -m QVideo.demos.yolodemo

See QVideo.overlays.yolo for literature references.

class QVideo.demos.yolodemo.YoloDemo(cameraTree, model_name='yolo11n.pt', **kwargs)[source]#

Bases: Demo

Extends Demo with a YOLO overlay.

Adds a QYoloWidget control panel below the camera control tree. Detected object bounding boxes are rendered in real time as a rectangle overlay on the video screen.

Parameters:
  • cameraTree (QCameraTree) – The camera control tree widget to display alongside the video feed.

  • model_name (str) – YOLO model weights file passed to QYoloWidget. Default: 'yolo11n.pt'.

  • **kwargs – Additional keyword arguments forwarded to Demo.

FilterRackDemo#

Extends QCamcorder with a dynamic QFilterRack (pre-loaded with QSmoothingFilter and QThresholdFilter) and three DVR recording modes selectable at runtime:

  • Raw — unfiltered frames at the camera’s full frame rate.

  • Filtered — rack-processed frames at the camera’s full frame rate.

  • Display — rack-processed frames at the throttled display rate.

Camcorder with an interactive filter rack and three recording modes.

Run directly:

python -m QVideo.demos.filterrackdemo

The filter rack starts with QSmoothingFilter and QThresholdFilter pre-loaded. Additional filters can be added interactively via the “Add filter…” button, and any filter can be removed or reordered by dragging.

Three recording modes are offered:

Raw

The unfiltered camera stream at the full camera frame rate.

Filtered

The rack-processed stream at the full camera frame rate. Every frame is filtered, regardless of the display throttle.

Display

The rack-processed stream at the throttled display rate. Only frames that are actually rendered to screen are recorded.

class QVideo.demos.filterrackdemo.FilterRackDemo(cameraWidget, **kwargs)[source]#

Bases: QCamcorder

Camcorder with an interactive filter rack and three recording modes.

Extends QCamcorder by adding a QFilterRack pre-loaded with QSmoothingFilter and QThresholdFilter, and a group of radio buttons to select the DVR recording source:

  • Raw: unfiltered frames at the camera’s full frame rate.

  • Filtered: rack-processed frames at the camera’s full frame rate.

  • Display: rack-processed frames at the throttled display rate.

Parameters:
  • cameraWidget (QCameraTree) – Camera control tree providing the video source.

  • **kwargs – Additional keyword arguments forwarded to QCamcorder.

dvrPlayback(playback)[source]#

Pause the filtered source during DVR playback.

Extends dvrPlayback() by suspending _FilteredSource while the DVR is playing. This prevents live camera frames from racing through the shared filter rack alongside DVR frames, which would corrupt AsyncVideoFilter results.

Parameters:

playback (bool) – True when DVR playback begins, False when it ends.

Return type:

None

CompositeDemo#

Extends QCamcorder with a trackpy particle- detection overlay and a Composite recording mode. When the Composite checkbox is enabled, the DVR records the fully rendered scene — video frame plus particle markers — rather than the raw camera frames.

Camcorder demo with trackpy overlay and composite recording.

Run directly:

python -m QVideo.demos.compositedemo

When the “Composite” checkbox is checked, the DVR records the rendered scene — video frame plus trackpy particle markers — instead of raw camera frames.

class QVideo.demos.compositedemo.CompositeDemo(cameraWidget, **kwargs)[source]#

Bases: QCamcorder

Camcorder with a trackpy overlay and composite-recording toggle.

Extends QCamcorder by adding a QTrackpyWidget control panel and a “Composite” checkbox to the controls column.

When the checkbox is unchecked (default), the DVR records raw camera frames as usual. When checked, composite is enabled on the screen and the DVR is switched to record from the screen, capturing each displayed frame with the trackpy markers composited in.

Parameters:
  • cameraWidget (QCameraTree) – Camera control tree providing the video source.

  • **kwargs – Additional keyword arguments forwarded to QCamcorder.