File indexing completed on 2024-05-12 15:49:09
0001 /* 0002 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: MIT 0004 */ 0005 0006 #ifndef PRISON_VIDEOSCANNER_H 0007 #define PRISON_VIDEOSCANNER_H 0008 0009 #include "prisonscanner_export.h" 0010 #include "scanresult.h" 0011 0012 #include <QAbstractVideoFilter> 0013 #include <QObject> 0014 0015 #include <memory> 0016 0017 namespace Prison 0018 { 0019 0020 class VideoScannerPrivate; 0021 0022 /** Scans a live video feed for barcodes. 0023 * 0024 * In Qt5 this can be added as a video filter to a VideoOutput element. 0025 * In Qt6 this can be connected to a QVideoSink object. 0026 * 0027 * @since 5.94 0028 */ 0029 class PRISONSCANNER_EXPORT VideoScanner : public QAbstractVideoFilter 0030 { 0031 Q_OBJECT 0032 Q_PROPERTY(Prison::ScanResult result READ result NOTIFY resultChanged) 0033 Q_PROPERTY(Prison::Format::BarcodeFormats formats READ formats WRITE setFormats NOTIFY formatsChanged) 0034 0035 public: 0036 explicit VideoScanner(QObject *parent = nullptr); 0037 ~VideoScanner(); 0038 0039 /** The latest result of the barcode scan. */ 0040 ScanResult result() const; 0041 0042 /** The barcode formats the scanner should look for. 0043 * By default all supported formats are enabled. 0044 */ 0045 Format::BarcodeFormats formats() const; 0046 /** 0047 * Sets the barcode formats to detect. 0048 * @param formats can be OR'ed values from Format::BarcodeFormats. 0049 */ 0050 void setFormats(Format::BarcodeFormats formats); 0051 0052 /// @cond internal 0053 QVideoFilterRunnable *createFilterRunnable() override; 0054 /// @endcond 0055 0056 Q_SIGNALS: 0057 /** Emitted whenever we get a new scan result, as long as any 0058 * property of the result changes. On a live video feed this can 0059 * be very frequently due to the changes of the position of the detected 0060 * barcode. This is therefore useful e.g. for marking the position 0061 * of the detected barcode. 0062 * @see resultContentChanged 0063 */ 0064 void resultChanged(const Prison::ScanResult &scanResult); 0065 0066 /** Emitted when a barcode with a new content has been detected, but 0067 * not when merely the position of a barcode changes in the video stream. 0068 * This is useful e.g. for continuously scanning multiple codes in one go. 0069 * @see resultChanged 0070 */ 0071 void resultContentChanged(const Prison::ScanResult &scanResult); 0072 0073 void formatsChanged(); 0074 void videoSinkChanged(); 0075 0076 private: 0077 std::unique_ptr<VideoScannerPrivate> d; 0078 }; 0079 0080 } 0081 0082 #endif // PRISON_VIDEOSCANNER_H