Skip to content

Commit

Permalink
fix: [qrcode extractor] fix catch cv2 exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Oct 3, 2024
1 parent ef93254 commit 970a169
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions bin/modules/QrCodeReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ def extract_qrcode(self, path):

if not contents:
detector = cv2.QRCodeDetector()
qr, decodeds, qarray, _ = detector.detectAndDecodeMulti(image)
if qr:
qr_codes = True
for d in decodeds:
if d:
contents.append(d)
data_qr, box, qrcode_image = detector.detectAndDecode(image)
if data_qr:
contents.append(data_qr)
qr_codes = True
try:
qr, decodeds, qarray, _ = detector.detectAndDecodeMulti(image)
if qr:
qr_codes = True
for d in decodeds:
if d:
contents.append(d)
except cv2.error as e:
self.logger.error(f'{e}: {self.obj.get_global_id()}')
try:
data_qr, box, qrcode_image = detector.detectAndDecode(image)
if data_qr:
contents.append(data_qr)
qr_codes = True
except cv2.error as e:
self.logger.error(f'{e}: {self.obj.get_global_id()}')

if qr_codes and not contents:
# # # # 0.5s per image
Expand Down

0 comments on commit 970a169

Please sign in to comment.