Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checker: Fields Extraction Support #6

Closed
Arg0s1080 opened this issue Apr 6, 2019 · 0 comments
Closed

Checker: Fields Extraction Support #6

Arg0s1080 opened this issue Apr 6, 2019 · 0 comments
Assignees
Labels
CHECKER MRZ.CHECKER Issues enhancement New feature or request

Comments

@Arg0s1080
Copy link
Owner

Arg0s1080 commented Apr 6, 2019

Several people have asked me by email how they get the fields (names, surnames, nationality, type of document, etc. strings) without access to a protected member of the class. Therefore I have created the fields() method for td1, td2, td3, mrva and mrvb.

For example:

from mrz.checker.td1 import TD1CodeChecker, get_country

mrz_td1 = ("IDD<<ID98754015<<<<<<<<<<<<<<<\n" 
           "8205122M1906224D<<<<<<<<<<<<<6\n" 
           "SCHNEIDER<WEBER<<NORBERT<<<<<<")

td1_check = TD1CodeChecker(mrz_td1)

To get identifiers, country, and date of birth....

Before (accessing to protected members of the class):

print(td1_check._identifier)
print(td1_check._country)
print(td1_check._birth_date)
Output:
SCHNEIDER<WEBER<<NORBERT<<<<<<
D<<
820512

Now:

fields() method returns a namedtuple with all fields strings:

td1_check.fields()
Returns:
fields(document_type='ID', country='D', document_number='ID9875401', document_number_hash='5', optional_data='', birth_date='820512', birth_date_hash='2', sex='M', expiry_date='190622', expiry_date_hash='4', nationality='D', optional_data_2='', final_hash='6', surname='SCHNEIDER WEBER', name='NORBERT')

So, to get given names, surnames and birth date:

fields = td1_check.fields()
print(fields.surname)
print(fields.name)
print(get_country(fields.country))
print(fields.birth_date)
Output:
SCHNEIDER WEBER
NORBERT
Germany
820512

Available fields

id cards and others td1's:

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash, document_number_hash,
 optional_data_2 and final_hash

td2's:

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash, document_number_hash
and final_hash

Passports and other td3's:

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash, document_number_hash,
optional_data_hash and final_hash

Any Visa (mrva & mrvb)

surname, name, country, nationality, birth_date, expiry_date, sex, document_type,
document_number, optional_data, birth_date_hash, expiry_date_hash and document_number_hash
@Arg0s1080 Arg0s1080 added the enhancement New feature or request label Apr 6, 2019
@Arg0s1080 Arg0s1080 self-assigned this Apr 6, 2019
@Arg0s1080 Arg0s1080 added the CHECKER MRZ.CHECKER Issues label Apr 6, 2019
@Arg0s1080 Arg0s1080 pinned this issue Apr 6, 2019
Arg0s1080 added a commit that referenced this issue Apr 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CHECKER MRZ.CHECKER Issues enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant