Spaces:
Build error
Build error
import cv2 | |
from readmrz import MrzDetector | |
from constants.paths import EXTRACTED_MRZ_PATH | |
def MRZ_detector(img_path): | |
try: | |
mrz_found = False | |
gray = [] | |
detector = MrzDetector() | |
image = detector.read(img_path) | |
cropped = detector.crop_area(image) | |
gray = cv2.cvtColor(cropped, cv2.COLOR_BGR2GRAY) | |
cv2.imshow('Image', cropped) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() | |
if len(cropped) != 13: | |
mrz_found = True | |
cv2.imwrite(EXTRACTED_MRZ_PATH, gray) | |
print("MRZ FOUND") | |
# cv2.imshow('Image', cropped) | |
# cv2.waitKey(0) | |
# cv2.destroyAllWindows() | |
return mrz_found, gray | |
except Exception as e: | |
print("[Exception in MRZ_detector] : ", str(e)) | |
return mrz_found, gray |