Skip to content

Commit

Permalink
update caller
Browse files Browse the repository at this point in the history
  • Loading branch information
jandom committed May 25, 2024
1 parent 1c227f5 commit 2a3669d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 2a3669d

Please sign in to comment.