From 805412866476b7690e75a2c30e792edf9946ae96 Mon Sep 17 00:00:00 2001 From: gruvdev Date: Mon, 9 Aug 2021 15:05:49 -0700 Subject: [PATCH] limit decode() by type QRCODE --- fishy/engine/fullautofisher/qr_detection.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fishy/engine/fullautofisher/qr_detection.py b/fishy/engine/fullautofisher/qr_detection.py index 2c969e4..b31baa5 100644 --- a/fishy/engine/fullautofisher/qr_detection.py +++ b/fishy/engine/fullautofisher/qr_detection.py @@ -4,7 +4,7 @@ from datetime import datetime import cv2 import numpy as np -from pyzbar.pyzbar import decode +from pyzbar.pyzbar import decode, ZBarSymbol from fishy.helper.helper import get_documents @@ -28,7 +28,8 @@ def get_qr_location(og_img): mask = np.zeros_like(img) cv2.drawContours(mask, cnt, i, 255, -1) x, y, w, h = cv2.boundingRect(cnt[i]) - qr_result = decode(og_img[y:h + y, x:w + x]) + qr_result = decode(og_img[y:h + y, x:w + x], + symbols=[ZBarSymbol.QRCODE]) if qr_result: valid_crops.append(((x, y, x + w, y + h), area)) @@ -38,7 +39,7 @@ def get_qr_location(og_img): # noinspection PyBroadException def get_values_from_image(img): try: - for qr in decode(img): + for qr in decode(img, symbols=[ZBarSymbol.QRCODE]): vals = qr.data.decode('utf-8').split(",") return float(vals[0]), float(vals[1]), float(vals[2])