Prison

videoscanner.h
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: MIT
4*/
5
6#ifndef PRISON_VIDEOSCANNER_H
7#define PRISON_VIDEOSCANNER_H
8
9#include "prisonscanner_export.h"
10#include "scanresult.h"
11
12#include <QObject>
13#include <QVideoSink>
14
15#include <memory>
16
17namespace Prison
18{
19
20class VideoScannerPrivate;
21
22/** Scans a live video feed for barcodes.
23 *
24 * In Qt5 this can be added as a video filter to a VideoOutput element.
25 * In Qt6 this can be connected to a QVideoSink object.
26 *
27 * @since 5.94
28 */
29class PRISONSCANNER_EXPORT VideoScanner : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(Prison::ScanResult result READ result NOTIFY resultChanged)
33 Q_PROPERTY(Prison::Format::BarcodeFormats formats READ formats WRITE setFormats NOTIFY formatsChanged)
34
35 Q_PROPERTY(QVideoSink *videoSink READ videoSink WRITE setVideoSink NOTIFY videoSinkChanged)
36
37public:
38 explicit VideoScanner(QObject *parent = nullptr);
40
41 /** The latest result of the barcode scan. */
42 ScanResult result() const;
43
44 /** The barcode formats the scanner should look for.
45 * By default all supported formats are enabled.
46 */
47 Format::BarcodeFormats formats() const;
48 /**
49 * Sets the barcode formats to detect.
50 * @param formats can be OR'ed values from Format::BarcodeFormats.
51 */
52 void setFormats(Format::BarcodeFormats formats);
53
54 /** The video sink being scanned for barcodes. */
55 QVideoSink *videoSink() const;
56 /** Sets the video sink to scan for barcodes. */
57 void setVideoSink(QVideoSink *sink);
58
59Q_SIGNALS:
60 /** Emitted whenever we get a new scan result, as long as any
61 * property of the result changes. On a live video feed this can
62 * be very frequently due to the changes of the position of the detected
63 * barcode. This is therefore useful e.g. for marking the position
64 * of the detected barcode.
65 * @see resultContentChanged
66 */
67 void resultChanged(const Prison::ScanResult &scanResult);
68
69 /** Emitted when a barcode with a new content has been detected, but
70 * not when merely the position of a barcode changes in the video stream.
71 * This is useful e.g. for continuously scanning multiple codes in one go.
72 * @see resultChanged
73 */
75
76 void formatsChanged();
77 void videoSinkChanged();
78
79private:
80 std::unique_ptr<VideoScannerPrivate> d;
81};
82
83}
84
85#endif // PRISON_VIDEOSCANNER_H
Result of a barcode scan attempt.
Definition scanresult.h:31
Scans a live video feed for barcodes.
void resultContentChanged(const Prison::ScanResult &scanResult)
Emitted when a barcode with a new content has been detected, but not when merely the position of a ba...
void resultChanged(const Prison::ScanResult &scanResult)
Emitted whenever we get a new scan result, as long as any property of the result changes.
Provides classes and methods for generating barcodes.
Definition barcode.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:42:29 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.