QVideo 4.5.0__tar.gz → 4.6.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.5.0 → qvideo-4.6.0}/PKG-INFO +1 -1
- {qvideo-4.5.0 → qvideo-4.6.0}/QCamcorder.py +40 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/QVideo.egg-info/PKG-INFO +1 -1
- {qvideo-4.5.0 → qvideo-4.6.0}/QVideo.egg-info/SOURCES.txt +1 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/combineddemo.py +1 -2
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/demo.py +4 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/filterdemo.py +0 -6
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/filterrackdemo.py +8 -14
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QDVRWidget.py +24 -8
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QCameraTree.py +13 -1
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QFilterRack.py +5 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/_launch.py +16 -6
- {qvideo-4.5.0 → qvideo-4.6.0}/pyproject.toml +1 -1
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_filterdemo.py +6 -4
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_launch.py +57 -21
- qvideo-4.6.0/tests/test_mainwindow.py +149 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qcamcorder.py +47 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qdvrwidget.py +57 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qfilterrack.py +23 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/LICENSE.md +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/QVideo.egg-info/dependency_links.txt +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/QVideo.egg-info/requires.txt +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/QVideo.egg-info/top_level.txt +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/README.md +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/__main__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Basler/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Basler/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Basler/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Flir/QListFlirCameras.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Flir/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Flir/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Flir/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Genicam/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Genicam/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Genicam/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/IDS/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/IDS/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/IDS/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/MV/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/MV/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/MV/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Noise/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Noise/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Noise/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/OpenCV/QListCVCameras.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/OpenCV/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/OpenCV/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/OpenCV/_devices.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/OpenCV/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Picamera/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Picamera/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Picamera/_imx500.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Picamera/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Vimbax/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Vimbax/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/Vimbax/_tree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/cameras/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/ROIdemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/circulardemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/compositedemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/histogramdemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/trackpydemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/uniformitydemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/demos/yolodemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QCircularBuffer.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QCircularDVRWidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QHDF5Reader.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QHDF5Writer.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QOpenCVReader.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/QOpenCVWriter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/dvr/icons_rc.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/_MedianBase.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/artistic.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/blob.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/circletransform.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/darkframe.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/dejitter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/dog.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/edge.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/exposure.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/flatfield.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/foreground.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/gamma.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/invert.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/laplacian.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/median.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/momean.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/momedian.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/normalize.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/rgb.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/roi.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/samplehold.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/smoothing.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/sobel.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/threshold.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/filters/unsharp.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QCamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QFilterPipeline.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QFilterRackWidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QFrameRelay.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QHistogramWidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QListCameras.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QSnapshot.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QUniformityWidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QVideoFilter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QVideoReader.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QVideoScreen.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QVideoSource.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/QVideoWriter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/_jupyter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/_qabc.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/chooser.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/clickable.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/errors.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/gentl.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/imageops.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/lib/videotypes.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/overlays/__init__.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/overlays/trackpy.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/overlays/yolo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/setup.cfg +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_artistic.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_blob.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_camera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_chooser.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_circletransform.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_circularbuffer.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_circulardemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_circulardvrwidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_clickable.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_combineddemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_compositedemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_darkframe.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_dejitter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_demo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_docs_quickstart.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_dog.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_edge.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_exposure.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_filter_export.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_filterrackdemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_filters_gray.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_flatfield.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_foreground.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_gamma.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_gentl.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_histogramdemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_histogramwidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_icons_rc.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_imageops.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_invert.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_jupyter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_laplacian.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_median.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_momean.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_momedian.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_normalize.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_overlays_package.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qabc.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qbaslercamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qcamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qcameratree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qfilterpipeline.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qfilterrackwidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qflircamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qframerelay.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qgenicamcamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qgenicamtree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qhdf5reader.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qhdf5writer.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qidscamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qimxcamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qlistcameras.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qlistcvcameras.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qlistflircameras.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qmvcamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qnoisecamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qnoisetree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qopencvcamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qopencvdevices.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qopencvreader.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qopencvtree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qopencvwriter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qpicamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qpicameratree.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qsnapshot.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qt_binding.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qvideoreader.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qvideoscreen.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qvideosource.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qvideowriter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_qvimbaxcamera.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_resolutions.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_rgb.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_roi.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_roidemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_samplehold.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_smoothing.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_sobel.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_threshold.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_trackpy_overlay.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_trackpydemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_uniformitydemo.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_uniformitywidget.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_unsharp.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_vendor_trees.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_videofilter.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_videotypes.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_yolo_overlay.py +0 -0
- {qvideo-4.5.0 → qvideo-4.6.0}/tests/test_yolodemo.py +0 -0
|
@@ -31,6 +31,13 @@ from QVideo.dvr import QDVRWidget
|
|
|
31
31
|
|
|
32
32
|
__all__ = ['QCamcorder']
|
|
33
33
|
|
|
34
|
+
#: Compact layout of the screen and the controls [pixels].
|
|
35
|
+
_MARGINS = (4, 4, 4, 4)
|
|
36
|
+
_SPACING = 3
|
|
37
|
+
|
|
38
|
+
#: Backlog, as a fraction of the allowance, from which it is shown.
|
|
39
|
+
_SHOW_BACKLOG = 0.25
|
|
40
|
+
|
|
34
41
|
|
|
35
42
|
class QCamcorder(QtWidgets.QWidget):
|
|
36
43
|
'''A widget combining a video screen, camera controls, and DVR.
|
|
@@ -42,6 +49,11 @@ class QCamcorder(QtWidgets.QWidget):
|
|
|
42
49
|
starts playback the screen is switched to the playback stream and the
|
|
43
50
|
camera controls are disabled until playback ends.
|
|
44
51
|
|
|
52
|
+
The widget emits :attr:`message` to warn when a recording starts to fall
|
|
53
|
+
behind the camera and to say why when the DVR stops one. The host
|
|
54
|
+
decides where to show it, for instance in the status bar of its main
|
|
55
|
+
window, as :func:`~QVideo.lib.launch` does.
|
|
56
|
+
|
|
45
57
|
A :class:`~QVideo.lib.QSnapshot.QSnapshot` is wired to the screen's
|
|
46
58
|
``newFrame`` signal, enabling still-frame capture via two hotkeys:
|
|
47
59
|
|
|
@@ -58,8 +70,16 @@ class QCamcorder(QtWidgets.QWidget):
|
|
|
58
70
|
**kwargs :
|
|
59
71
|
Additional keyword arguments forwarded to
|
|
60
72
|
:class:`~pyqtgraph.Qt.QtWidgets.QWidget`.
|
|
73
|
+
|
|
74
|
+
Signals
|
|
75
|
+
-------
|
|
76
|
+
message(str)
|
|
77
|
+
Text for the user, or an empty string to clear it.
|
|
61
78
|
'''
|
|
62
79
|
|
|
80
|
+
#: Emitted with text for the user, or ``''`` to clear it.
|
|
81
|
+
message = QtCore.Signal(str)
|
|
82
|
+
|
|
63
83
|
def __init__(self,
|
|
64
84
|
cameraWidget: QCameraTree,
|
|
65
85
|
*args, **kwargs) -> None:
|
|
@@ -77,10 +97,14 @@ class QCamcorder(QtWidgets.QWidget):
|
|
|
77
97
|
|
|
78
98
|
self.controls = QtWidgets.QWidget(self)
|
|
79
99
|
controlsLayout = QtWidgets.QVBoxLayout(self.controls)
|
|
100
|
+
controlsLayout.setContentsMargins(*_MARGINS)
|
|
101
|
+
controlsLayout.setSpacing(_SPACING)
|
|
80
102
|
controlsLayout.addWidget(self.dvr)
|
|
81
103
|
controlsLayout.addWidget(self.cameraWidget)
|
|
82
104
|
|
|
83
105
|
layout = QtWidgets.QHBoxLayout(self)
|
|
106
|
+
layout.setContentsMargins(*_MARGINS)
|
|
107
|
+
layout.setSpacing(_SPACING)
|
|
84
108
|
layout.addWidget(self.screen)
|
|
85
109
|
layout.addWidget(self.controls)
|
|
86
110
|
layout.setStretch(0, 1)
|
|
@@ -88,6 +112,11 @@ class QCamcorder(QtWidgets.QWidget):
|
|
|
88
112
|
|
|
89
113
|
def _connectSignals(self) -> None:
|
|
90
114
|
self.dvr.playing.connect(self.dvrPlayback)
|
|
115
|
+
self.dvr.recording.connect(self._clearMessage)
|
|
116
|
+
self.dvr.backlog.connect(self._showBacklog)
|
|
117
|
+
# Queued, so that the reason follows the end of the recording,
|
|
118
|
+
# which clears the message.
|
|
119
|
+
self.dvr.stopped.connect(self.message, QtCore.Qt.QueuedConnection)
|
|
91
120
|
self.screen.newFrame.connect(self._snapshot.newFrame)
|
|
92
121
|
|
|
93
122
|
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
|
|
@@ -120,6 +149,17 @@ class QCamcorder(QtWidgets.QWidget):
|
|
|
120
149
|
self.screen.source = self.dvr.player if playback else self.source
|
|
121
150
|
self.cameraWidget.setDisabled(playback)
|
|
122
151
|
|
|
152
|
+
@QtCore.Slot(bool)
|
|
153
|
+
def _clearMessage(self, recording: bool) -> None:
|
|
154
|
+
'''Clear the message when a recording starts or ends.'''
|
|
155
|
+
self.message.emit('')
|
|
156
|
+
|
|
157
|
+
@QtCore.Slot(float)
|
|
158
|
+
def _showBacklog(self, fraction: float) -> None:
|
|
159
|
+
'''Warn while the writer falls behind the camera.'''
|
|
160
|
+
self.message.emit(f'Writer backlog: {fraction:.0%} of the limit'
|
|
161
|
+
if fraction >= _SHOW_BACKLOG else '')
|
|
162
|
+
|
|
123
163
|
@property
|
|
124
164
|
def source(self) -> QVideoSource:
|
|
125
165
|
'''The :class:`~QVideo.lib.QVideoSource.QVideoSource` from the
|
|
@@ -80,6 +80,7 @@ class CombinedDemo(FilterRackDemo):
|
|
|
80
80
|
self._modeComposite = QtWidgets.QRadioButton('Composite')
|
|
81
81
|
self._modeBox.layout().addWidget(self._modeComposite)
|
|
82
82
|
self._modeGroup.addButton(self._modeComposite)
|
|
83
|
+
self._sources[self._modeComposite] = self.screen
|
|
83
84
|
|
|
84
85
|
def _onModeToggled(self,
|
|
85
86
|
button: QtWidgets.QAbstractButton,
|
|
@@ -89,8 +90,6 @@ class CombinedDemo(FilterRackDemo):
|
|
|
89
90
|
if checked:
|
|
90
91
|
self.screen.composite = button is self._modeComposite
|
|
91
92
|
super()._onModeToggled(button, checked)
|
|
92
|
-
if checked and button is self._modeComposite:
|
|
93
|
-
self.dvr.source = self.screen
|
|
94
93
|
|
|
95
94
|
|
|
96
95
|
if __name__ == '__main__': # pragma: no cover
|
|
@@ -39,8 +39,12 @@ class Demo(QtWidgets.QWidget):
|
|
|
39
39
|
|
|
40
40
|
def _setupUi(self) -> None:
|
|
41
41
|
layout = QtWidgets.QHBoxLayout(self)
|
|
42
|
+
layout.setContentsMargins(4, 4, 4, 4)
|
|
43
|
+
layout.setSpacing(3)
|
|
42
44
|
layout.addWidget(self.screen)
|
|
43
45
|
self._controls = QtWidgets.QVBoxLayout()
|
|
46
|
+
self._controls.setContentsMargins(0, 0, 0, 0)
|
|
47
|
+
self._controls.setSpacing(3)
|
|
44
48
|
layout.addLayout(self._controls)
|
|
45
49
|
layout.setStretch(0, 1) # screen fills horizontal space
|
|
46
50
|
layout.setStretch(1, 0) # controls retain natural width
|
|
@@ -6,7 +6,6 @@ Run directly::
|
|
|
6
6
|
python -m QVideo.demos.filterdemo
|
|
7
7
|
'''
|
|
8
8
|
|
|
9
|
-
from qtpy import QtGui
|
|
10
9
|
from QVideo.demos.demo import Demo
|
|
11
10
|
from QVideo.lib import QCameraTree, QFilterRack, launch
|
|
12
11
|
|
|
@@ -49,11 +48,6 @@ class FilterDemo(Demo):
|
|
|
49
48
|
for name in filters:
|
|
50
49
|
self.rack.addByName(name)
|
|
51
50
|
|
|
52
|
-
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
|
|
53
|
-
'''Stop the filter pipeline before the widget closes.'''
|
|
54
|
-
self.rack.pipeline.stop()
|
|
55
|
-
super().closeEvent(event)
|
|
56
|
-
|
|
57
51
|
|
|
58
52
|
if __name__ == '__main__': # pragma: no cover
|
|
59
53
|
launch(FilterDemo, 'Filter Demo',
|
|
@@ -29,7 +29,7 @@ filters and feeds both the display and the recorder, so stateful filters
|
|
|
29
29
|
see each frame exactly once.
|
|
30
30
|
'''
|
|
31
31
|
|
|
32
|
-
from qtpy import QtCore,
|
|
32
|
+
from qtpy import QtCore, QtWidgets
|
|
33
33
|
from QVideo.QCamcorder import QCamcorder
|
|
34
34
|
from QVideo.lib import QCameraTree, QFilterRack, launch
|
|
35
35
|
from QVideo.filters import QSmoothingFilter, QThresholdFilter
|
|
@@ -77,7 +77,9 @@ class FilterRackDemo(QCamcorder):
|
|
|
77
77
|
|
|
78
78
|
def _setupModeUi(self) -> None:
|
|
79
79
|
self._modeBox = QtWidgets.QGroupBox('Record from')
|
|
80
|
+
self._modeBox.setFlat(True)
|
|
80
81
|
layout = QtWidgets.QHBoxLayout(self._modeBox)
|
|
82
|
+
layout.setContentsMargins(4, 0, 4, 0)
|
|
81
83
|
self._modeRaw = QtWidgets.QRadioButton('Raw')
|
|
82
84
|
self._modeFiltered = QtWidgets.QRadioButton('Filtered')
|
|
83
85
|
self._modeDisplay = QtWidgets.QRadioButton('Display')
|
|
@@ -88,6 +90,9 @@ class FilterRackDemo(QCamcorder):
|
|
|
88
90
|
self._modeGroup.addButton(self._modeRaw)
|
|
89
91
|
self._modeGroup.addButton(self._modeFiltered)
|
|
90
92
|
self._modeGroup.addButton(self._modeDisplay)
|
|
93
|
+
self._sources = {self._modeRaw: self.source,
|
|
94
|
+
self._modeFiltered: self.rack.pipeline,
|
|
95
|
+
self._modeDisplay: self.screen}
|
|
91
96
|
|
|
92
97
|
def _connectModeSignals(self) -> None:
|
|
93
98
|
self._modeGroup.buttonToggled.connect(self._onModeToggled)
|
|
@@ -108,11 +113,6 @@ class FilterRackDemo(QCamcorder):
|
|
|
108
113
|
self.rack.source = self.dvr.player if playback else self.source
|
|
109
114
|
self.cameraWidget.setDisabled(playback)
|
|
110
115
|
|
|
111
|
-
def closeEvent(self, event: QtGui.QCloseEvent) -> None:
|
|
112
|
-
'''Stop the filter pipeline, then the camera source.'''
|
|
113
|
-
self.rack.pipeline.stop()
|
|
114
|
-
super().closeEvent(event)
|
|
115
|
-
|
|
116
116
|
@QtCore.Slot(QtWidgets.QAbstractButton, bool)
|
|
117
117
|
def _onModeToggled(self,
|
|
118
118
|
button: QtWidgets.QAbstractButton,
|
|
@@ -126,14 +126,8 @@ class FilterRackDemo(QCamcorder):
|
|
|
126
126
|
checked : bool
|
|
127
127
|
``True`` when the button is selected; ``False`` on deselection.
|
|
128
128
|
'''
|
|
129
|
-
if
|
|
130
|
-
|
|
131
|
-
if button is self._modeRaw:
|
|
132
|
-
self.dvr.source = self.source
|
|
133
|
-
elif button is self._modeFiltered:
|
|
134
|
-
self.dvr.source = self.rack.pipeline
|
|
135
|
-
elif button is self._modeDisplay:
|
|
136
|
-
self.dvr.source = self.screen
|
|
129
|
+
if checked:
|
|
130
|
+
self.dvr.source = self._sources[button]
|
|
137
131
|
|
|
138
132
|
|
|
139
133
|
if __name__ == '__main__': # pragma: no cover
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'''Composite DVR widget for recording and playing back video streams.'''
|
|
2
2
|
from collections.abc import Callable
|
|
3
|
+
import math
|
|
3
4
|
from qtpy import QtCore, QtGui, QtWidgets
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
import numpy as np
|
|
@@ -22,6 +23,9 @@ import logging
|
|
|
22
23
|
|
|
23
24
|
__all__ = ['QDVRWidget']
|
|
24
25
|
|
|
26
|
+
#: Steps in which the backlog is reported.
|
|
27
|
+
_BACKLOG_STEPS = 20
|
|
28
|
+
|
|
25
29
|
|
|
26
30
|
logger = logging.getLogger(__name__)
|
|
27
31
|
|
|
@@ -83,6 +87,10 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
83
87
|
Emitted when recording starts (``True``) or stops (``False``).
|
|
84
88
|
playing(bool)
|
|
85
89
|
Emitted when playback starts (``True``) or stops (``False``).
|
|
90
|
+
backlog(float)
|
|
91
|
+
Emitted while recording whenever the backlog changes by 5% of what
|
|
92
|
+
is allowed, with the backlog as a fraction of the allowance:
|
|
93
|
+
``1.`` is the point at which ``behind`` is emitted.
|
|
86
94
|
behind(float)
|
|
87
95
|
Emitted once each time the recording falls behind the camera by
|
|
88
96
|
more than *lagLimit* seconds or *maxMemory* bytes, with the lag
|
|
@@ -105,6 +113,8 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
105
113
|
recording = QtCore.Signal(bool)
|
|
106
114
|
#: Emitted when playback starts (``True``) or stops (``False``).
|
|
107
115
|
playing = QtCore.Signal(bool)
|
|
116
|
+
#: Emitted as the backlog changes, as a fraction of what is allowed.
|
|
117
|
+
backlog = QtCore.Signal(float)
|
|
108
118
|
#: Emitted when the recording falls behind the camera, with the lag [s].
|
|
109
119
|
behind = QtCore.Signal(float)
|
|
110
120
|
#: Emitted with the reason when the widget stops a recording itself.
|
|
@@ -178,7 +188,7 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
178
188
|
self._writer: object | None = None
|
|
179
189
|
self._player: QVideoSource | None = None
|
|
180
190
|
self._thread: QtCore.QThread | None = None
|
|
181
|
-
self.
|
|
191
|
+
self._level = 0
|
|
182
192
|
self._setupUi()
|
|
183
193
|
self._connectSignals()
|
|
184
194
|
self.source = source
|
|
@@ -371,7 +381,7 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
371
381
|
fps=self.source.fps,
|
|
372
382
|
nframes=self.nframes.value(),
|
|
373
383
|
nskip=self.nskip.value())
|
|
374
|
-
self.
|
|
384
|
+
self._level = 0
|
|
375
385
|
self._budget = (self.maxMemory
|
|
376
386
|
or 0.8 * psutil.virtual_memory().available)
|
|
377
387
|
self._writer.frameNumber.connect(self.setFrameNumber)
|
|
@@ -469,28 +479,34 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
469
479
|
@QtCore.Slot(np.ndarray, object)
|
|
470
480
|
def _watch(self, frame: Image, info: FrameInfo | None = None) -> None:
|
|
471
481
|
'''Compare each captured frame with the newest one the writer has
|
|
472
|
-
taken up, and report once each time the writer
|
|
482
|
+
taken up, report the backlog, and report once each time the writer
|
|
483
|
+
falls behind.
|
|
473
484
|
|
|
474
485
|
The comparison uses the capture times, so it measures the backlog
|
|
475
486
|
even while the writer is stuck inside a single write, and it
|
|
476
487
|
ignores sources that capture slowly. The memory budget is
|
|
477
488
|
converted to the time it takes the camera to fill it, so one
|
|
478
|
-
limit serves both.
|
|
489
|
+
limit serves both. The backlog is reported in steps, not for
|
|
490
|
+
every frame.
|
|
479
491
|
'''
|
|
480
492
|
taken = self._writer and self._writer.received
|
|
481
493
|
if info is None or not taken:
|
|
482
494
|
return
|
|
483
|
-
lag = info.timestamp - taken.timestamp
|
|
495
|
+
lag = max(info.timestamp - taken.timestamp, 0.)
|
|
484
496
|
fill = self._budget / (self.source.fps * frame.nbytes)
|
|
485
|
-
|
|
486
|
-
|
|
497
|
+
fraction = lag / min(self.lagLimit, fill)
|
|
498
|
+
level = math.ceil(fraction * _BACKLOG_STEPS)
|
|
499
|
+
if level == self._level:
|
|
500
|
+
return
|
|
501
|
+
was, self._level = self._level, level
|
|
502
|
+
self.backlog.emit(fraction)
|
|
503
|
+
if level > _BACKLOG_STEPS >= was:
|
|
487
504
|
self.behind.emit(lag)
|
|
488
505
|
if self.stopWhenBehind:
|
|
489
506
|
reason = f'recording fell {lag:.1f} s behind the camera'
|
|
490
507
|
logger.error(reason)
|
|
491
508
|
self.stopped.emit(reason)
|
|
492
509
|
self.stop()
|
|
493
|
-
self._late = late
|
|
494
510
|
|
|
495
511
|
@QtCore.Slot(int)
|
|
496
512
|
def setFrameNumber(self, framenumber: int) -> None:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'''Auto-building pyqtgraph parameter tree for QCamera property inspection.'''
|
|
2
|
-
from qtpy import QtCore, QtGui
|
|
2
|
+
from qtpy import QtCore, QtGui, QtWidgets
|
|
3
3
|
from pyqtgraph.parametertree import Parameter, ParameterTree
|
|
4
4
|
from QVideo.lib import QCamera, QVideoSource
|
|
5
5
|
import math
|
|
@@ -8,6 +8,9 @@ import logging
|
|
|
8
8
|
|
|
9
9
|
__all__ = ['QCameraTree']
|
|
10
10
|
|
|
11
|
+
#: Height [pixels] that the tree asks for and is squeezed to at most.
|
|
12
|
+
_MIN_HEIGHT = 120
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
logger = logging.getLogger(__name__)
|
|
13
16
|
logger.setLevel(logging.WARNING)
|
|
@@ -132,6 +135,15 @@ class QCameraTree(ParameterTree):
|
|
|
132
135
|
header.setSectionResizeMode(count - 1, header.ResizeMode.Stretch)
|
|
133
136
|
self.adjustSize()
|
|
134
137
|
self.setMinimumWidth(self.width())
|
|
138
|
+
# The tree scrolls, so it asks for a few rows and takes the height
|
|
139
|
+
# that its neighbors leave.
|
|
140
|
+
self.setSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred,
|
|
141
|
+
QtWidgets.QSizePolicy.Policy.Expanding)
|
|
142
|
+
self.setMinimumHeight(_MIN_HEIGHT)
|
|
143
|
+
|
|
144
|
+
def sizeHint(self) -> QtCore.QSize:
|
|
145
|
+
'''Ask for a few rows of height: the tree scrolls.'''
|
|
146
|
+
return QtCore.QSize(super().sizeHint().width(), _MIN_HEIGHT)
|
|
135
147
|
|
|
136
148
|
@staticmethod
|
|
137
149
|
def _updateStep(param: Parameter) -> None:
|
|
@@ -22,6 +22,10 @@ class QFilterRack(QFilterRackWidget):
|
|
|
22
22
|
rack = QFilterRack(source=camera)
|
|
23
23
|
screen.source = rack.pipeline
|
|
24
24
|
|
|
25
|
+
The pipeline stops when the application quits and when the rack is
|
|
26
|
+
deleted, so a rack needs no explicit shutdown. Closing a window only
|
|
27
|
+
hides the rack: call ``rack.pipeline.stop()`` to stop it sooner.
|
|
28
|
+
|
|
25
29
|
Use :class:`~QVideo.lib.QFilterRackWidget.QFilterRackWidget` to
|
|
26
30
|
apply the filters to recorded frames, or to design a pipeline,
|
|
27
31
|
without a thread.
|
|
@@ -48,6 +52,7 @@ class QFilterRack(QFilterRackWidget):
|
|
|
48
52
|
depth: int = 1) -> None:
|
|
49
53
|
super().__init__(parent, editable)
|
|
50
54
|
self.pipeline = QFilterPipeline(source, rack=self, depth=depth)
|
|
55
|
+
self.destroyed.connect(self.pipeline.stop)
|
|
51
56
|
|
|
52
57
|
@property
|
|
53
58
|
def source(self):
|
|
@@ -15,17 +15,22 @@ def launch(widget: type[QtWidgets.QWidget],
|
|
|
15
15
|
|
|
16
16
|
The camera backend comes from the command-line flags described in
|
|
17
17
|
:func:`~QVideo.lib.chooser.choose_camera` (a noise camera if there are
|
|
18
|
-
none). The
|
|
19
|
-
|
|
18
|
+
none). The widget becomes the central widget of a
|
|
19
|
+
:class:`~qtpy.QtWidgets.QMainWindow`, which is how applications embed
|
|
20
|
+
QVideo components, so that sizing and shutdown are exercised in that
|
|
21
|
+
setting. The window has a status bar that shows the messages of a
|
|
22
|
+
widget with a ``message(str)`` signal, and it closes on Ctrl+Q. A
|
|
23
|
+
widget that needs an optional package that is not installed ends the
|
|
24
|
+
program with the error message.
|
|
20
25
|
|
|
21
26
|
Parameters
|
|
22
27
|
----------
|
|
23
28
|
widget : type
|
|
24
|
-
Class of the
|
|
25
|
-
|
|
29
|
+
Class of the central widget. It is called with the camera tree as
|
|
30
|
+
its first argument, as :class:`~QVideo.demos.demo.Demo` and
|
|
26
31
|
:class:`~QVideo.QCamcorder.QCamcorder` expect.
|
|
27
32
|
title : str, optional
|
|
28
|
-
Name of the application.
|
|
33
|
+
Name of the application and title of the window.
|
|
29
34
|
**kwargs :
|
|
30
35
|
Further keyword arguments for *widget*.
|
|
31
36
|
|
|
@@ -41,9 +46,14 @@ def launch(widget: type[QtWidgets.QWidget],
|
|
|
41
46
|
app = pg.mkQApp(title)
|
|
42
47
|
tree = choose_camera().start()
|
|
43
48
|
try:
|
|
44
|
-
|
|
49
|
+
central = widget(tree, **kwargs)
|
|
45
50
|
except ImportError as error:
|
|
46
51
|
sys.exit(f'Error: {error}')
|
|
52
|
+
window = QtWidgets.QMainWindow()
|
|
53
|
+
window.setCentralWidget(central)
|
|
54
|
+
window.setWindowTitle(title or '')
|
|
55
|
+
if hasattr(central, 'message'):
|
|
56
|
+
central.message.connect(window.statusBar().showMessage)
|
|
47
57
|
QtWidgets.QShortcut(
|
|
48
58
|
QtGui.QKeySequence('Ctrl+Q'), window).activated.connect(app.quit)
|
|
49
59
|
window.show()
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "QVideo"
|
|
7
|
-
version = "4.
|
|
7
|
+
version = "4.6.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" }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'''Unit tests for demos.filterdemo.'''
|
|
2
2
|
import unittest
|
|
3
|
-
from qtpy import QtWidgets
|
|
3
|
+
from qtpy import QtCore, QtWidgets
|
|
4
4
|
from QVideo.lib import QFilterRack, QFilterPipeline, QVideoScreen
|
|
5
5
|
from QVideo.cameras.Noise._tree import QNoiseTree
|
|
6
6
|
from QVideo.demos.demo import Demo
|
|
@@ -77,10 +77,12 @@ class TestFilterDemo(unittest.TestCase):
|
|
|
77
77
|
with self.assertRaises(ValueError):
|
|
78
78
|
FilterDemo(QNoiseTree(), ['No Such Filter'])
|
|
79
79
|
|
|
80
|
-
def
|
|
80
|
+
def test_deleting_the_demo_stops_the_pipeline(self):
|
|
81
81
|
widget = self._make_demo()
|
|
82
|
-
widget.
|
|
83
|
-
|
|
82
|
+
pipeline = widget.rack.pipeline
|
|
83
|
+
widget.deleteLater()
|
|
84
|
+
app.sendPostedEvents(None, QtCore.QEvent.DeferredDelete)
|
|
85
|
+
self.assertFalse(pipeline.isRunning())
|
|
84
86
|
|
|
85
87
|
|
|
86
88
|
if __name__ == '__main__': # pragma: no cover
|
|
@@ -3,7 +3,7 @@ import runpy
|
|
|
3
3
|
import unittest
|
|
4
4
|
import warnings
|
|
5
5
|
from unittest.mock import MagicMock, patch
|
|
6
|
-
from qtpy import QtWidgets
|
|
6
|
+
from qtpy import QtCore, QtWidgets
|
|
7
7
|
from QVideo.lib import QFilterRack
|
|
8
8
|
from QVideo.lib import launch
|
|
9
9
|
from QVideo.lib import _launch as launch_module
|
|
@@ -12,33 +12,69 @@ from QVideo.lib import _launch as launch_module
|
|
|
12
12
|
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication([])
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class _Widget(QtWidgets.QWidget):
|
|
16
|
+
'''Stands in for an application: it records how it was built.'''
|
|
17
|
+
|
|
18
|
+
def __init__(self, tree, **kwargs):
|
|
19
|
+
super().__init__()
|
|
20
|
+
self.tree = tree
|
|
21
|
+
self.kwargs = kwargs
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class _Talker(_Widget):
|
|
25
|
+
message = QtCore.Signal(str)
|
|
26
|
+
|
|
27
|
+
|
|
15
28
|
class TestLaunch(unittest.TestCase):
|
|
16
29
|
|
|
17
30
|
def run_launch(self, widget, **kwargs):
|
|
31
|
+
'''Launch *widget*; return the camera chooser and the window.'''
|
|
32
|
+
shown = []
|
|
33
|
+
|
|
34
|
+
def run():
|
|
35
|
+
shown.extend(w for w in app.topLevelWidgets()
|
|
36
|
+
if isinstance(w, QtWidgets.QMainWindow)
|
|
37
|
+
and w.isVisible())
|
|
38
|
+
|
|
18
39
|
with patch.object(launch_module, 'choose_camera') as choose, \
|
|
19
40
|
patch.object(launch_module.pg, 'mkQApp') as make_app, \
|
|
20
|
-
patch.object(launch_module.pg, 'exec'
|
|
41
|
+
patch.object(launch_module.pg, 'exec', run), \
|
|
21
42
|
patch.object(launch_module.QtWidgets, 'QShortcut'):
|
|
22
43
|
launch(widget, 'Title', **kwargs)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
self.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
window.
|
|
41
|
-
|
|
44
|
+
self.make_app = make_app
|
|
45
|
+
for window in shown:
|
|
46
|
+
self.addCleanup(window.close)
|
|
47
|
+
return choose, shown[0]
|
|
48
|
+
|
|
49
|
+
def test_the_widget_is_built_from_the_started_camera(self):
|
|
50
|
+
choose, window = self.run_launch(_Widget)
|
|
51
|
+
tree = choose.return_value.start.return_value
|
|
52
|
+
self.assertIs(window.centralWidget().tree, tree)
|
|
53
|
+
|
|
54
|
+
def test_further_arguments_reach_the_widget(self):
|
|
55
|
+
_, window = self.run_launch(_Widget, filters=['Canny'])
|
|
56
|
+
self.assertEqual(window.centralWidget().kwargs,
|
|
57
|
+
{'filters': ['Canny']})
|
|
58
|
+
|
|
59
|
+
def test_the_widget_is_the_center_of_a_main_window(self):
|
|
60
|
+
_, window = self.run_launch(_Widget)
|
|
61
|
+
self.assertIsInstance(window, QtWidgets.QMainWindow)
|
|
62
|
+
self.assertIsInstance(window.centralWidget(), _Widget)
|
|
63
|
+
|
|
64
|
+
def test_the_application_and_the_window_are_titled(self):
|
|
65
|
+
_, window = self.run_launch(_Widget)
|
|
66
|
+
self.make_app.assert_called_once_with('Title')
|
|
67
|
+
self.assertEqual(window.windowTitle(), 'Title')
|
|
68
|
+
|
|
69
|
+
def test_messages_appear_in_the_status_bar(self):
|
|
70
|
+
_, window = self.run_launch(_Talker)
|
|
71
|
+
window.centralWidget().message.emit('falling behind')
|
|
72
|
+
self.assertEqual(window.statusBar().currentMessage(),
|
|
73
|
+
'falling behind')
|
|
74
|
+
|
|
75
|
+
def test_a_widget_without_messages_is_left_alone(self):
|
|
76
|
+
_, window = self.run_launch(_Widget)
|
|
77
|
+
self.assertIsNone(window.findChild(QtWidgets.QStatusBar))
|
|
42
78
|
|
|
43
79
|
def test_a_missing_package_ends_the_program_with_its_message(self):
|
|
44
80
|
widget = MagicMock(side_effect=ImportError('install trackpy'))
|