QVideo 4.2.0__tar.gz → 4.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qvideo-4.2.0 → qvideo-4.3.0}/PKG-INFO +1 -1
- {qvideo-4.2.0 → qvideo-4.3.0}/QVideo.egg-info/PKG-INFO +1 -1
- {qvideo-4.2.0 → qvideo-4.3.0}/QVideo.egg-info/SOURCES.txt +2 -0
- qvideo-4.3.0/lib/QFrameRelay.py +69 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QVideoScreen.py +4 -2
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/__init__.py +4 -1
- {qvideo-4.2.0 → qvideo-4.3.0}/pyproject.toml +1 -1
- qvideo-4.3.0/tests/test_qframerelay.py +122 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qvideoscreen.py +40 -8
- {qvideo-4.2.0 → qvideo-4.3.0}/LICENSE.md +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/QCamcorder.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/QVideo.egg-info/dependency_links.txt +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/QVideo.egg-info/requires.txt +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/QVideo.egg-info/top_level.txt +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/README.md +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/__main__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Basler/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Basler/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Basler/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Flir/QListFlirCameras.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Flir/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Flir/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Flir/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Genicam/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Genicam/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Genicam/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/IDS/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/IDS/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/IDS/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/MV/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/MV/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/MV/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Noise/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Noise/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Noise/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/OpenCV/QListCVCameras.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/OpenCV/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/OpenCV/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/OpenCV/_devices.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/OpenCV/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Picamera/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Picamera/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Picamera/_imx500.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Picamera/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Vimbax/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Vimbax/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/Vimbax/_tree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/cameras/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/ROIdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/circulardemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/compositedemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/demo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/filterdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/filterrackdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/histogramdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/trackpydemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/uniformitydemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/demos/yolodemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QCircularBuffer.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QCircularDVRWidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QDVRWidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QHDF5Reader.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QHDF5Writer.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QOpenCVReader.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/QOpenCVWriter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/dvr/icons_rc.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/_MedianBase.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/artistic.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/blob.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/circletransform.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/darkframe.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/dejitter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/dog.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/edge.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/exposure.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/flatfield.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/foreground.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/gamma.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/invert.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/laplacian.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/median.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/momean.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/momedian.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/normalize.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/rgb.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/roi.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/samplehold.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/smoothing.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/sobel.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/threshold.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/filters/unsharp.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QCamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QCameraTree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QFPSMeter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QFilterRack.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QFilterStack.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QHistogramWidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QListCameras.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QSnapshot.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QUniformityWidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QVideoFilter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QVideoReader.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QVideoSource.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/QVideoWriter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/_jupyter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/_qabc.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/chooser.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/clickable.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/errors.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/gentl.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/imageops.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/lib/videotypes.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/overlays/__init__.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/overlays/trackpy.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/overlays/yolo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/setup.cfg +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_artistic.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_blob.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_camera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_chooser.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_circletransform.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_circularbuffer.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_circulardemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_circulardvrwidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_clickable.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_compositedemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_darkframe.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_dejitter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_demo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_dog.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_edge.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_exposure.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_filter_export.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_filterdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_filterrackdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_filters_gray.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_flatfield.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_foreground.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_gamma.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_gentl.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_histogramdemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_histogramwidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_icons_rc.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_imageops.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_invert.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_jupyter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_laplacian.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_median.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_momean.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_momedian.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_normalize.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_overlays_package.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qabc.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qbaslercamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qcamcorder.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qcamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qcameratree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qdvrwidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qfilterrack.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qfilterstack.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qflircamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qfpsmeter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qgenicamcamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qgenicamtree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qhdf5reader.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qhdf5writer.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qidscamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qimxcamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qlistcameras.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qlistcvcameras.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qlistflircameras.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qmvcamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qnoisecamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qnoisetree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qopencvcamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qopencvdevices.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qopencvreader.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qopencvtree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qopencvwriter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qpicamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qpicameratree.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qsnapshot.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qt_binding.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qvideoreader.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qvideosource.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qvideowriter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_qvimbaxcamera.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_resolutions.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_rgb.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_roi.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_roidemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_samplehold.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_smoothing.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_sobel.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_threshold.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_trackpy_overlay.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_trackpydemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_uniformitydemo.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_uniformitywidget.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_unsharp.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_vendor_trees.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_videofilter.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_videotypes.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_yolo_overlay.py +0 -0
- {qvideo-4.2.0 → qvideo-4.3.0}/tests/test_yolodemo.py +0 -0
|
@@ -95,6 +95,7 @@ lib/QCameraTree.py
|
|
|
95
95
|
lib/QFPSMeter.py
|
|
96
96
|
lib/QFilterRack.py
|
|
97
97
|
lib/QFilterStack.py
|
|
98
|
+
lib/QFrameRelay.py
|
|
98
99
|
lib/QHistogramWidget.py
|
|
99
100
|
lib/QListCameras.py
|
|
100
101
|
lib/QSnapshot.py
|
|
@@ -163,6 +164,7 @@ tests/test_qfilterrack.py
|
|
|
163
164
|
tests/test_qfilterstack.py
|
|
164
165
|
tests/test_qflircamera.py
|
|
165
166
|
tests/test_qfpsmeter.py
|
|
167
|
+
tests/test_qframerelay.py
|
|
166
168
|
tests/test_qgenicamcamera.py
|
|
167
169
|
tests/test_qgenicamtree.py
|
|
168
170
|
tests/test_qhdf5reader.py
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'''Latest-frame handoff from a capture thread to the thread of a consumer.'''
|
|
2
|
+
import numpy as np
|
|
3
|
+
from qtpy import QtCore
|
|
4
|
+
from QVideo.lib.videotypes import Image, FrameInfo
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
__all__ = ['QFrameRelay']
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class QFrameRelay(QtCore.QObject):
|
|
11
|
+
|
|
12
|
+
'''Pass the newest frame of a source to the thread this object lives in.
|
|
13
|
+
|
|
14
|
+
A queued connection delivers every frame, so while the receiving thread
|
|
15
|
+
is busy (a modal dialog, a window drag, heavy painting) the frames wait
|
|
16
|
+
in its event queue without limit: three seconds of a 200 fps, 2048 x 2048
|
|
17
|
+
camera hold 1.5 GB. The relay keeps one frame instead. A frame that
|
|
18
|
+
arrives before the previous one was taken replaces it, and the receiving
|
|
19
|
+
thread is woken at most once, so its event queue stays short and it
|
|
20
|
+
always gets the latest frame.
|
|
21
|
+
|
|
22
|
+
Use it for consumers that only show or sample the stream. A consumer
|
|
23
|
+
that needs every frame, such as a recorder, connects to the source.
|
|
24
|
+
|
|
25
|
+
The relay is the receiver of ``source.newFrame`` through a direct
|
|
26
|
+
connection, so it runs in the capture thread and never blocks it. It
|
|
27
|
+
lives in the thread that created it; frames with the same
|
|
28
|
+
:class:`~QVideo.lib.videotypes.FrameInfo` the source emitted arrive in
|
|
29
|
+
that thread. A consumer behind a relay sees gaps in ``info.index`` where
|
|
30
|
+
frames were replaced.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
source : QVideoSource
|
|
35
|
+
Provider of ``newFrame(ndarray, FrameInfo)``, or of
|
|
36
|
+
``newFrame(ndarray)``.
|
|
37
|
+
|
|
38
|
+
Signals
|
|
39
|
+
-------
|
|
40
|
+
newFrame(ndarray, FrameInfo)
|
|
41
|
+
The newest frame since the previous emission.
|
|
42
|
+
'''
|
|
43
|
+
|
|
44
|
+
newFrame = QtCore.Signal(np.ndarray, object)
|
|
45
|
+
_wake = QtCore.Signal()
|
|
46
|
+
|
|
47
|
+
def __init__(self, source) -> None:
|
|
48
|
+
super().__init__()
|
|
49
|
+
self._mutex = QtCore.QMutex()
|
|
50
|
+
self._latest: tuple[Image, FrameInfo | None] | None = None
|
|
51
|
+
self._wake.connect(self._deliver)
|
|
52
|
+
source.newFrame.connect(self._offer, QtCore.Qt.DirectConnection)
|
|
53
|
+
|
|
54
|
+
@QtCore.Slot(np.ndarray)
|
|
55
|
+
@QtCore.Slot(np.ndarray, object)
|
|
56
|
+
def _offer(self, frame: Image, info: FrameInfo | None = None) -> None:
|
|
57
|
+
'''Keep *frame*; runs in the thread that emitted ``newFrame``.'''
|
|
58
|
+
with QtCore.QMutexLocker(self._mutex):
|
|
59
|
+
idle, self._latest = self._latest is None, (frame, info)
|
|
60
|
+
if idle:
|
|
61
|
+
self._wake.emit()
|
|
62
|
+
|
|
63
|
+
@QtCore.Slot()
|
|
64
|
+
def _deliver(self) -> None:
|
|
65
|
+
'''Pass the kept frame on; runs in the thread of the relay.'''
|
|
66
|
+
with QtCore.QMutexLocker(self._mutex):
|
|
67
|
+
frame, info = self._latest
|
|
68
|
+
self._latest = None
|
|
69
|
+
self.newFrame.emit(frame, info)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'''Live video display widget with mouse-aware graphical overlay support.'''
|
|
2
2
|
from qtpy import QtCore, QtGui, QtWidgets
|
|
3
3
|
from QVideo.lib.QVideoSource import QVideoSource
|
|
4
|
+
from QVideo.lib.QFrameRelay import QFrameRelay
|
|
4
5
|
from QVideo.lib.videotypes import FrameInfo
|
|
5
6
|
from QVideo.lib.videotypes import Image
|
|
6
7
|
import numpy as np
|
|
@@ -112,14 +113,15 @@ class QVideoScreen(GraphicsLayoutWidget):
|
|
|
112
113
|
def source(self, source: QVideoSource | None) -> None:
|
|
113
114
|
if self._source is not None:
|
|
114
115
|
self._source.shapeChanged.disconnect(self.updateShape)
|
|
115
|
-
self._source.newFrame.disconnect(self.setImage)
|
|
116
116
|
self._source = source
|
|
117
|
+
self._relay = None
|
|
117
118
|
if source is None:
|
|
118
119
|
return
|
|
119
120
|
if source.shape is not None:
|
|
120
121
|
self.updateShape(source.shape)
|
|
121
122
|
self._source.shapeChanged.connect(self.updateShape)
|
|
122
|
-
self.
|
|
123
|
+
self._relay = QFrameRelay(source)
|
|
124
|
+
self._relay.newFrame.connect(self.setImage)
|
|
123
125
|
|
|
124
126
|
@property
|
|
125
127
|
def framerate(self) -> int | None:
|
|
@@ -19,6 +19,8 @@ QVideoScreen
|
|
|
19
19
|
Widget that displays frames emitted by a :class:`QVideoSource`.
|
|
20
20
|
VideoFilter
|
|
21
21
|
Base class for composable image-processing filters.
|
|
22
|
+
QFrameRelay
|
|
23
|
+
Latest-frame handoff from a capture thread to a GUI-thread consumer.
|
|
22
24
|
QVideoFilter
|
|
23
25
|
Qt widget wrapper around a :class:`VideoFilter`.
|
|
24
26
|
QFilterRack
|
|
@@ -45,6 +47,7 @@ from .QCameraTree import QCameraTree
|
|
|
45
47
|
from .QVideoScreen import QVideoScreen
|
|
46
48
|
from .QFilterRack import QFilterRack
|
|
47
49
|
from .QFilterStack import QFilterStack
|
|
50
|
+
from .QFrameRelay import QFrameRelay
|
|
48
51
|
from .QVideoFilter import VideoFilter, QVideoFilter
|
|
49
52
|
from .QVideoReader import QVideoReader
|
|
50
53
|
from .QVideoWriter import QVideoWriter
|
|
@@ -60,6 +63,6 @@ __all__ = '''Image
|
|
|
60
63
|
FrameInfo
|
|
61
64
|
clickable Camera choose_camera QListCameras
|
|
62
65
|
QCamera QCameraError QDriverError QDeviceError QVideoSource QCameraTree
|
|
63
|
-
QFilterRack QFilterStack
|
|
66
|
+
QFilterRack QFilterStack QFrameRelay
|
|
64
67
|
QVideoReader QVideoWriter QVideoScreen
|
|
65
68
|
QFPSMeter QHistogramWidget QUniformityWidget QSnapshot VideoFilter QVideoFilter'''.split()
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "QVideo"
|
|
7
|
-
version = "4.
|
|
7
|
+
version = "4.3.0"
|
|
8
8
|
description = "PyQt-based framework for integrating video cameras into research applications"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "GPL-3.0-or-later" }
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'''Unit tests for QFrameRelay.'''
|
|
2
|
+
import gc
|
|
3
|
+
import threading
|
|
4
|
+
import unittest
|
|
5
|
+
import numpy as np
|
|
6
|
+
from qtpy import QtCore, QtWidgets
|
|
7
|
+
from QVideo.lib.QFrameRelay import QFrameRelay
|
|
8
|
+
from QVideo.lib.videotypes import FrameInfo
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication([])
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class _Source(QtCore.QObject):
|
|
15
|
+
newFrame = QtCore.Signal(np.ndarray, object)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class _PlainSource(QtCore.QObject):
|
|
19
|
+
newFrame = QtCore.Signal(np.ndarray)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def frame(n: int) -> np.ndarray:
|
|
23
|
+
return np.full((2, 2), n, dtype=np.uint8)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def emit_from_thread(source, indices):
|
|
27
|
+
'''Emit frames from a thread other than the one running the relay.'''
|
|
28
|
+
def run():
|
|
29
|
+
for n in indices:
|
|
30
|
+
source.newFrame.emit(frame(n), FrameInfo(n, float(n)))
|
|
31
|
+
thread = threading.Thread(target=run)
|
|
32
|
+
thread.start()
|
|
33
|
+
thread.join()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class RelayTestCase(unittest.TestCase):
|
|
37
|
+
|
|
38
|
+
def make(self, source=None):
|
|
39
|
+
self.source = source or _Source()
|
|
40
|
+
self.relay = QFrameRelay(self.source)
|
|
41
|
+
self.out = []
|
|
42
|
+
self.relay.newFrame.connect(
|
|
43
|
+
lambda image, info: self.out.append((int(image[0, 0]), info)))
|
|
44
|
+
return self.relay
|
|
45
|
+
|
|
46
|
+
def values(self):
|
|
47
|
+
return [value for value, _ in self.out]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class TestDelivery(RelayTestCase):
|
|
51
|
+
|
|
52
|
+
def test_a_frame_arrives(self):
|
|
53
|
+
self.make()
|
|
54
|
+
emit_from_thread(self.source, [1])
|
|
55
|
+
app.processEvents()
|
|
56
|
+
self.assertEqual(self.values(), [1])
|
|
57
|
+
|
|
58
|
+
def test_the_info_arrives_unchanged(self):
|
|
59
|
+
self.make()
|
|
60
|
+
emit_from_thread(self.source, [4])
|
|
61
|
+
app.processEvents()
|
|
62
|
+
self.assertEqual(self.out[0][1], FrameInfo(4, 4.))
|
|
63
|
+
|
|
64
|
+
def test_a_one_argument_source_gives_no_info(self):
|
|
65
|
+
source = _PlainSource()
|
|
66
|
+
self.make(source)
|
|
67
|
+
source.newFrame.emit(frame(1))
|
|
68
|
+
app.processEvents()
|
|
69
|
+
self.assertEqual(self.out, [(1, None)])
|
|
70
|
+
|
|
71
|
+
def test_frames_in_the_receiving_thread_arrive_at_once(self):
|
|
72
|
+
self.make()
|
|
73
|
+
self.source.newFrame.emit(frame(1), FrameInfo(1, 1.))
|
|
74
|
+
self.source.newFrame.emit(frame(2), FrameInfo(2, 2.))
|
|
75
|
+
self.assertEqual(self.values(), [1, 2])
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class TestLatestWins(RelayTestCase):
|
|
79
|
+
|
|
80
|
+
def test_a_busy_receiver_gets_only_the_newest_frame(self):
|
|
81
|
+
self.make()
|
|
82
|
+
emit_from_thread(self.source, range(50))
|
|
83
|
+
app.processEvents()
|
|
84
|
+
self.assertEqual(self.values(), [49])
|
|
85
|
+
|
|
86
|
+
def test_the_receiver_is_woken_once_while_it_is_busy(self):
|
|
87
|
+
self.make()
|
|
88
|
+
wakes = []
|
|
89
|
+
self.relay._wake.connect(lambda: wakes.append(1))
|
|
90
|
+
emit_from_thread(self.source, range(50))
|
|
91
|
+
app.processEvents()
|
|
92
|
+
self.assertEqual(len(wakes), 1)
|
|
93
|
+
|
|
94
|
+
def test_the_next_frame_is_delivered_after_a_pickup(self):
|
|
95
|
+
self.make()
|
|
96
|
+
emit_from_thread(self.source, range(5))
|
|
97
|
+
app.processEvents()
|
|
98
|
+
emit_from_thread(self.source, range(5, 10))
|
|
99
|
+
app.processEvents()
|
|
100
|
+
self.assertEqual(self.values(), [4, 9])
|
|
101
|
+
|
|
102
|
+
def test_nothing_is_delivered_twice(self):
|
|
103
|
+
self.make()
|
|
104
|
+
emit_from_thread(self.source, [1])
|
|
105
|
+
app.processEvents()
|
|
106
|
+
app.processEvents()
|
|
107
|
+
self.assertEqual(self.values(), [1])
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class TestLifetime(RelayTestCase):
|
|
111
|
+
|
|
112
|
+
def test_a_deleted_relay_receives_nothing_and_raises_nothing(self):
|
|
113
|
+
self.make()
|
|
114
|
+
del self.relay
|
|
115
|
+
gc.collect()
|
|
116
|
+
emit_from_thread(self.source, [1])
|
|
117
|
+
app.processEvents()
|
|
118
|
+
self.assertEqual(self.out, [])
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if __name__ == '__main__':
|
|
122
|
+
unittest.main()
|
|
@@ -21,6 +21,14 @@ def make_mock_source(fps=30., width=640, height=480):
|
|
|
21
21
|
return source
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
class _Emitter(QtCore.QObject):
|
|
25
|
+
'''A source with real Qt signals.'''
|
|
26
|
+
newFrame = QtCore.Signal(np.ndarray, object)
|
|
27
|
+
shapeChanged = QtCore.Signal(QtCore.QSize)
|
|
28
|
+
fps = 30.
|
|
29
|
+
shape = QtCore.QSize(640, 480)
|
|
30
|
+
|
|
31
|
+
|
|
24
32
|
def _spy(screen, signal_name='newFrame'):
|
|
25
33
|
return QtTest.QSignalSpy(getattr(screen, signal_name))
|
|
26
34
|
|
|
@@ -108,11 +116,24 @@ class TestSource(unittest.TestCase):
|
|
|
108
116
|
screen.source = source
|
|
109
117
|
source.shapeChanged.connect.assert_called_once_with(screen.updateShape)
|
|
110
118
|
|
|
111
|
-
def
|
|
119
|
+
def test_frames_from_the_source_are_displayed(self):
|
|
112
120
|
screen = make_screen()
|
|
113
|
-
source =
|
|
121
|
+
source = _Emitter()
|
|
114
122
|
screen.source = source
|
|
115
|
-
|
|
123
|
+
info = FrameInfo(3, 1.)
|
|
124
|
+
with patch.object(screen.image, 'setImage') as show:
|
|
125
|
+
source.newFrame.emit(_FRAME, info)
|
|
126
|
+
show.assert_called_once()
|
|
127
|
+
|
|
128
|
+
def test_the_info_of_a_frame_is_passed_on(self):
|
|
129
|
+
screen = make_screen()
|
|
130
|
+
source = _Emitter()
|
|
131
|
+
screen.source = source
|
|
132
|
+
seen = []
|
|
133
|
+
screen.newFrame.connect(lambda frame, info: seen.append(info))
|
|
134
|
+
info = FrameInfo(3, 1.)
|
|
135
|
+
source.newFrame.emit(_FRAME, info)
|
|
136
|
+
self.assertEqual(seen, [info])
|
|
116
137
|
|
|
117
138
|
def test_source_disconnects_old_shape_changed(self):
|
|
118
139
|
screen = make_screen()
|
|
@@ -121,12 +142,23 @@ class TestSource(unittest.TestCase):
|
|
|
121
142
|
screen.source = make_mock_source()
|
|
122
143
|
old_source.shapeChanged.disconnect.assert_called_once_with(screen.updateShape)
|
|
123
144
|
|
|
124
|
-
def
|
|
145
|
+
def test_frames_from_the_old_source_are_ignored(self):
|
|
125
146
|
screen = make_screen()
|
|
126
|
-
|
|
127
|
-
screen.source =
|
|
128
|
-
screen.source =
|
|
129
|
-
|
|
147
|
+
old = _Emitter()
|
|
148
|
+
screen.source = old
|
|
149
|
+
screen.source = _Emitter()
|
|
150
|
+
with patch.object(screen.image, 'setImage') as show:
|
|
151
|
+
old.newFrame.emit(_FRAME, FrameInfo(0, 0.))
|
|
152
|
+
show.assert_not_called()
|
|
153
|
+
|
|
154
|
+
def test_clearing_the_source_stops_the_frames(self):
|
|
155
|
+
screen = make_screen()
|
|
156
|
+
source = _Emitter()
|
|
157
|
+
screen.source = source
|
|
158
|
+
screen.source = None
|
|
159
|
+
with patch.object(screen.image, 'setImage') as show:
|
|
160
|
+
source.newFrame.emit(_FRAME, FrameInfo(0, 0.))
|
|
161
|
+
show.assert_not_called()
|
|
130
162
|
|
|
131
163
|
def test_source_no_disconnect_when_none(self):
|
|
132
164
|
'''Setting source for the first time should not attempt to disconnect.'''
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|