QVideo 4.0.1__tar.gz → 4.2.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.0.1 → qvideo-4.2.0}/PKG-INFO +2 -1
- {qvideo-4.0.1 → qvideo-4.2.0}/QVideo.egg-info/PKG-INFO +2 -1
- {qvideo-4.0.1 → qvideo-4.2.0}/QVideo.egg-info/requires.txt +1 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Flir/_camera.py +1 -1
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QCircularBuffer.py +4 -12
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QDVRWidget.py +77 -3
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QFilterRack.py +1 -1
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QFilterStack.py +7 -3
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QVideoSource.py +7 -3
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QVideoWriter.py +27 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/pyproject.toml +2 -1
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_circularbuffer.py +2 -25
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qdvrwidget.py +139 -5
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qfilterstack.py +8 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qvideosource.py +12 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qvideowriter.py +66 -1
- {qvideo-4.0.1 → qvideo-4.2.0}/LICENSE.md +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/QCamcorder.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/QVideo.egg-info/SOURCES.txt +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/QVideo.egg-info/dependency_links.txt +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/QVideo.egg-info/top_level.txt +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/README.md +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/__main__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Basler/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Basler/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Basler/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Flir/QListFlirCameras.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Flir/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Flir/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Genicam/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Genicam/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Genicam/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/IDS/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/IDS/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/IDS/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/MV/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/MV/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/MV/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Noise/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Noise/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Noise/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/OpenCV/QListCVCameras.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/OpenCV/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/OpenCV/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/OpenCV/_devices.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/OpenCV/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Picamera/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Picamera/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Picamera/_imx500.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Picamera/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Vimbax/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Vimbax/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/Vimbax/_tree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/cameras/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/ROIdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/circulardemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/compositedemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/demo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/filterdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/filterrackdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/histogramdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/trackpydemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/uniformitydemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/demos/yolodemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QCircularDVRWidget.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QHDF5Reader.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QHDF5Writer.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QOpenCVReader.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/QOpenCVWriter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/dvr/icons_rc.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/_MedianBase.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/artistic.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/blob.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/circletransform.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/darkframe.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/dejitter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/dog.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/edge.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/exposure.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/flatfield.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/foreground.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/gamma.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/invert.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/laplacian.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/median.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/momean.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/momedian.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/normalize.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/rgb.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/roi.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/samplehold.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/smoothing.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/sobel.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/threshold.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/filters/unsharp.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QCamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QCameraTree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QFPSMeter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QHistogramWidget.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QListCameras.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QSnapshot.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QUniformityWidget.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QVideoFilter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QVideoReader.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/QVideoScreen.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/_jupyter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/_qabc.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/chooser.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/clickable.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/errors.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/gentl.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/imageops.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/lib/videotypes.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/overlays/__init__.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/overlays/trackpy.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/overlays/yolo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/setup.cfg +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_artistic.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_blob.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_camera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_chooser.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_circletransform.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_circulardemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_circulardvrwidget.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_clickable.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_compositedemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_darkframe.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_dejitter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_demo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_dog.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_edge.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_exposure.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_filter_export.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_filterdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_filterrackdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_filters_gray.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_flatfield.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_foreground.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_gamma.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_gentl.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_histogramdemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_histogramwidget.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_icons_rc.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_imageops.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_invert.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_jupyter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_laplacian.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_median.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_momean.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_momedian.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_normalize.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_overlays_package.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qabc.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qbaslercamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qcamcorder.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qcamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qcameratree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qfilterrack.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qflircamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qfpsmeter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qgenicamcamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qgenicamtree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qhdf5reader.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qhdf5writer.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qidscamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qimxcamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qlistcameras.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qlistcvcameras.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qlistflircameras.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qmvcamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qnoisecamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qnoisetree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qopencvcamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qopencvdevices.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qopencvreader.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qopencvtree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qopencvwriter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qpicamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qpicameratree.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qsnapshot.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qt_binding.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qvideoreader.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qvideoscreen.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_qvimbaxcamera.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_resolutions.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_rgb.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_roi.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_roidemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_samplehold.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_smoothing.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_sobel.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_threshold.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_trackpy_overlay.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_trackpydemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_uniformitydemo.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_uniformitywidget.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_unsharp.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_vendor_trees.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_videofilter.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_videotypes.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_yolo_overlay.py +0 -0
- {qvideo-4.0.1 → qvideo-4.2.0}/tests/test_yolodemo.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: QVideo
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: PyQt-based framework for integrating video cameras into research applications
|
|
5
5
|
Author-email: "David G. Grier" <david.grier@nyu.edu>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -26,6 +26,7 @@ Requires-Dist: numpy
|
|
|
26
26
|
Requires-Dist: opencv-python
|
|
27
27
|
Requires-Dist: qtpy
|
|
28
28
|
Requires-Dist: pyqtgraph
|
|
29
|
+
Requires-Dist: psutil
|
|
29
30
|
Provides-Extra: pyqt5
|
|
30
31
|
Requires-Dist: PyQt5; extra == "pyqt5"
|
|
31
32
|
Requires-Dist: PyQt5-sip; extra == "pyqt5"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: QVideo
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: PyQt-based framework for integrating video cameras into research applications
|
|
5
5
|
Author-email: "David G. Grier" <david.grier@nyu.edu>
|
|
6
6
|
License: GPL-3.0-or-later
|
|
@@ -26,6 +26,7 @@ Requires-Dist: numpy
|
|
|
26
26
|
Requires-Dist: opencv-python
|
|
27
27
|
Requires-Dist: qtpy
|
|
28
28
|
Requires-Dist: pyqtgraph
|
|
29
|
+
Requires-Dist: psutil
|
|
29
30
|
Provides-Extra: pyqt5
|
|
30
31
|
Requires-Dist: PyQt5; extra == "pyqt5"
|
|
31
32
|
Requires-Dist: PyQt5-sip; extra == "pyqt5"
|
|
@@ -34,7 +34,7 @@ class QFlirCamera(QGenicamCamera):
|
|
|
34
34
|
_producer_filenames = ('Spinnaker_GenTL.cti',)
|
|
35
35
|
_producerHint = ('Install the Spinnaker SDK and set GENICAM_GENTL64_PATH '
|
|
36
36
|
'to the directory containing Spinnaker_GenTL.cti '
|
|
37
|
-
'(typically /opt/spinnaker/lib/spinnaker-gentl).')
|
|
37
|
+
'(on Linux, typically /opt/spinnaker/lib/spinnaker-gentl).')
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
class QFlirSource(QGenicamSource):
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'''Ring buffer that accumulates timestamped frames for later saving.'''
|
|
2
|
-
import os
|
|
3
2
|
from collections import deque
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from time import time
|
|
6
5
|
from qtpy import QtCore
|
|
7
6
|
import numpy as np
|
|
7
|
+
import psutil
|
|
8
8
|
import logging
|
|
9
9
|
|
|
10
10
|
from QVideo.lib.videotypes import Image, FrameInfo
|
|
@@ -99,22 +99,14 @@ class QCircularBuffer(QtCore.QObject):
|
|
|
99
99
|
|
|
100
100
|
@staticmethod
|
|
101
101
|
def _totalRAM() -> int:
|
|
102
|
-
'''Return total physical RAM in bytes
|
|
103
|
-
|
|
104
|
-
import psutil
|
|
105
|
-
return psutil.virtual_memory().total
|
|
106
|
-
except ImportError:
|
|
107
|
-
pass
|
|
108
|
-
try:
|
|
109
|
-
return os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')
|
|
110
|
-
except (AttributeError, ValueError):
|
|
111
|
-
return 0
|
|
102
|
+
'''Return total physical RAM in bytes.'''
|
|
103
|
+
return psutil.virtual_memory().total
|
|
112
104
|
|
|
113
105
|
def _checkMemory(self) -> None:
|
|
114
106
|
self._warned = True
|
|
115
107
|
estimated = self._buffer.maxlen * self._frameBytes
|
|
116
108
|
total = self._totalRAM()
|
|
117
|
-
if
|
|
109
|
+
if estimated > _MEMORY_WARN_FRACTION * total:
|
|
118
110
|
est_mb = estimated / 1024 ** 2
|
|
119
111
|
pct = 100 * estimated / total
|
|
120
112
|
total_gb = total / 1024 ** 3
|
|
@@ -3,8 +3,9 @@ from collections.abc import Callable
|
|
|
3
3
|
from qtpy import QtCore, QtGui, QtWidgets
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import numpy as np
|
|
6
|
+
import psutil
|
|
6
7
|
from QVideo.lib import clickable, QVideoSource
|
|
7
|
-
from QVideo.lib.videotypes import Image
|
|
8
|
+
from QVideo.lib.videotypes import Image, FrameInfo
|
|
8
9
|
from .QOpenCVWriter import QOpenCVWriter
|
|
9
10
|
from .QOpenCVReader import QOpenCVSource
|
|
10
11
|
|
|
@@ -55,6 +56,20 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
55
56
|
filename : str or None
|
|
56
57
|
Default file path for saving. If ``None``, defaults to
|
|
57
58
|
``~/default.mkv``.
|
|
59
|
+
stopWhenBehind : bool
|
|
60
|
+
Stop recording when the writer falls more than *lagLimit* seconds
|
|
61
|
+
behind the camera. A recorder must not drop frames, so frames
|
|
62
|
+
queue in memory while storage is slower than the camera; stopping
|
|
63
|
+
keeps a slow disk from filling memory. Set ``False`` to record
|
|
64
|
+
through the backlog. Default: ``True``.
|
|
65
|
+
lagLimit : float
|
|
66
|
+
How far [seconds] the writer may fall behind the newest captured
|
|
67
|
+
frame. Default: ``1.``.
|
|
68
|
+
maxMemory : float or None
|
|
69
|
+
Memory [bytes] that frames waiting for the writer may occupy.
|
|
70
|
+
The recording is treated as behind as soon as the backlog would
|
|
71
|
+
exceed it, whatever *lagLimit* says. ``None`` means 80% of the
|
|
72
|
+
memory available when recording starts. Default: ``None``.
|
|
58
73
|
*args :
|
|
59
74
|
Forwarded to :class:`~qtpy.QtWidgets.QFrame`.
|
|
60
75
|
**kwargs :
|
|
@@ -68,6 +83,20 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
68
83
|
Emitted when recording starts (``True``) or stops (``False``).
|
|
69
84
|
playing(bool)
|
|
70
85
|
Emitted when playback starts (``True``) or stops (``False``).
|
|
86
|
+
behind(float)
|
|
87
|
+
Emitted once each time the recording falls behind the camera by
|
|
88
|
+
more than *lagLimit* seconds or *maxMemory* bytes, with the lag
|
|
89
|
+
in seconds.
|
|
90
|
+
stopped(str)
|
|
91
|
+
Emitted with the reason when the widget stops a recording by
|
|
92
|
+
itself, just before ``recording(False)``.
|
|
93
|
+
|
|
94
|
+
Notes
|
|
95
|
+
-----
|
|
96
|
+
Stopping waits for the writer to finish the frames already captured,
|
|
97
|
+
so no recorded frame is lost. With *stopWhenBehind* the wait is
|
|
98
|
+
bounded by the smaller of *lagLimit* seconds and *maxMemory* bytes of
|
|
99
|
+
data.
|
|
71
100
|
'''
|
|
72
101
|
|
|
73
102
|
#: Emitted for each frame during playback.
|
|
@@ -76,6 +105,11 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
76
105
|
recording = QtCore.Signal(bool)
|
|
77
106
|
#: Emitted when playback starts (``True``) or stops (``False``).
|
|
78
107
|
playing = QtCore.Signal(bool)
|
|
108
|
+
#: Emitted when the recording falls behind the camera, with the lag [s].
|
|
109
|
+
behind = QtCore.Signal(float)
|
|
110
|
+
#: Emitted with the reason when the widget stops a recording itself.
|
|
111
|
+
stopped = QtCore.Signal(str)
|
|
112
|
+
_shutdown = QtCore.Signal()
|
|
79
113
|
|
|
80
114
|
FILENAME = 'default.mkv'
|
|
81
115
|
|
|
@@ -131,12 +165,20 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
131
165
|
*args,
|
|
132
166
|
source: QVideoSource | None = None,
|
|
133
167
|
filename: str = '',
|
|
168
|
+
stopWhenBehind: bool = True,
|
|
169
|
+
lagLimit: float = 1.,
|
|
170
|
+
maxMemory: float | None = None,
|
|
134
171
|
**kwargs) -> None:
|
|
135
172
|
super().__init__(*args, **kwargs)
|
|
173
|
+
self.stopWhenBehind = stopWhenBehind
|
|
174
|
+
self.lagLimit = lagLimit
|
|
175
|
+
self.maxMemory = maxMemory
|
|
176
|
+
self._budget = float('inf')
|
|
136
177
|
self._source: QVideoSource | None = None
|
|
137
178
|
self._writer: object | None = None
|
|
138
179
|
self._player: QVideoSource | None = None
|
|
139
180
|
self._thread: QtCore.QThread | None = None
|
|
181
|
+
self._late = False
|
|
140
182
|
self._setupUi()
|
|
141
183
|
self._connectSignals()
|
|
142
184
|
self.source = source
|
|
@@ -329,12 +371,17 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
329
371
|
fps=self.source.fps,
|
|
330
372
|
nframes=self.nframes.value(),
|
|
331
373
|
nskip=self.nskip.value())
|
|
374
|
+
self._late = False
|
|
375
|
+
self._budget = (self.maxMemory
|
|
376
|
+
or 0.8 * psutil.virtual_memory().available)
|
|
332
377
|
self._writer.frameNumber.connect(self.setFrameNumber)
|
|
333
378
|
self._writer.finished.connect(self.stop)
|
|
334
379
|
self._thread = QtCore.QThread()
|
|
335
380
|
self._writer.moveToThread(self._thread)
|
|
381
|
+
self._shutdown.connect(self._writer.shutdown)
|
|
336
382
|
self._thread.start()
|
|
337
383
|
self.source.newFrame.connect(self._writer.write)
|
|
384
|
+
self.source.newFrame.connect(self._watch)
|
|
338
385
|
self.recording.emit(True)
|
|
339
386
|
|
|
340
387
|
@QtCore.Slot()
|
|
@@ -390,14 +437,14 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
390
437
|
logger.debug('Stopping Recording')
|
|
391
438
|
try:
|
|
392
439
|
self.source.newFrame.disconnect(self._writer.write)
|
|
440
|
+
self.source.newFrame.disconnect(self._watch)
|
|
393
441
|
self._writer.frameNumber.disconnect(self.setFrameNumber)
|
|
394
442
|
self._writer.finished.disconnect(self.stop)
|
|
395
443
|
except (RuntimeError, TypeError):
|
|
396
444
|
logger.debug(
|
|
397
445
|
'Some recording signals were already disconnected')
|
|
398
|
-
self.
|
|
446
|
+
self._shutdown.emit()
|
|
399
447
|
self._thread.wait()
|
|
400
|
-
self._writer.close()
|
|
401
448
|
self._thread = None
|
|
402
449
|
self._writer = None
|
|
403
450
|
self.recording.emit(False)
|
|
@@ -418,6 +465,33 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
418
465
|
self.stop()
|
|
419
466
|
super().closeEvent(event)
|
|
420
467
|
|
|
468
|
+
@QtCore.Slot(np.ndarray)
|
|
469
|
+
@QtCore.Slot(np.ndarray, object)
|
|
470
|
+
def _watch(self, frame: Image, info: FrameInfo | None = None) -> None:
|
|
471
|
+
'''Compare each captured frame with the newest one the writer has
|
|
472
|
+
taken up, and report once each time the writer falls behind.
|
|
473
|
+
|
|
474
|
+
The comparison uses the capture times, so it measures the backlog
|
|
475
|
+
even while the writer is stuck inside a single write, and it
|
|
476
|
+
ignores sources that capture slowly. The memory budget is
|
|
477
|
+
converted to the time it takes the camera to fill it, so one
|
|
478
|
+
limit serves both.
|
|
479
|
+
'''
|
|
480
|
+
taken = self._writer and self._writer.received
|
|
481
|
+
if info is None or not taken:
|
|
482
|
+
return
|
|
483
|
+
lag = info.timestamp - taken.timestamp
|
|
484
|
+
fill = self._budget / (self.source.fps * frame.nbytes)
|
|
485
|
+
late = lag > min(self.lagLimit, fill)
|
|
486
|
+
if late and not self._late:
|
|
487
|
+
self.behind.emit(lag)
|
|
488
|
+
if self.stopWhenBehind:
|
|
489
|
+
reason = f'recording fell {lag:.1f} s behind the camera'
|
|
490
|
+
logger.error(reason)
|
|
491
|
+
self.stopped.emit(reason)
|
|
492
|
+
self.stop()
|
|
493
|
+
self._late = late
|
|
494
|
+
|
|
421
495
|
@QtCore.Slot(int)
|
|
422
496
|
def setFrameNumber(self, framenumber: int) -> None:
|
|
423
497
|
'''Set the displayed frame number.'''
|
|
@@ -447,7 +447,7 @@ class QFilterRack(QtWidgets.QWidget):
|
|
|
447
447
|
path, _ = QtWidgets.QFileDialog.getSaveFileName(
|
|
448
448
|
self, 'Export Pipeline', 'filter.py', 'Python files (*.py)')
|
|
449
449
|
if path:
|
|
450
|
-
with open(path, 'w') as fh:
|
|
450
|
+
with open(path, 'w', encoding='utf-8') as fh:
|
|
451
451
|
fh.write(self.exportPipeline())
|
|
452
452
|
|
|
453
453
|
def _removeSlot(self, slot: '_FilterSlot') -> None:
|
|
@@ -213,9 +213,13 @@ class QFilterStack(QtCore.QThread):
|
|
|
213
213
|
return frame
|
|
214
214
|
|
|
215
215
|
def __del__(self) -> None:
|
|
216
|
-
#
|
|
217
|
-
#
|
|
218
|
-
|
|
216
|
+
# The garbage collector may get here after Qt has deleted the C++
|
|
217
|
+
# object (or before it was built): then there is no thread to stop.
|
|
218
|
+
try:
|
|
219
|
+
running = self.isRunning()
|
|
220
|
+
except RuntimeError:
|
|
221
|
+
return
|
|
222
|
+
if running:
|
|
219
223
|
self.stop()
|
|
220
224
|
|
|
221
225
|
@QtCore.Slot()
|
|
@@ -144,9 +144,13 @@ class QVideoSource(QtCore.QThread):
|
|
|
144
144
|
logger.debug('streaming finished')
|
|
145
145
|
|
|
146
146
|
def __del__(self) -> None:
|
|
147
|
-
#
|
|
148
|
-
#
|
|
149
|
-
|
|
147
|
+
# The garbage collector may get here after Qt has deleted the C++
|
|
148
|
+
# object (or before it was built): then there is no thread to stop.
|
|
149
|
+
try:
|
|
150
|
+
running = self.isRunning()
|
|
151
|
+
except RuntimeError:
|
|
152
|
+
return
|
|
153
|
+
if running:
|
|
150
154
|
self.stop()
|
|
151
155
|
self.wait()
|
|
152
156
|
|
|
@@ -48,6 +48,9 @@ class QVideoWriter(QtCore.QObject, metaclass=QABCMeta):
|
|
|
48
48
|
Write a video frame to the file.
|
|
49
49
|
close() -> None
|
|
50
50
|
Close the video file.
|
|
51
|
+
shutdown() -> None
|
|
52
|
+
Close the file and end the writer's thread, after the frames
|
|
53
|
+
already waiting have been written.
|
|
51
54
|
|
|
52
55
|
Properties
|
|
53
56
|
----------
|
|
@@ -59,6 +62,17 @@ class QVideoWriter(QtCore.QObject, metaclass=QABCMeta):
|
|
|
59
62
|
Write every *nskip*-th frame received; 1 writes every frame.
|
|
60
63
|
nframes : int
|
|
61
64
|
The maximum number of frames to write.
|
|
65
|
+
received : FrameInfo or None
|
|
66
|
+
Capture metadata of the newest frame handed to :meth:`write`, or
|
|
67
|
+
``None`` before the first. Compared with the newest frame the
|
|
68
|
+
camera has captured, it measures how far the writer is behind.
|
|
69
|
+
|
|
70
|
+
Notes
|
|
71
|
+
-----
|
|
72
|
+
A writer must not drop frames, so frames queue in memory while storage
|
|
73
|
+
is slower than the camera. The writer does not police that backlog;
|
|
74
|
+
the code that owns the recording does (see
|
|
75
|
+
:class:`~QVideo.dvr.QDVRWidget.QDVRWidget`).
|
|
62
76
|
|
|
63
77
|
Abstract Methods
|
|
64
78
|
----------------
|
|
@@ -90,6 +104,7 @@ class QVideoWriter(QtCore.QObject, metaclass=QABCMeta):
|
|
|
90
104
|
self.nskip = nskip
|
|
91
105
|
self.target = nframes
|
|
92
106
|
self.blank = False
|
|
107
|
+
self.received: FrameInfo | None = None
|
|
93
108
|
|
|
94
109
|
@abstractmethod
|
|
95
110
|
def open(self, frame: Image) -> bool:
|
|
@@ -135,6 +150,7 @@ class QVideoWriter(QtCore.QObject, metaclass=QABCMeta):
|
|
|
135
150
|
'''
|
|
136
151
|
if info is None:
|
|
137
152
|
info = FrameInfo(self.framenumber, perf_counter())
|
|
153
|
+
self.received = info
|
|
138
154
|
if not self.isOpen() and not self.open(frame):
|
|
139
155
|
logger.warning(f'Could not write to {self.filename}')
|
|
140
156
|
self.finished.emit()
|
|
@@ -155,3 +171,14 @@ class QVideoWriter(QtCore.QObject, metaclass=QABCMeta):
|
|
|
155
171
|
@abstractmethod
|
|
156
172
|
def close(self) -> None:
|
|
157
173
|
pass
|
|
174
|
+
|
|
175
|
+
@QtCore.Slot()
|
|
176
|
+
def shutdown(self) -> None:
|
|
177
|
+
'''Close the file and end the thread this writer lives in.
|
|
178
|
+
|
|
179
|
+
Invoke it through a signal, so that it is queued behind the frames
|
|
180
|
+
already waiting and none of them is lost. The writer must live
|
|
181
|
+
in a worker thread.
|
|
182
|
+
'''
|
|
183
|
+
self.close()
|
|
184
|
+
self.thread().quit()
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "QVideo"
|
|
7
|
-
version = "4.0
|
|
7
|
+
version = "4.2.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" }
|
|
@@ -34,6 +34,7 @@ dependencies = [
|
|
|
34
34
|
"opencv-python",
|
|
35
35
|
"qtpy",
|
|
36
36
|
"pyqtgraph",
|
|
37
|
+
"psutil",
|
|
37
38
|
]
|
|
38
39
|
|
|
39
40
|
[project.urls]
|
|
@@ -253,25 +253,13 @@ class TestTotalRAM(unittest.TestCase):
|
|
|
253
253
|
result = QCircularBuffer._totalRAM()
|
|
254
254
|
self.assertIsInstance(result, int)
|
|
255
255
|
|
|
256
|
-
def
|
|
256
|
+
def test_reads_total_from_psutil(self):
|
|
257
257
|
mock_psutil = MagicMock()
|
|
258
258
|
mock_psutil.virtual_memory.return_value.total = 16 * 1024 ** 3
|
|
259
|
-
with patch.
|
|
259
|
+
with patch.object(_module, 'psutil', mock_psutil):
|
|
260
260
|
result = QCircularBuffer._totalRAM()
|
|
261
261
|
self.assertEqual(result, 16 * 1024 ** 3)
|
|
262
262
|
|
|
263
|
-
def test_falls_back_to_sysconf(self):
|
|
264
|
-
with patch.dict('sys.modules', {'psutil': None}):
|
|
265
|
-
with patch.object(_module.os, 'sysconf', side_effect=[4096, 1024]):
|
|
266
|
-
result = QCircularBuffer._totalRAM()
|
|
267
|
-
self.assertEqual(result, 4096 * 1024)
|
|
268
|
-
|
|
269
|
-
def test_returns_zero_on_failure(self):
|
|
270
|
-
with patch.dict('sys.modules', {'psutil': None}):
|
|
271
|
-
with patch.object(_module.os, 'sysconf', side_effect=ValueError):
|
|
272
|
-
result = QCircularBuffer._totalRAM()
|
|
273
|
-
self.assertEqual(result, 0)
|
|
274
|
-
|
|
275
263
|
|
|
276
264
|
class TestMemoryWarning(unittest.TestCase):
|
|
277
265
|
|
|
@@ -317,17 +305,6 @@ class TestMemoryWarning(unittest.TestCase):
|
|
|
317
305
|
buf.duration = 2 # triggers _resize, resets _warned
|
|
318
306
|
self.assertFalse(buf._warned)
|
|
319
307
|
|
|
320
|
-
def test_no_warning_when_total_ram_unknown(self):
|
|
321
|
-
buf = QCircularBuffer(fps=10., duration=1)
|
|
322
|
-
with patch.object(buf, '_totalRAM', return_value=0):
|
|
323
|
-
try:
|
|
324
|
-
with self.assertLogs('QVideo.dvr.QCircularBuffer', level='WARNING'):
|
|
325
|
-
buf.append(self._big_frame())
|
|
326
|
-
warned = True
|
|
327
|
-
except AssertionError:
|
|
328
|
-
warned = False
|
|
329
|
-
self.assertFalse(warned)
|
|
330
|
-
|
|
331
308
|
|
|
332
309
|
if __name__ == '__main__':
|
|
333
310
|
unittest.main()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'''Unit tests for QDVRWidget.'''
|
|
2
2
|
import unittest
|
|
3
|
+
from types import SimpleNamespace
|
|
3
4
|
import numpy as np
|
|
4
5
|
from unittest.mock import patch, MagicMock
|
|
6
|
+
from QVideo.lib.videotypes import FrameInfo
|
|
5
7
|
from qtpy import QtCore, QtGui, QtWidgets, QtTest
|
|
6
8
|
from QVideo.dvr.QDVRWidget import QDVRWidget, _h5py_available
|
|
7
9
|
|
|
@@ -17,6 +19,8 @@ class MockSource(QtCore.QObject):
|
|
|
17
19
|
super().__init__()
|
|
18
20
|
self.fps = 30.
|
|
19
21
|
|
|
22
|
+
_FRAME = np.zeros((4, 4), dtype=np.uint8)
|
|
23
|
+
|
|
20
24
|
|
|
21
25
|
class MockWriter(QtCore.QObject):
|
|
22
26
|
'''Minimal writer with real Qt signals.'''
|
|
@@ -25,6 +29,8 @@ class MockWriter(QtCore.QObject):
|
|
|
25
29
|
|
|
26
30
|
def __init__(self, *args, **kwargs):
|
|
27
31
|
super().__init__()
|
|
32
|
+
self.received = None
|
|
33
|
+
self.shutdowns = 0
|
|
28
34
|
|
|
29
35
|
def write(self, frame):
|
|
30
36
|
pass
|
|
@@ -32,6 +38,9 @@ class MockWriter(QtCore.QObject):
|
|
|
32
38
|
def close(self):
|
|
33
39
|
pass
|
|
34
40
|
|
|
41
|
+
def shutdown(self):
|
|
42
|
+
self.shutdowns += 1
|
|
43
|
+
|
|
35
44
|
def moveToThread(self, thread):
|
|
36
45
|
pass
|
|
37
46
|
|
|
@@ -96,7 +105,8 @@ def setup_recording(widget, source):
|
|
|
96
105
|
source.newFrame.connect(writer.write)
|
|
97
106
|
writer.frameNumber.connect(widget.setFrameNumber)
|
|
98
107
|
writer.finished.connect(widget.stop)
|
|
99
|
-
|
|
108
|
+
source.newFrame.connect(widget._watch)
|
|
109
|
+
widget._shutdown.connect(writer.shutdown)
|
|
100
110
|
widget._writer = writer
|
|
101
111
|
widget._thread = thread
|
|
102
112
|
return writer, thread
|
|
@@ -234,6 +244,131 @@ class TestQDVRWidgetRecord(unittest.TestCase):
|
|
|
234
244
|
self.assertEqual(len(spy), 1)
|
|
235
245
|
self.assertTrue(spy[0][0])
|
|
236
246
|
|
|
247
|
+
def watching(self, **kwargs):
|
|
248
|
+
'''A recording whose writer has taken up the frame stamped t=10.'''
|
|
249
|
+
widget, source = make_widget_with_source()
|
|
250
|
+
for key, value in kwargs.items():
|
|
251
|
+
setattr(widget, key, value)
|
|
252
|
+
writer, _ = setup_recording(widget, source)
|
|
253
|
+
writer.received = FrameInfo(0, 10.)
|
|
254
|
+
return widget, writer
|
|
255
|
+
|
|
256
|
+
def capture(self, widget, t):
|
|
257
|
+
widget._watch(_FRAME, FrameInfo(1, t))
|
|
258
|
+
|
|
259
|
+
def test_defaults(self):
|
|
260
|
+
widget = make_widget()
|
|
261
|
+
self.assertTrue(widget.stopWhenBehind)
|
|
262
|
+
self.assertEqual(widget.lagLimit, 1.)
|
|
263
|
+
self.assertIsNone(widget.maxMemory)
|
|
264
|
+
|
|
265
|
+
def test_a_writer_keeping_up_is_left_alone(self):
|
|
266
|
+
widget, _ = self.watching()
|
|
267
|
+
self.capture(widget, 10.5)
|
|
268
|
+
self.assertTrue(widget.isRecording())
|
|
269
|
+
|
|
270
|
+
def test_falling_behind_stops_the_recording_by_default(self):
|
|
271
|
+
widget, _ = self.watching()
|
|
272
|
+
with self.assertLogs('QVideo.dvr.QDVRWidget', 'ERROR'):
|
|
273
|
+
self.capture(widget, 12.)
|
|
274
|
+
self.assertFalse(widget.isRecording())
|
|
275
|
+
|
|
276
|
+
def test_the_reason_is_reported(self):
|
|
277
|
+
widget, _ = self.watching()
|
|
278
|
+
reasons = []
|
|
279
|
+
widget.stopped.connect(reasons.append)
|
|
280
|
+
with self.assertLogs('QVideo.dvr.QDVRWidget', 'ERROR'):
|
|
281
|
+
self.capture(widget, 12.)
|
|
282
|
+
self.assertEqual(len(reasons), 1)
|
|
283
|
+
self.assertIn('2.0 s behind', reasons[0])
|
|
284
|
+
|
|
285
|
+
def test_behind_is_emitted_before_the_recording_stops(self):
|
|
286
|
+
widget, _ = self.watching()
|
|
287
|
+
states = []
|
|
288
|
+
widget.behind.connect(lambda lag: states.append(widget.isRecording()))
|
|
289
|
+
with self.assertLogs('QVideo.dvr.QDVRWidget', 'ERROR'):
|
|
290
|
+
self.capture(widget, 12.)
|
|
291
|
+
self.assertEqual(states, [True])
|
|
292
|
+
|
|
293
|
+
def test_recording_continues_when_stopping_is_disabled(self):
|
|
294
|
+
widget, _ = self.watching(stopWhenBehind=False)
|
|
295
|
+
stops = []
|
|
296
|
+
widget.stopped.connect(stops.append)
|
|
297
|
+
self.capture(widget, 12.)
|
|
298
|
+
self.assertTrue(widget.isRecording())
|
|
299
|
+
self.assertEqual(stops, [])
|
|
300
|
+
|
|
301
|
+
def test_staying_behind_is_reported_once(self):
|
|
302
|
+
widget, _ = self.watching(stopWhenBehind=False)
|
|
303
|
+
lags = []
|
|
304
|
+
widget.behind.connect(lags.append)
|
|
305
|
+
for t in (12., 12.1, 12.2):
|
|
306
|
+
self.capture(widget, t)
|
|
307
|
+
self.assertEqual(lags, [2.])
|
|
308
|
+
|
|
309
|
+
def test_catching_up_rearms_the_report(self):
|
|
310
|
+
widget, writer = self.watching(stopWhenBehind=False)
|
|
311
|
+
lags = []
|
|
312
|
+
widget.behind.connect(lags.append)
|
|
313
|
+
self.capture(widget, 12.)
|
|
314
|
+
writer.received = FrameInfo(1, 12.)
|
|
315
|
+
self.capture(widget, 12.1)
|
|
316
|
+
self.capture(widget, 14.)
|
|
317
|
+
self.assertEqual(len(lags), 2)
|
|
318
|
+
|
|
319
|
+
def test_the_limit_can_be_changed(self):
|
|
320
|
+
widget, _ = self.watching(lagLimit=5.)
|
|
321
|
+
self.capture(widget, 12.)
|
|
322
|
+
self.assertTrue(widget.isRecording())
|
|
323
|
+
|
|
324
|
+
def test_a_small_memory_budget_stops_the_recording(self):
|
|
325
|
+
# 0.5 s of a 30 Hz source of 16-byte frames
|
|
326
|
+
widget, _ = self.watching(_budget=0.5 * 30 * _FRAME.nbytes)
|
|
327
|
+
with self.assertLogs('QVideo.dvr.QDVRWidget', 'ERROR'):
|
|
328
|
+
self.capture(widget, 10.6)
|
|
329
|
+
self.assertFalse(widget.isRecording())
|
|
330
|
+
|
|
331
|
+
def test_a_large_memory_budget_leaves_the_time_limit_in_charge(self):
|
|
332
|
+
widget, _ = self.watching(_budget=1e12)
|
|
333
|
+
self.capture(widget, 10.9)
|
|
334
|
+
self.assertTrue(widget.isRecording())
|
|
335
|
+
with self.assertLogs('QVideo.dvr.QDVRWidget', 'ERROR'):
|
|
336
|
+
self.capture(widget, 12.)
|
|
337
|
+
self.assertFalse(widget.isRecording())
|
|
338
|
+
|
|
339
|
+
def test_the_budget_defaults_to_most_of_the_available_memory(self):
|
|
340
|
+
widget, source = make_widget_with_source()
|
|
341
|
+
free = SimpleNamespace(available=1000)
|
|
342
|
+
with patch.dict(QDVRWidget.Writer, {'.avi': MockWriter}), \
|
|
343
|
+
patch.object(QtCore, 'QThread', return_value=MockThread()), \
|
|
344
|
+
patch('psutil.virtual_memory', return_value=free):
|
|
345
|
+
widget.record()
|
|
346
|
+
self.assertEqual(widget._budget, 800)
|
|
347
|
+
|
|
348
|
+
def test_max_memory_overrides_the_default_budget(self):
|
|
349
|
+
widget, source = make_widget_with_source()
|
|
350
|
+
widget.maxMemory = 123
|
|
351
|
+
with patch.dict(QDVRWidget.Writer, {'.avi': MockWriter}), \
|
|
352
|
+
patch.object(QtCore, 'QThread', return_value=MockThread()):
|
|
353
|
+
widget.record()
|
|
354
|
+
self.assertEqual(widget._budget, 123)
|
|
355
|
+
|
|
356
|
+
def test_a_writer_that_has_seen_nothing_is_not_late(self):
|
|
357
|
+
widget, writer = self.watching()
|
|
358
|
+
writer.received = None
|
|
359
|
+
self.capture(widget, 99.)
|
|
360
|
+
self.assertTrue(widget.isRecording())
|
|
361
|
+
|
|
362
|
+
def test_a_frame_without_info_is_ignored(self):
|
|
363
|
+
widget, _ = self.watching()
|
|
364
|
+
widget._watch(_FRAME)
|
|
365
|
+
self.assertTrue(widget.isRecording())
|
|
366
|
+
|
|
367
|
+
def test_a_late_event_after_stopping_is_harmless(self):
|
|
368
|
+
widget, _ = self.watching()
|
|
369
|
+
widget.stop()
|
|
370
|
+
self.capture(widget, 99.) # queued before stop, delivered after
|
|
371
|
+
|
|
237
372
|
def test_record_when_recording_calls_stop(self):
|
|
238
373
|
widget, source = make_widget_with_source()
|
|
239
374
|
setup_recording(widget, source)
|
|
@@ -357,12 +492,11 @@ class TestQDVRWidgetStop(unittest.TestCase):
|
|
|
357
492
|
widget.stop()
|
|
358
493
|
self.assertIsNone(widget._writer)
|
|
359
494
|
|
|
360
|
-
def
|
|
495
|
+
def test_stop_shuts_the_writer_down_once(self):
|
|
361
496
|
widget, source = make_widget_with_source()
|
|
362
497
|
writer, _ = setup_recording(widget, source)
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
mock_close.assert_called_once()
|
|
498
|
+
widget.stop()
|
|
499
|
+
self.assertEqual(writer.shutdowns, 1)
|
|
366
500
|
|
|
367
501
|
def test_stop_is_safe_when_signals_already_disconnected(self):
|
|
368
502
|
widget, source = make_widget_with_source()
|
|
@@ -5,6 +5,7 @@ import sys
|
|
|
5
5
|
import threading
|
|
6
6
|
import time
|
|
7
7
|
import unittest
|
|
8
|
+
from unittest.mock import patch
|
|
8
9
|
import numpy as np
|
|
9
10
|
from qtpy import QtCore, QtTest, QtWidgets
|
|
10
11
|
from QVideo.lib.QFilterStack import QFilterStack
|
|
@@ -406,6 +407,13 @@ print('survived')
|
|
|
406
407
|
|
|
407
408
|
class TestLifecycle(StackTestCase):
|
|
408
409
|
|
|
410
|
+
def test_finalizer_ignores_a_deleted_thread(self):
|
|
411
|
+
stack = self.make()
|
|
412
|
+
with patch.object(QFilterStack, 'isRunning',
|
|
413
|
+
side_effect=RuntimeError):
|
|
414
|
+
stack.__del__()
|
|
415
|
+
self.assertTrue(stack.isRunning())
|
|
416
|
+
|
|
409
417
|
def test_thread_is_running_after_creation(self):
|
|
410
418
|
self.make()
|
|
411
419
|
self.assertTrue(self.stack.isRunning())
|
|
@@ -367,6 +367,18 @@ print('survived')
|
|
|
367
367
|
self.assertIn('survived', result.stdout)
|
|
368
368
|
self.assertNotIn('Destroyed while thread', result.stderr)
|
|
369
369
|
|
|
370
|
+
def test_finalizer_leaves_an_unstarted_source_alone(self):
|
|
371
|
+
vs = make_vs()
|
|
372
|
+
with patch.object(vs, 'stop') as stop:
|
|
373
|
+
vs.__del__()
|
|
374
|
+
stop.assert_not_called()
|
|
375
|
+
|
|
376
|
+
def test_finalizer_ignores_a_deleted_thread(self):
|
|
377
|
+
vs = make_vs()
|
|
378
|
+
with patch.object(QVideoSource, 'isRunning',
|
|
379
|
+
side_effect=RuntimeError):
|
|
380
|
+
vs.__del__()
|
|
381
|
+
|
|
370
382
|
|
|
371
383
|
if __name__ == '__main__':
|
|
372
384
|
unittest.main()
|