Skip to content

Commit

Permalink
fix for finalchecksum
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakumar-mahalingam committed Jan 14, 2025
1 parent a43ceaf commit 1a5b18b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions fastmrz/fastmrz.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _process_image(self, image_path):
image = cv2.resize(image, (256, 256), interpolation=cv2.INTER_NEAREST)
image = np.asarray(np.float32(image / 255))

if len(image.shape) > 3:
if len(image.shape) >= 3:
image = image[:, :, :3]
image = np.reshape(image, (1, 256, 256, 3))

Expand Down Expand Up @@ -77,9 +77,9 @@ def _cleanse_roi(self, mrz_text):

def _get_final_checkdigit(self, input_string, input_type):
if input_type == "TD3":
return self._get_checkdigit(input_string[:10] + input_string[13:20] + input_string[21:43])
return self._get_checkdigit(input_string[1][:10] + input_string[1][13:20] + input_string[1][21:43])
elif input_type == "TD2":
return self._get_checkdigit(input_string[:10] + input_string[13:20] + input_string[21:35])
return self._get_checkdigit(input_string[1][:10] + input_string[1][13:20] + input_string[1][21:35])
else:
return self._get_checkdigit(input_string[0][5:] + input_string[1][:7] + input_string[1][8:15]
+ input_string[1][18:29])
Expand Down
4 changes: 2 additions & 2 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def test_cleanse_roi(self):
def test_get_final_check_digit(self):
input_string = "I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<\nD231458907UTO7408122F1204159<<<<<<<6"
input_type = "TD2"
final_check_digit = fast_mrz._get_final_check_digit(input_string, input_type)
final_check_digit = fast_mrz._get_final_checkdigit(input_string, input_type)
self.assertIsInstance(final_check_digit, str)

def test_get_check_digit(self):
input_string = "I<UTOERIKSSON<<ANNA< MARIA<<<<< <<<<<<\nD231458907UTO7408122F1204159<<<<<<<6\n\n"
check_digit = fast_mrz._get_check_digit(input_string)
check_digit = fast_mrz._get_checkdigit(input_string)
self.assertIsInstance(check_digit, str)

def test_format_date(self):
Expand Down

0 comments on commit 1a5b18b

Please sign in to comment.