护照、签证、身份证和其他旅行证件的机器可读区域生成器和检查器

mrz的Python项目详细描述


说明:

公务旅行机读区域生成器和检查器 文件尺寸1、2、3、MRVA和MRVB(护照、签证、国民身份证 卡片和其他旅行证件)

mrz发生器和mrz检查器按照国际民用 航空组织规范(国际民航组织9303):

公务旅行证件现场发放:

image

图像

使用生成器:

TD1(身份证):

Params:                      Case insensitive

    document_type    (str):  The first letter shall be 'I', 'A' or 'C'
    country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)
    document_number  (str):  Document number
    birth_date       (str):  YYMMDD
    sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined 'X'
    expiry_date      (str):  YYMMDD
    nationality      (str):  3 letters code (ISO 3166-1) or country name (in English)
    surname          (str):  Holder primary identifier(s). This field will be transliterated
    given_names      (str):  Holder secondary identifier(s). This field will be transliterated
    optional_data1   (str):  Optional personal data at the discretion of the issuing State.
                             Non-mandatory field. Empty string by default
    optional_data2   (str):  Optional personal data at the discretion of the issuing State.
                             Non-mandatory field. Empty string by default
    transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default
    force           (bool):  Disables checks for country, nationality and document_type fields.
                             Allows to use 3-letter-codes not included in the countries dictionary
                             and to use document_type codes without restrictions.

TD2

Params:                      Case insensitive

    document_type    (str):  The first letter shall be 'I', 'A' or 'C'
    country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)
    surname          (str):  Holder primary identifier(s). This field will be transliterated.
    given_names      (str):  Holder secondary identifier(s). This field will be transliterated.
    document_number  (str):  Document number.
    nationality      (str):  3 letters code (ISO 3166-1) or country name
    birth_date       (str):  YYMMDD
    sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined 'X'
    expiry_date      (str):  YYMMDD
    optional_data    (str):  Optional personal data at the discretion of the issuing State.
                             Non-mandatory field. Empty string by default
    transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default
    force           (bool):  Disables checks for country, nationality and document_type fields.
                             Allows to use 3-letter-codes not included in the countries dictionary
                             and to use document_type codes without restrictions.

TD3(护照)

Params:                      Case insensitive

    document_type    (str):  Normally 'P' for passport
    country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)
    surname          (str):  Primary identifier(s)
    given_names      (str):  Secondary identifier(s)
    passport_number  (str):  Passport number
    nationality      (str):  3 letters code (ISO 3166-1) or country name
    birth_date       (str):  YYMMDD
    sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined 'X'
    expiry_date      (str):  YYMMDD
    optional data    (str):  Personal number. In some countries non-mandatory field. Empty string by default
    transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default
    force           (bool):  Disables checks for country, nationality and document_type fields.
                             Allows to use 3-letter-codes not included in the countries dictionary
                             and to use document_type codes without restrictions.

MRVA(A类签证)

Params:                      Case insensitive

    document_type    (str):  The First letter must be 'V'
    country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)
    surname          (str):  Primary identifier(s)
    given_names      (str):  Secondary identifier(s)
    passport_number  (str):  Passport number
    nationality      (str):  3 letters code (ISO 3166-1) or country name
    birth_date       (str):  YYMMDD
    sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined 'X'
    expiry_date      (str):  YYMMDD
    optional_data    (str):  Optional personal data at the discretion of the issuing State.
                             Non-mandatory field. Empty string by default.
    transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default
    force           (bool):  Disables checks for country, nationality and document_type fields.
                             Allows to use 3-letter-codes not included in the countries dictionary
                             and to use document_type codes without restrictions.

MRVB(B类签证)

Params:                      Case insensitive

    document_type    (str):  The First letter must be 'V'
    country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)
    surname          (str):  Primary identifier(s)
    given_names      (str):  Secondary identifier(s)
    passport_number  (str):  Passport number
    nationality      (str):  3 letters code (ISO 3166-1) or country name
    birth_date       (str):  YYMMDD
    sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined 'X'
    expiry_date      (str):  YYMMDD
    optional_data    (str):  Optional personal data at the discretion of the issuing State.
                             Non-mandatory field. Empty string by default.
    transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default
    force           (bool):  Disables checks for country, nationality and document_type fields.
                             Allows to use 3-letter-codes not included in the countries dictionary
                             and to use document_type codes without restrictions.

护照生成器示例(ICAO9303样本):

image

图像

TD3代码生成器->;str:

frommrz.generator.td3importTD3CodeGeneratorcode=TD3CodeGenerator("P","UTO","Eriksson","Anna María","L898902C3","UTO","740812","F","120415","ZE184226B")print(code)

输出:

P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L898902C36UTO7408122F1204159ZE184226B<<<<<10

注意:参见mrz.generator examples folder中的其他用法

使用情况检查器:

