Skip to content

Commit

Permalink
update qreader.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jandom committed Jul 24, 2024
1 parent a62d6b7 commit cf081bf
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions qreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,10 @@ def decode(

def detect_and_decode(
self, image: np.ndarray, return_detections: bool = False, is_bgr: bool = False
) -> (
tuple[
dict[str, np.ndarray | float | tuple[float | int, float | int]], str | None
]
| tuple[str | None, ...]
):
) -> typing.Tuple[
typing.Tuple[str | None, ...],
tuple[dict[str, np.ndarray | float | tuple[float | int, float | int]]] | None,
]:
"""
This method will decode the **QR** codes in the given image and return the decoded strings
(or None, if any of them was detected but not decoded).
Expand All @@ -227,7 +225,7 @@ def detect_and_decode(
if return_detections:
return decoded_qrs, detections
else:
return decoded_qrs
return decoded_qrs, None

def get_detection_result_from_polygon(
self,
Expand Down Expand Up @@ -334,7 +332,7 @@ def _decode_qr_zbar(
results=decodedQR,
)
# For QRs with black background and white foreground, try to invert the image
inverted_image: NDArray[np.generic] = 255 - rescaled_image
inverted_image = np.array(255) - rescaled_image
decodedQR = decodeQR(inverted_image, symbols=[ZBarSymbol.QRCODE])
if len(decodedQR) > 0:
return wrap(
Expand Down

0 comments on commit cf081bf

Please sign in to comment.