Merge pull request #92 from wabkia/zbar-qr-type-limit

This commit is contained in:
Adam Saudagar 2021-08-10 10:45:33 +05:30 committed by GitHub
commit 4167ffcfac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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])