TD1(身份证):

Params:

    mrz_string        (str):  MRZ string of TD1. Must be 90 uppercase characters long (3 lines)
    check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the
                              document is not expired and that expiry_date is not greater than 10 years
    compute_warnings (bool):  If it's set True, warnings compute as False

TD2:

Params:

    mrz_string        (str):  MRZ string of TD2. Must be 72 characters long (uppercase) (2 lines)
    check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the
                              document is not expired and that expiry_date is not greater than 10 years
    compute_warnings (bool):  If it's set True, warnings compute as False

TD3(护照):

Params:

    mrz_string        (str):  MRZ string of TD3. Must be 88 characters long (uppercase) (2 lines)
    check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the
                              document is not expired and that expiry_date is not greater than 10 years
    compute_warnings (bool):  If it's set True, warnings compute as False

磁共振血管成像:

Params:

    mrz_string        (str):  MRZ string of Visas type A. Must be 88 characters long (uppercase) (2 lines)
    check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the
                              document is not expired and that expiry_date is not greater than 10 years
    compute_warnings (bool):  If it's set True, warnings compute as False

mrvb:

Params:

    mrz_string        (str):  MRZ string of Visas type B. Must be 72 characters long (uppercase) (2 lines)
    check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the
                              document is not expired and that expiry_date is not greater than 10 years
    compute_warnings (bool):  If it's set True, warnings compute as False

身份证检查器示例
image

图像

td1代码检查器->;bool

frommrz.checker.td1importTD1CodeCheckerresult=bool(TD1CodeChecker("I<SWE59000002<8198703142391<<<\n""8703145M1701027SWE<<<<<<<<<<<8\n""SPECIMEN<<SVEN<<<<<<<<<<<<<<<<"))print(result)

输出

True

注意:参见mrz.checker examples folder中的其他用法

字段提取示例(对TD1、TD2、TD3和签证有效)

frommrz.checker.td1importTD1CodeChecker,get_countrytd1_check=TD1CodeChecker("IDLIEID98754015<<<<<<<<<<<<<<<\n""8205122M1906224LIE<<<<<<<<<<<6\n""OSPELT<BECK<<MARISA<<<<<<<<<<<")fields=td1_check.fields()print(fields.name,fields.surname)print(get_country(fields.country))

输出

MARISA OSPELT BECK
Liechtenstein

注意:参见mrz.checker examples folderthis issue中的其他用法

安装:

通过pip(可能不是最新版本):

sudo -H pip install mrz

克隆此回购协议(可能无法正常工作):

git clone https://github.com/Arg0s1080/mrz.git
cd mrz
sudo python3 setup.py install

特点:

  • [X]特殊拉丁字符的音译(acutes,tildes, 分封、坟墓、回旋曲等)
  • [x]阿拉伯字符音译
  • [X]增加了几种西里尔语变体:塞尔维亚语、马其顿语, 白俄罗斯语、乌克兰语和保加利亚语
  • 现代希腊语音译(实验)
  • [X]现代希伯来语(无元音)音译(实验性)
  • [X]根据其英文名称生成国家代码(例如: “荷兰”->;“荷兰”)
  • [X]名称截断检测
  • [X]检查程序中的错误报告、警告报告和完整报告。
  • [X]警告计算为错误的可能性 检查程序中的compute_warnings关键字。
  • [x]禁用国家代码、国籍和 文件类型,允许使用 国家词典和使用不带 发电机堵塞
  • [X]在checker中添加了一段时间的新支票。
  • [X]签证支持
  • [X]在checker中提取字段(姓名、姓氏、国家、性别等) (版本0.5.0)

待办事项:

  • []生成器中的自动名称截断
  • []禁用国家代码、国籍检查的可能性, checker中的文档类型和其他字段。
  • []添加日志记录

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
安卓在Java中将字符串连接到“集合”   java在自己的模块上为每个模块运行spring boot单元测试   java如何在不调用join或get的情况下将Collection<CompletableFuture<X>>转换为CompletableFuture<Collection<X>>?   java折叠工具栏布局在滚动时不折叠   java JPA组合主键/外键映射   java如何使用Apache Velocity模板生成自动关闭的XML元素(如果值为null或空)   Java在2D数组中存储输入文件中的数字   java JPA:如何建模映射<String,设置<Object>>(嵌套集合)   用于使用Java查找字符串的windows MapReduce   java将多个方法组合成一个通用方法   java Micronaut嵌套Json输入验证   java在方法中使用类变量   jar构建Java应用程序   JDBC上的java缓存数据   java Play 2.5。x没有绑定到此线程的EntityManager   java密码。getBlockSize()返回128位,即使使用256位密钥也是如此   java如何在Android上显示可用通知声音列表   Java JNI调用的数组开销   java在创建映射和基于特定键获取值时执行HashMap、LinkedHashMap和ConcurrentHashMap的成本