Skip to content

Commit 2b10467

Browse files
Merge pull request #10 from sivakumar-mahalingam/dev
Dev _get_roi
2 parents 70c5b86 + 7357b95 commit 2b10467

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ Now, based on the example of a national passport, let us take a closer look at t
137137
- [ ] Support pdf as input
138138
- [x] Function to return mrz text as output
139139
- [ ] Bulk process
140-
- [ ] Image Enhancement
140+
- [ ] Add function parameter - Image Enhancement
141+
- [ ] Add function parameter - Image Enhancement Model
141142
- [ ] Train Tesseract model with additional data
142143
- [x] Add function parameter - include_checkdigit
143144
- [ ] Add function - get_mrz_image

fastmrz/fastmrz.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@ def _get_roi(self, output_data, image_path):
5656
y_end = min(image.shape[0], y + h + padding)
5757

5858
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)
6060

6161
# Apply additional preprocessing to ROI before OCR
6262
roi_gray = cv2.cvtColor(roi_arr, cv2.COLOR_BGR2GRAY)
6363

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]
6869

6970
# Configure pytesseract parameters for better MRZ recognition
7071
custom_config = r'--oem 3 --psm 6'

0 commit comments

Comments
 (0)