1
0

qt gui: qrreader: lower strong_count in qtmultimedia based reader

The qtmultimedia-based qrreader has the concept of "strong_count":
before the scanner returns a decoded qr code result, it waits until
it has seen at least "strong_count" (e.g. 10) frames in which the qr code was seen and successfully decoded.
I think the idea might have been to reduce false positives, mis-decoding qr codes from bad frames.
However in practice it makes scanning even moderately sized qr codes really difficult for the user:
it takes several seconds (at least on my laptop cam) to obtain enough "clear" frames that count into the strong_count.

So I am lowering the strong_count to 2, down from CAMERA_FPS/3,
which makes it easier to scan, and I still haven't seen false positives even with this value.
This commit is contained in:
SomberNight
2025-01-10 12:59:56 +00:00
parent 838490fea4
commit c43a691eee
2 changed files with 5 additions and 4 deletions

View File

@@ -171,7 +171,6 @@ class QrReaderCameraDialog(Logger, MessageBoxMixin, QDialog):
"""
self.validator = QrReaderValidatorCounted()
self.validator.strong_count = 5 # FIXME: make this time based rather than framect based
device_info = None
@@ -322,8 +321,8 @@ class QrReaderCameraDialog(Logger, MessageBoxMixin, QDialog):
if last_stats_delta > 1.0: # stats every 1.0 seconds
fps = self.frame_counter / last_stats_delta
qr_fps = self.qr_frame_counter / last_stats_delta
if self.validator is not None:
self.validator.strong_count = math.ceil(qr_fps / 3) # 1/3 of a second's worth of qr frames determines strong_count
#if self.validator is not None:
# self.validator.strong_count = math.ceil(qr_fps / 3) # 1/3 of a second's worth of qr frames determines strong_count
stats_format = 'running at {} FPS, scanner at {} FPS'
self.logger.info(stats_format.format(fps, qr_fps))
self.frame_counter = 0

View File

@@ -104,7 +104,9 @@ class QrReaderValidatorColorizing(QrReaderValidatorCounting):
WEAK_COLOR: QColor = QColor(Qt.GlobalColor.red)
STRONG_COLOR: QColor = QColor(Qt.GlobalColor.green)
strong_count: int = 10
strong_count: int = 2 # FIXME: make this time based rather than framect based
# note: we set a low strong_count to ~disable this mechanism and make QR codes
# much easier to scan (but potentially with some false positives)
def validate_results(self, results: List[QrCodeResult]) -> QrReaderValidatorResult:
res = super().validate_results(results)