@@ -56,15 +56,16 @@ def _get_roi(self, output_data, image_path):
56
56
y_end = min (image .shape [0 ], y + h + padding )
57
57
58
58
roi_arr = image [y_start :y_end , x_start :x_end ].copy ()
59
- roi_arr = cv2 .convertScaleAbs (roi_arr , alpha = 1.25 , beta = - 50 )
59
+ # roi_arr = cv2.convertScaleAbs(roi_arr, alpha=1.25, beta=-50)
60
60
61
61
# Apply additional preprocessing to ROI before OCR
62
62
roi_gray = cv2 .cvtColor (roi_arr , cv2 .COLOR_BGR2GRAY )
63
63
64
- kernel = np .ones ((1 ,1 ), np .uint8 )
65
- roi_dilate = cv2 .dilate (roi_gray , kernel , iterations = 1 )
66
- roi_gaussianblur = cv2 .GaussianBlur (roi_dilate , (5 ,5 ), 0 )
67
- roi_threshold = cv2 .threshold (roi_gaussianblur , 0 , 255 , cv2 .THRESH_BINARY + cv2 .THRESH_OTSU )[1 ]
64
+ # kernel = np.ones((1, 1), np.uint8)
65
+ # roi_dilate = cv2.dilate(roi_gray, kernel, iterations=1)
66
+ # roi_dilate = cv2.erode(roi_dilate, kernel, iterations=1)
67
+
68
+ roi_threshold = cv2 .threshold (roi_gray , 0 , 255 , cv2 .THRESH_BINARY + cv2 .THRESH_OTSU )[1 ]
68
69
69
70
# Configure pytesseract parameters for better MRZ recognition
70
71
custom_config = r'--oem 3 --psm 6'
0 commit comments