QVideo 4.0.0__tar.gz → 4.1.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.0 → qvideo-4.1.0}/PKG-INFO +1 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/QCamcorder.py +1 -2
- {qvideo-4.0.0 → qvideo-4.1.0}/QVideo.egg-info/PKG-INFO +1 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Genicam/_camera.py +43 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Genicam/_tree.py +24 -28
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/OpenCV/_camera.py +1 -3
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QDVRWidget.py +61 -3
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QCamera.py +45 -36
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QCameraTree.py +2 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QVideoSource.py +7 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QVideoWriter.py +27 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/__init__.py +2 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/pyproject.toml +1 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qcamera.py +58 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qdvrwidget.py +105 -5
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qgenicamcamera.py +68 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qopencvtree.py +11 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qvideosource.py +32 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qvideowriter.py +66 -1
- {qvideo-4.0.0 → qvideo-4.1.0}/LICENSE.md +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/QVideo.egg-info/SOURCES.txt +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/QVideo.egg-info/dependency_links.txt +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/QVideo.egg-info/requires.txt +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/QVideo.egg-info/top_level.txt +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/README.md +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/__main__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Basler/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Basler/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Basler/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Flir/QListFlirCameras.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Flir/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Flir/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Flir/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Genicam/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/IDS/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/IDS/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/IDS/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/MV/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/MV/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/MV/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Noise/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Noise/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Noise/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/OpenCV/QListCVCameras.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/OpenCV/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/OpenCV/_devices.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/OpenCV/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Picamera/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Picamera/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Picamera/_imx500.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Picamera/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Vimbax/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Vimbax/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/Vimbax/_tree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/cameras/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/ROIdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/circulardemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/compositedemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/demo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/filterdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/filterrackdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/histogramdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/trackpydemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/uniformitydemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/demos/yolodemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QCircularBuffer.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QCircularDVRWidget.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QHDF5Reader.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QHDF5Writer.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QOpenCVReader.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/QOpenCVWriter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/dvr/icons_rc.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/_MedianBase.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/artistic.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/blob.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/circletransform.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/darkframe.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/dejitter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/dog.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/edge.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/exposure.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/flatfield.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/foreground.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/gamma.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/invert.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/laplacian.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/median.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/momean.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/momedian.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/normalize.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/rgb.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/roi.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/samplehold.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/smoothing.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/sobel.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/threshold.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/filters/unsharp.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QFPSMeter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QFilterRack.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QFilterStack.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QHistogramWidget.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QListCameras.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QSnapshot.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QUniformityWidget.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QVideoFilter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QVideoReader.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/QVideoScreen.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/_jupyter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/_qabc.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/chooser.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/clickable.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/errors.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/gentl.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/imageops.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/lib/videotypes.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/overlays/__init__.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/overlays/trackpy.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/overlays/yolo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/setup.cfg +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_artistic.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_blob.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_camera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_chooser.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_circletransform.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_circularbuffer.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_circulardemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_circulardvrwidget.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_clickable.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_compositedemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_darkframe.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_dejitter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_demo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_dog.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_edge.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_exposure.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_filter_export.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_filterdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_filterrackdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_filters_gray.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_flatfield.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_foreground.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_gamma.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_gentl.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_histogramdemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_histogramwidget.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_icons_rc.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_imageops.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_invert.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_jupyter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_laplacian.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_median.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_momean.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_momedian.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_normalize.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_overlays_package.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qabc.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qbaslercamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qcamcorder.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qcameratree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qfilterrack.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qfilterstack.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qflircamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qfpsmeter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qgenicamtree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qhdf5reader.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qhdf5writer.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qidscamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qimxcamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qlistcameras.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qlistcvcameras.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qlistflircameras.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qmvcamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qnoisecamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qnoisetree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qopencvcamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qopencvdevices.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qopencvreader.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qopencvwriter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qpicamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qpicameratree.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qsnapshot.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qt_binding.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qvideoreader.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qvideoscreen.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_qvimbaxcamera.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_resolutions.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_rgb.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_roi.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_roidemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_samplehold.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_smoothing.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_sobel.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_threshold.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_trackpy_overlay.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_trackpydemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_uniformitydemo.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_uniformitywidget.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_unsharp.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_vendor_trees.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_videofilter.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_videotypes.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_yolo_overlay.py +0 -0
- {qvideo-4.0.0 → qvideo-4.1.0}/tests/test_yolodemo.py +0 -0
|
@@ -5,7 +5,7 @@ and DVR.
|
|
|
5
5
|
|
|
6
6
|
Run directly to launch a full camcorder application with camera selection::
|
|
7
7
|
|
|
8
|
-
python -m QVideo.QCamcorder [-b|-c|-f|-i|-m|-p|-
|
|
8
|
+
python -m QVideo.QCamcorder [-b|-c|-f|-i|-m|-p|-v] [cameraID]
|
|
9
9
|
|
|
10
10
|
Camera flags (mutually exclusive):
|
|
11
11
|
|
|
@@ -17,7 +17,6 @@ Camera flags (mutually exclusive):
|
|
|
17
17
|
-i [cameraID] IDS Imaging camera (requires IDS peak SDK)
|
|
18
18
|
-m [cameraID] MATRIX VISION mvGenTLProducer (universal GenICam, not FLIR)
|
|
19
19
|
-p [cameraID] Raspberry Pi camera module (requires picamera2)
|
|
20
|
-
-r [cameraID] OpenCV camera with resolution drop-down selector
|
|
21
20
|
-v [cameraID] Allied Vision VimbaX camera
|
|
22
21
|
-h Show help and exit
|
|
23
22
|
|
|
@@ -477,9 +477,51 @@ class QGenicamCamera(QCamera):
|
|
|
477
477
|
node = self.node(feature)
|
|
478
478
|
if node is None:
|
|
479
479
|
return False
|
|
480
|
-
|
|
480
|
+
with self._mutex:
|
|
481
|
+
mode = node.node.get_access_mode()
|
|
481
482
|
return (mode == EAccessMode.RW) or (feature in self._protected)
|
|
482
483
|
|
|
484
|
+
def state(self, name: str) -> dict[str, object]:
|
|
485
|
+
'''Return a snapshot of the named node, read under the device lock.
|
|
486
|
+
|
|
487
|
+
Read the device through this method, not through :meth:`node`,
|
|
488
|
+
wherever acquisition may be running (for example a GUI that polls
|
|
489
|
+
the hardware): it never overlaps a frame read.
|
|
490
|
+
|
|
491
|
+
Parameters
|
|
492
|
+
----------
|
|
493
|
+
name : str
|
|
494
|
+
GenICam node name. It must exist (see :meth:`has_node`).
|
|
495
|
+
|
|
496
|
+
Returns
|
|
497
|
+
-------
|
|
498
|
+
dict
|
|
499
|
+
``access`` (:class:`EAccessMode`) and ``kind`` (``'int'``,
|
|
500
|
+
``'float'``, ``'enum'`` or ``'other'``) always; ``min``,
|
|
501
|
+
``max`` and ``inc`` for numbers (``inc`` is ``None`` when the
|
|
502
|
+
node has no increment); ``entries`` (symbolic names) for an
|
|
503
|
+
enumeration; and ``value`` when the node is readable.
|
|
504
|
+
'''
|
|
505
|
+
node = self.node(name)
|
|
506
|
+
with self._mutex:
|
|
507
|
+
access = node.node.get_access_mode()
|
|
508
|
+
state = {'access': access, 'kind': 'other'}
|
|
509
|
+
if isinstance(node, IInteger):
|
|
510
|
+
state.update(kind='int', min=node.min, max=node.max,
|
|
511
|
+
inc=node.inc)
|
|
512
|
+
elif isinstance(node, IFloat):
|
|
513
|
+
state.update(kind='float', min=node.min, max=node.max,
|
|
514
|
+
inc=node.inc if node.has_inc() else None)
|
|
515
|
+
elif isinstance(node, IEnumeration):
|
|
516
|
+
state.update(kind='enum',
|
|
517
|
+
entries=[v.symbolic for v in node.entries])
|
|
518
|
+
if access in (EAccessMode.RO, EAccessMode.RW):
|
|
519
|
+
if isinstance(node, IEnumeration):
|
|
520
|
+
state['value'] = node.to_string()
|
|
521
|
+
elif isinstance(node, IProperty):
|
|
522
|
+
state['value'] = node.value
|
|
523
|
+
return state
|
|
524
|
+
|
|
483
525
|
|
|
484
526
|
class QGenicamSource(QVideoSource):
|
|
485
527
|
|
|
@@ -243,34 +243,31 @@ class QGenicamTree(QCameraTree):
|
|
|
243
243
|
name = p.opts.get('name')
|
|
244
244
|
if not self.camera.has_node(name):
|
|
245
245
|
continue
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
state = self.camera.state(name)
|
|
247
|
+
kind, inc = state['kind'], state.get('inc')
|
|
248
|
+
if kind == 'int':
|
|
249
|
+
p.setOpts(limits=(state['min'], state['max']), step=inc)
|
|
250
|
+
elif kind == 'float':
|
|
250
251
|
scale = self._scaleFactors.get(name, 1.0)
|
|
251
|
-
opts = {'limits': (
|
|
252
|
+
opts = {'limits': (state['min'] * scale,
|
|
253
|
+
state['max'] * scale)}
|
|
252
254
|
if name in self._decParams:
|
|
253
255
|
value = p.value()
|
|
254
256
|
if value > 0:
|
|
255
257
|
step = 10 ** (math.floor(math.log10(value)) - 1)
|
|
256
|
-
if
|
|
257
|
-
step = max(step,
|
|
258
|
+
if inc is not None:
|
|
259
|
+
step = max(step, inc * scale)
|
|
258
260
|
opts['step'] = step
|
|
259
|
-
elif
|
|
260
|
-
opts['step'] =
|
|
261
|
+
elif inc is not None:
|
|
262
|
+
opts['step'] = inc * scale
|
|
261
263
|
p.setOpts(**opts)
|
|
262
|
-
elif
|
|
263
|
-
p.setOpts(limits=[
|
|
264
|
-
|
|
265
|
-
def
|
|
266
|
-
'''
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
elif isinstance(node, (IBoolean, IInteger, IFloat, IString)):
|
|
270
|
-
value = node.value
|
|
271
|
-
else:
|
|
272
|
-
return None
|
|
273
|
-
if name in self._scaleFactors:
|
|
264
|
+
elif kind == 'enum':
|
|
265
|
+
p.setOpts(limits=state['entries'])
|
|
266
|
+
|
|
267
|
+
def _scaledValue(self, name: str, state: dict) -> object:
|
|
268
|
+
'''Return the value in a node snapshot, applying any scale factor.'''
|
|
269
|
+
value = state.get('value')
|
|
270
|
+
if value is not None and name in self._scaleFactors:
|
|
274
271
|
value *= self._scaleFactors[name]
|
|
275
272
|
return value
|
|
276
273
|
|
|
@@ -289,10 +286,10 @@ class QGenicamTree(QCameraTree):
|
|
|
289
286
|
name = p.opts.get('name')
|
|
290
287
|
if not self.camera.has_node(name):
|
|
291
288
|
continue
|
|
292
|
-
|
|
293
|
-
if
|
|
289
|
+
state = self.camera.state(name)
|
|
290
|
+
if state['access'] != EAccessMode.RO:
|
|
294
291
|
continue
|
|
295
|
-
value = self.
|
|
292
|
+
value = self._scaledValue(name, state)
|
|
296
293
|
if value is None:
|
|
297
294
|
continue
|
|
298
295
|
p.blockSignals(True)
|
|
@@ -333,11 +330,10 @@ class QGenicamTree(QCameraTree):
|
|
|
333
330
|
name = p.opts.get('name')
|
|
334
331
|
if not self.camera.has_node(name):
|
|
335
332
|
continue
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if mode not in (EAccessMode.RO, EAccessMode.RW):
|
|
333
|
+
state = self.camera.state(name)
|
|
334
|
+
if state['access'] not in (EAccessMode.RO, EAccessMode.RW):
|
|
339
335
|
continue
|
|
340
|
-
value = self.
|
|
336
|
+
value = self._scaledValue(name, state)
|
|
341
337
|
if value is None:
|
|
342
338
|
continue
|
|
343
339
|
p.setValue(value)
|
|
@@ -243,9 +243,7 @@ class QOpenCVCamera(QCamera):
|
|
|
243
243
|
Stores the value for the next :meth:`_initialize` and writes it to
|
|
244
244
|
the device immediately. OpenCV's V4L2 backend handles the required
|
|
245
245
|
``VIDIOC_STREAMOFF`` / ``VIDIOC_S_FMT`` / ``VIDIOC_STREAMON`` cycle
|
|
246
|
-
internally, so no device close/reopen is needed.
|
|
247
|
-
be holding :attr:`~QVideo.lib.QCamera.QCamera.mutex` — use
|
|
248
|
-
:meth:`~QVideo.lib.QCamera.QCamera.set` which acquires it.
|
|
246
|
+
internally, so no device close/reopen is needed.
|
|
249
247
|
'''
|
|
250
248
|
self._configWidth = int(value)
|
|
251
249
|
self._device.set(self.WIDTH, self._configWidth)
|
|
@@ -4,7 +4,7 @@ from qtpy import QtCore, QtGui, QtWidgets
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
import numpy as np
|
|
6
6
|
from QVideo.lib import clickable, QVideoSource
|
|
7
|
-
from QVideo.lib.videotypes import Image
|
|
7
|
+
from QVideo.lib.videotypes import Image, FrameInfo
|
|
8
8
|
from .QOpenCVWriter import QOpenCVWriter
|
|
9
9
|
from .QOpenCVReader import QOpenCVSource
|
|
10
10
|
|
|
@@ -55,6 +55,15 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
55
55
|
filename : str or None
|
|
56
56
|
Default file path for saving. If ``None``, defaults to
|
|
57
57
|
``~/default.mkv``.
|
|
58
|
+
stopWhenBehind : bool
|
|
59
|
+
Stop recording when the writer falls more than *lagLimit* seconds
|
|
60
|
+
behind the camera. A recorder must not drop frames, so frames
|
|
61
|
+
queue in memory while storage is slower than the camera; stopping
|
|
62
|
+
keeps a slow disk from filling memory. Set ``False`` to record
|
|
63
|
+
through the backlog. Default: ``True``.
|
|
64
|
+
lagLimit : float
|
|
65
|
+
How far [seconds] the writer may fall behind the newest captured
|
|
66
|
+
frame. Default: ``1.``.
|
|
58
67
|
*args :
|
|
59
68
|
Forwarded to :class:`~qtpy.QtWidgets.QFrame`.
|
|
60
69
|
**kwargs :
|
|
@@ -68,6 +77,18 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
68
77
|
Emitted when recording starts (``True``) or stops (``False``).
|
|
69
78
|
playing(bool)
|
|
70
79
|
Emitted when playback starts (``True``) or stops (``False``).
|
|
80
|
+
behind(float)
|
|
81
|
+
Emitted once each time the recording falls more than *lagLimit*
|
|
82
|
+
seconds behind the camera, with the lag in seconds.
|
|
83
|
+
stopped(str)
|
|
84
|
+
Emitted with the reason when the widget stops a recording by
|
|
85
|
+
itself, just before ``recording(False)``.
|
|
86
|
+
|
|
87
|
+
Notes
|
|
88
|
+
-----
|
|
89
|
+
Stopping waits for the writer to finish the frames already captured,
|
|
90
|
+
so no recorded frame is lost. With *stopWhenBehind* the wait is
|
|
91
|
+
bounded by *lagLimit* seconds of data.
|
|
71
92
|
'''
|
|
72
93
|
|
|
73
94
|
#: Emitted for each frame during playback.
|
|
@@ -76,6 +97,11 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
76
97
|
recording = QtCore.Signal(bool)
|
|
77
98
|
#: Emitted when playback starts (``True``) or stops (``False``).
|
|
78
99
|
playing = QtCore.Signal(bool)
|
|
100
|
+
#: Emitted when the recording falls behind the camera, with the lag [s].
|
|
101
|
+
behind = QtCore.Signal(float)
|
|
102
|
+
#: Emitted with the reason when the widget stops a recording itself.
|
|
103
|
+
stopped = QtCore.Signal(str)
|
|
104
|
+
_shutdown = QtCore.Signal()
|
|
79
105
|
|
|
80
106
|
FILENAME = 'default.mkv'
|
|
81
107
|
|
|
@@ -131,12 +157,17 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
131
157
|
*args,
|
|
132
158
|
source: QVideoSource | None = None,
|
|
133
159
|
filename: str = '',
|
|
160
|
+
stopWhenBehind: bool = True,
|
|
161
|
+
lagLimit: float = 1.,
|
|
134
162
|
**kwargs) -> None:
|
|
135
163
|
super().__init__(*args, **kwargs)
|
|
164
|
+
self.stopWhenBehind = stopWhenBehind
|
|
165
|
+
self.lagLimit = lagLimit
|
|
136
166
|
self._source: QVideoSource | None = None
|
|
137
167
|
self._writer: object | None = None
|
|
138
168
|
self._player: QVideoSource | None = None
|
|
139
169
|
self._thread: QtCore.QThread | None = None
|
|
170
|
+
self._late = False
|
|
140
171
|
self._setupUi()
|
|
141
172
|
self._connectSignals()
|
|
142
173
|
self.source = source
|
|
@@ -329,12 +360,15 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
329
360
|
fps=self.source.fps,
|
|
330
361
|
nframes=self.nframes.value(),
|
|
331
362
|
nskip=self.nskip.value())
|
|
363
|
+
self._late = False
|
|
332
364
|
self._writer.frameNumber.connect(self.setFrameNumber)
|
|
333
365
|
self._writer.finished.connect(self.stop)
|
|
334
366
|
self._thread = QtCore.QThread()
|
|
335
367
|
self._writer.moveToThread(self._thread)
|
|
368
|
+
self._shutdown.connect(self._writer.shutdown)
|
|
336
369
|
self._thread.start()
|
|
337
370
|
self.source.newFrame.connect(self._writer.write)
|
|
371
|
+
self.source.newFrame.connect(self._watch)
|
|
338
372
|
self.recording.emit(True)
|
|
339
373
|
|
|
340
374
|
@QtCore.Slot()
|
|
@@ -390,14 +424,14 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
390
424
|
logger.debug('Stopping Recording')
|
|
391
425
|
try:
|
|
392
426
|
self.source.newFrame.disconnect(self._writer.write)
|
|
427
|
+
self.source.newFrame.disconnect(self._watch)
|
|
393
428
|
self._writer.frameNumber.disconnect(self.setFrameNumber)
|
|
394
429
|
self._writer.finished.disconnect(self.stop)
|
|
395
430
|
except (RuntimeError, TypeError):
|
|
396
431
|
logger.debug(
|
|
397
432
|
'Some recording signals were already disconnected')
|
|
398
|
-
self.
|
|
433
|
+
self._shutdown.emit()
|
|
399
434
|
self._thread.wait()
|
|
400
|
-
self._writer.close()
|
|
401
435
|
self._thread = None
|
|
402
436
|
self._writer = None
|
|
403
437
|
self.recording.emit(False)
|
|
@@ -418,6 +452,30 @@ class QDVRWidget(QtWidgets.QFrame):
|
|
|
418
452
|
self.stop()
|
|
419
453
|
super().closeEvent(event)
|
|
420
454
|
|
|
455
|
+
@QtCore.Slot(np.ndarray)
|
|
456
|
+
@QtCore.Slot(np.ndarray, object)
|
|
457
|
+
def _watch(self, frame: Image, info: FrameInfo | None = None) -> None:
|
|
458
|
+
'''Compare each captured frame with the newest one the writer has
|
|
459
|
+
taken up, and report once each time the writer falls behind.
|
|
460
|
+
|
|
461
|
+
The comparison uses the capture times, so it measures the backlog
|
|
462
|
+
even while the writer is stuck inside a single write, and it
|
|
463
|
+
ignores sources that capture slowly.
|
|
464
|
+
'''
|
|
465
|
+
taken = self._writer and self._writer.received
|
|
466
|
+
if info is None or not taken:
|
|
467
|
+
return
|
|
468
|
+
lag = info.timestamp - taken.timestamp
|
|
469
|
+
late = lag > self.lagLimit
|
|
470
|
+
if late and not self._late:
|
|
471
|
+
self.behind.emit(lag)
|
|
472
|
+
if self.stopWhenBehind:
|
|
473
|
+
reason = f'recording fell {lag:.1f} s behind the camera'
|
|
474
|
+
logger.error(reason)
|
|
475
|
+
self.stopped.emit(reason)
|
|
476
|
+
self.stop()
|
|
477
|
+
self._late = late
|
|
478
|
+
|
|
421
479
|
@QtCore.Slot(int)
|
|
422
480
|
def setFrameNumber(self, framenumber: int) -> None:
|
|
423
481
|
'''Set the displayed frame number.'''
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'''Abstract base class for all QVideo camera backends.'''
|
|
2
2
|
from abc import abstractmethod
|
|
3
3
|
from collections.abc import Callable
|
|
4
|
+
from functools import wraps
|
|
4
5
|
from types import TracebackType
|
|
5
6
|
from qtpy import QtCore
|
|
6
7
|
from QVideo.lib._qabc import QABCMeta
|
|
7
8
|
from QVideo.lib.videotypes import Image
|
|
8
9
|
import numpy as np
|
|
9
10
|
import logging
|
|
11
|
+
import threading
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
logger = logging.getLogger(__name__)
|
|
@@ -68,11 +70,14 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
68
70
|
|
|
69
71
|
Notes
|
|
70
72
|
-----
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
so
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
One reentrant lock serializes all access to the device. Every
|
|
74
|
+
registered getter, setter and method, and :meth:`saferead`, runs
|
|
75
|
+
holding it, so no property is read or written while a frame is
|
|
76
|
+
being read, and a multi-step change (stop acquisition, set, restart)
|
|
77
|
+
is never interleaved with anything else. Backends need no locking of
|
|
78
|
+
their own, and may freely call one another's properties. Pause and
|
|
79
|
+
resume control is the responsibility of the enclosing
|
|
80
|
+
:class:`QVideoSource`.
|
|
76
81
|
'''
|
|
77
82
|
|
|
78
83
|
PropertyValue = bool | int | float | str
|
|
@@ -86,7 +91,7 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
86
91
|
|
|
87
92
|
def __init__(self, *args, **kwargs) -> None:
|
|
88
93
|
super().__init__(*args, **kwargs)
|
|
89
|
-
self._mutex =
|
|
94
|
+
self._mutex = threading.RLock()
|
|
90
95
|
self._properties: dict[str, dict[str, object]] = {}
|
|
91
96
|
self._methods: dict[str, Callable[[], object]] = {}
|
|
92
97
|
self._isOpen = False
|
|
@@ -117,7 +122,7 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
117
122
|
def __setattr__(self, name: str, value) -> None:
|
|
118
123
|
'''Delegate attribute assignment to registered property setters.
|
|
119
124
|
|
|
120
|
-
Routes ``camera.fps = 30`` through :meth:`set` (
|
|
125
|
+
Routes ``camera.fps = 30`` through :meth:`set` (serialized with reads,
|
|
121
126
|
type-coerced) for any name in ``_properties``. All other names —
|
|
122
127
|
including internal backing attributes and Qt object attributes —
|
|
123
128
|
fall through to ``super().__setattr__``.
|
|
@@ -177,7 +182,9 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
177
182
|
if setter is _AUTO:
|
|
178
183
|
def setter(v): return setattr(self, f'_{name}', ptype(v))
|
|
179
184
|
self._properties[name] = dict(
|
|
180
|
-
getter=getter,
|
|
185
|
+
getter=self._serialized(getter),
|
|
186
|
+
setter=self._serialized(setter),
|
|
187
|
+
ptype=ptype, **meta)
|
|
181
188
|
|
|
182
189
|
def registerMethod(self, name: str, method: Callable[[], object]) -> None:
|
|
183
190
|
'''Register a named callable method.
|
|
@@ -189,7 +196,18 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
189
196
|
method : callable
|
|
190
197
|
Zero-argument callable to invoke.
|
|
191
198
|
'''
|
|
192
|
-
self._methods[name] = method
|
|
199
|
+
self._methods[name] = self._serialized(method)
|
|
200
|
+
|
|
201
|
+
def _serialized(self, function: Callable | None) -> Callable | None:
|
|
202
|
+
'''Wrap *function* so that it runs holding the device lock.'''
|
|
203
|
+
if function is None:
|
|
204
|
+
return None
|
|
205
|
+
|
|
206
|
+
@wraps(function)
|
|
207
|
+
def locked(*args):
|
|
208
|
+
with self._mutex:
|
|
209
|
+
return function(*args)
|
|
210
|
+
return locked
|
|
193
211
|
|
|
194
212
|
# ------------------------------------------------------------------
|
|
195
213
|
# Open / close lifecycle
|
|
@@ -299,16 +317,15 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
299
317
|
value : PropertyValue
|
|
300
318
|
New value to assign.
|
|
301
319
|
'''
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
setter(value)
|
|
320
|
+
if key not in self._properties:
|
|
321
|
+
logger.error(f'Unknown property: {key}')
|
|
322
|
+
return
|
|
323
|
+
setter = self._properties[key]['setter']
|
|
324
|
+
if setter is None:
|
|
325
|
+
logger.warning(f'Property {key!r} is read-only')
|
|
326
|
+
else:
|
|
327
|
+
logger.debug(f'Setting {key}: {value}')
|
|
328
|
+
setter(value)
|
|
312
329
|
|
|
313
330
|
@QtCore.Slot(str)
|
|
314
331
|
def get(self, key: str) -> PropertyValue | None:
|
|
@@ -326,12 +343,10 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
326
343
|
PropertyValue or None
|
|
327
344
|
Current value, or ``None`` if the property is unknown.
|
|
328
345
|
'''
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
logger.error(f'Unknown property: {key}')
|
|
334
|
-
return None
|
|
346
|
+
if key not in self._properties:
|
|
347
|
+
logger.error(f'Unknown property: {key}')
|
|
348
|
+
return None
|
|
349
|
+
value = self._properties[key]['getter']()
|
|
335
350
|
self.propertyValue.emit(key, value)
|
|
336
351
|
return value
|
|
337
352
|
|
|
@@ -344,11 +359,10 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
344
359
|
key : str
|
|
345
360
|
Method name.
|
|
346
361
|
'''
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
logger.error(f'Unknown method: {key}')
|
|
362
|
+
if key in self._methods:
|
|
363
|
+
self._methods[key]()
|
|
364
|
+
else:
|
|
365
|
+
logger.error(f'Unknown method: {key}')
|
|
352
366
|
|
|
353
367
|
# ------------------------------------------------------------------
|
|
354
368
|
# Frame acquisition
|
|
@@ -363,11 +377,6 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
363
377
|
tuple[bool, Image or None]
|
|
364
378
|
``(True, frame)`` on success, ``(False, None)`` on failure.
|
|
365
379
|
|
|
366
|
-
Notes
|
|
367
|
-
-----
|
|
368
|
-
Must not call :meth:`set`, :meth:`get`, :meth:`execute`, or
|
|
369
|
-
:meth:`saferead` — those methods acquire the same non-recursive
|
|
370
|
-
mutex that :meth:`saferead` holds while invoking ``read()``.
|
|
371
380
|
'''
|
|
372
381
|
|
|
373
382
|
def saferead(self) -> CameraData:
|
|
@@ -381,7 +390,7 @@ class QCamera(QtCore.QObject, metaclass=QABCMeta):
|
|
|
381
390
|
tuple[bool, Image or None]
|
|
382
391
|
Result of :meth:`read`.
|
|
383
392
|
'''
|
|
384
|
-
with
|
|
393
|
+
with self._mutex:
|
|
385
394
|
return self.read()
|
|
386
395
|
|
|
387
396
|
# ------------------------------------------------------------------
|
|
@@ -76,6 +76,8 @@ class QCameraTree(ParameterTree):
|
|
|
76
76
|
'default': value}
|
|
77
77
|
if spec['setter'] is None:
|
|
78
78
|
entry['enabled'] = False
|
|
79
|
+
if spec.get('hidden'):
|
|
80
|
+
entry['visible'] = False
|
|
79
81
|
if spec['ptype'] is str and spec.get('limits'):
|
|
80
82
|
entry.update(type='list', limits=spec['limits'])
|
|
81
83
|
entries.append(entry)
|
|
@@ -143,6 +143,13 @@ class QVideoSource(QtCore.QThread):
|
|
|
143
143
|
self.newFrame.emit(frame, info)
|
|
144
144
|
logger.debug('streaming finished')
|
|
145
145
|
|
|
146
|
+
def __del__(self) -> None:
|
|
147
|
+
# Python state only: the flag is absent if construction failed and
|
|
148
|
+
# False once stopped, when Qt may already have deleted the object.
|
|
149
|
+
if vars(self).get('_running'):
|
|
150
|
+
self.stop()
|
|
151
|
+
self.wait()
|
|
152
|
+
|
|
146
153
|
@QtCore.Slot()
|
|
147
154
|
def start(self) -> 'QVideoSource':
|
|
148
155
|
'''Start the capture thread.
|
|
@@ -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()
|
|
@@ -59,6 +59,7 @@ from .QSnapshot import QSnapshot
|
|
|
59
59
|
__all__ = '''Image
|
|
60
60
|
FrameInfo
|
|
61
61
|
clickable Camera choose_camera QListCameras
|
|
62
|
-
QCamera QCameraError QDriverError QDeviceError QVideoSource QCameraTree
|
|
62
|
+
QCamera QCameraError QDriverError QDeviceError QVideoSource QCameraTree
|
|
63
|
+
QFilterRack QFilterStack
|
|
63
64
|
QVideoReader QVideoWriter QVideoScreen
|
|
64
65
|
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.1.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,4 +1,6 @@
|
|
|
1
1
|
'''Unit tests for QCamera.'''
|
|
2
|
+
import threading
|
|
3
|
+
import time
|
|
2
4
|
import unittest
|
|
3
5
|
import numpy as np
|
|
4
6
|
from unittest.mock import patch
|
|
@@ -75,7 +77,7 @@ class TestInit(unittest.TestCase):
|
|
|
75
77
|
|
|
76
78
|
def test_has_mutex(self):
|
|
77
79
|
cam = make_camera()
|
|
78
|
-
self.assertIsInstance(cam._mutex,
|
|
80
|
+
self.assertIsInstance(cam._mutex, type(threading.RLock()))
|
|
79
81
|
|
|
80
82
|
|
|
81
83
|
|
|
@@ -428,5 +430,60 @@ class TestExecute(unittest.TestCase):
|
|
|
428
430
|
cam.execute('nonexistent')
|
|
429
431
|
|
|
430
432
|
|
|
433
|
+
class TestSerialization(unittest.TestCase):
|
|
434
|
+
'''No device access overlaps a frame read, by any route.'''
|
|
435
|
+
|
|
436
|
+
def setUp(self):
|
|
437
|
+
self.cam = make_camera()
|
|
438
|
+
self.reading = threading.Event()
|
|
439
|
+
self.overlaps = []
|
|
440
|
+
|
|
441
|
+
def slow_read():
|
|
442
|
+
self.reading.set()
|
|
443
|
+
time.sleep(0.15)
|
|
444
|
+
self.reading.clear()
|
|
445
|
+
return True, np.zeros((4, 4), dtype=np.uint8)
|
|
446
|
+
|
|
447
|
+
def checked(value):
|
|
448
|
+
def getter():
|
|
449
|
+
self.overlaps.append(self.reading.is_set())
|
|
450
|
+
return value
|
|
451
|
+
return getter
|
|
452
|
+
|
|
453
|
+
self.cam.read = slow_read
|
|
454
|
+
self.cam.registerProperty('probe', getter=checked(1), ptype=int)
|
|
455
|
+
self.cam.registerMethod('act', checked(None))
|
|
456
|
+
|
|
457
|
+
def during_a_read(self, access):
|
|
458
|
+
thread = threading.Thread(target=self.cam.saferead)
|
|
459
|
+
thread.start()
|
|
460
|
+
self.reading.wait(1)
|
|
461
|
+
access()
|
|
462
|
+
thread.join()
|
|
463
|
+
self.assertEqual(self.overlaps, [False])
|
|
464
|
+
|
|
465
|
+
def test_attribute_access(self):
|
|
466
|
+
self.during_a_read(lambda: self.cam.probe)
|
|
467
|
+
|
|
468
|
+
def test_get(self):
|
|
469
|
+
self.during_a_read(lambda: self.cam.get('probe'))
|
|
470
|
+
|
|
471
|
+
def test_settings(self):
|
|
472
|
+
self.during_a_read(lambda: self.cam.settings)
|
|
473
|
+
|
|
474
|
+
def test_execute(self):
|
|
475
|
+
self.during_a_read(lambda: self.cam.execute('act'))
|
|
476
|
+
|
|
477
|
+
def test_set(self):
|
|
478
|
+
self.cam.registerProperty('probe', getter=lambda: 1, ptype=int,
|
|
479
|
+
setter=lambda v: self.overlaps.append(
|
|
480
|
+
self.reading.is_set()))
|
|
481
|
+
self.during_a_read(lambda: self.cam.set('probe', 2))
|
|
482
|
+
|
|
483
|
+
def test_a_setter_may_read_other_properties(self):
|
|
484
|
+
self.cam.set('width', 320)
|
|
485
|
+
self.assertEqual(self.cam.shape.width(), 320)
|
|
486
|
+
|
|
487
|
+
|
|
431
488
|
if __name__ == '__main__':
|
|
432
489
|
unittest.main()
|