From 2a3669da9f4fc6a8cb870d5da9900b51eae0bd86 Mon Sep 17 00:00:00 2001 From: Jan Domanski Date: Sat, 25 May 2024 10:06:20 +0200 Subject: [PATCH] update caller --- qreader.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qreader.py b/qreader.py index 57aa86e..0a474e5 100644 --- a/qreader.py +++ b/qreader.py @@ -126,7 +126,9 @@ def decode(self, image: np.ndarray, detection_result: dict[str, np.ndarray|float # Crop the image if a bounding box is given decodedQR = self._decode_qr_zbar(image=image, detection_result=detection_result) if len(decodedQR) > 0: - decoded_str = decodedQR[0].data.decode('utf-8') + # Take first result only + decodeQRResult = decodedQR[0] + decoded_str = decodeQRResult.result.data.decode('utf-8') for encoding in self.reencode_to: try: decoded_str = decoded_str.encode(encoding).decode('utf-8') @@ -204,7 +206,7 @@ def get_detection_result_from_polygon(self, def _decode_qr_zbar(self, image: np.ndarray, detection_result: dict[str, np.ndarray | float | tuple[float | int, float | int]]) -> list[ - Decoded]: + DecodeQRResult]: """ Try to decode the QR code just with pyzbar, pre-processing the image if it fails in different ways that sometimes work.