-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19ff25d
commit acac11b
Showing
4 changed files
with
118 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from Laghima import Laghima | ||
from fastmrz import FastMRZ | ||
import os | ||
|
||
laghima = Laghima() | ||
# fast_mrz = FastMRZ(tesseract_path=r'/opt/homebrew/Cellar/tesseract/5.3.4_1/bin/tesseract') | ||
# fast_mrz = FastMRZ(tesseract_path=r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe') | ||
|
||
# Need to add other type of documents in /data | ||
passport_mrz = laghima.read_mrz(os.path.abspath('../data/passport_uk.jpg')) | ||
fast_mrz = FastMRZ() | ||
passport_mrz = fast_mrz.read_mrz(os.path.abspath('../data/passport_uk.jpg')) | ||
print(passport_mrz) | ||
|
||
# Add README testing badge. Ref, https://github.com/mingrammer/diagrams/blob/master/README.md?plain=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import numpy as np | ||
import os | ||
from fastmrz import FastMRZ | ||
|
||
fast_mrz = FastMRZ() | ||
|
||
|
||
# Test cases for _process_image function | ||
def test_process_image(): | ||
image_path = os.path.abspath('../data/td3.jpg') | ||
processed_image = fast_mrz._process_image(image_path) | ||
assert isinstance(processed_image, np.ndarray) | ||
assert processed_image.shape == (1, 256, 256, 3) | ||
|
||
|
||
# Test cases for _get_roi function | ||
def test_get_roi(): | ||
output_data = np.random.rand(1, 256, 256, 1) | ||
image_path = os.path.abspath('../data/td3.jpg') | ||
roi = fast_mrz._get_roi(output_data, image_path) | ||
assert isinstance(roi, str) | ||
|
||
|
||
# Test cases for _cleanse_roi function | ||
def test_cleanse_roi(): | ||
raw_text = "P<UTOERIKSSON<<ANNA<MARIA<<< <<<<<<<<< <<<<<<<\n\nL898902C36UTO7408122F1204159ZE184226B<<<<<10\n" | ||
cleansed_text = fast_mrz._cleanse_roi(raw_text) | ||
assert isinstance(cleansed_text, str) | ||
|
||
|
||
# Test cases for _get_final_check_digit function | ||
def test_get_final_check_digit(): | ||
input_string = "'I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<\nD231458907UTO7408122F1204159<<<<<<<6" | ||
input_type = "TD2" | ||
final_check_digit = fast_mrz._get_final_check_digit(input_string, input_type) | ||
assert isinstance(final_check_digit, str) | ||
|
||
|
||
# Test cases for _get_check_digit function | ||
def test_get_check_digit(): | ||
input_string = "'I<UTOERIKSSON<<ANNA< MARIA<<<<< <<<<<<\nD231458907UTO7408122F1204159<<<<<<<6\n\n" | ||
check_digit = fast_mrz._get_check_digit(input_string) | ||
assert isinstance(check_digit, str) | ||
|
||
|
||
# Test cases for _format_date function | ||
def test_format_date(): | ||
input_date = "220101" | ||
formatted_date = fast_mrz._format_date(input_date) | ||
assert isinstance(formatted_date, str) | ||
|
||
|
||
# Test cases for read_raw_mrz function | ||
def test_read_raw_mrz(): | ||
image_path = os.path.abspath('../data/td2.jpg') | ||
raw_mrz = fast_mrz.read_raw_mrz(image_path) | ||
assert isinstance(raw_mrz, str) | ||
|
||
|
||
# Test cases for read_mrz function | ||
def test_read_mrz(): | ||
image_path = os.path.abspath('../data/td3.jpg') | ||
mrz_data = fast_mrz.read_mrz(image_path) | ||
assert isinstance(mrz_data, dict) | ||
assert 'status' in mrz_data.keys() |