[go: up one dir, main page]

CN111144400B - Identification method, device, terminal equipment and storage medium for ID card information - Google Patents

Identification method, device, terminal equipment and storage medium for ID card information Download PDF

Info

Publication number
CN111144400B
CN111144400B CN201811317603.9A CN201811317603A CN111144400B CN 111144400 B CN111144400 B CN 111144400B CN 201811317603 A CN201811317603 A CN 201811317603A CN 111144400 B CN111144400 B CN 111144400B
Authority
CN
China
Prior art keywords
text
information
text box
boxes
identity card
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811317603.9A
Other languages
Chinese (zh)
Other versions
CN111144400A (en
Inventor
张樱
师军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201811317603.9A priority Critical patent/CN111144400B/en
Publication of CN111144400A publication Critical patent/CN111144400A/en
Application granted granted Critical
Publication of CN111144400B publication Critical patent/CN111144400B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V20/00Scenes; Scene-specific elements
    • G06V20/60Type of objects
    • G06V20/62Text, e.g. of license plates, overlay texts or captions on TV images
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/24Aligning, centring, orientation detection or correction of the image
    • G06V10/245Aligning, centring, orientation detection or correction of the image by locating a pattern; Special marks for positioning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition
    • G06V30/14Image acquisition
    • G06V30/146Aligning or centring of the image pick-up or image-field
    • G06V30/1475Inclination or skew detection or correction of characters or of image to be recognised
    • G06V30/1478Inclination or skew detection or correction of characters or of image to be recognised of characters or characters lines
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Character Input (AREA)

Abstract

The invention provides an identification method, a device, terminal equipment and a storage medium of identity card information, and relates to the technical field of intelligent identification, wherein the method comprises the following steps: acquiring an identity card image of identity card information to be identified; performing text line detection on the identity card image to obtain a plurality of text boxes; acquiring position information of a text box in an identity card image; performing text recognition on the text box to obtain text information corresponding to the text box; determining text information with a corresponding relation according to the position information and the text information of the text box; and determining the identity card information corresponding to the identity card image according to the text information with the corresponding relation. The invention can effectively improve the identification accuracy of the identity card information.

Description

身份证信息的识别方法、装置、终端设备及存储介质Identification method, device, terminal equipment and storage medium for ID card information

技术领域Technical field

本发明涉及智能识别技术领域,尤其是涉及一种身份证信息的识别方法、装置、终端设备及存储介质。The present invention relates to the field of intelligent identification technology, and in particular to an identification method, device, terminal equipment and storage medium for ID card information.

背景技术Background technique

目前很多场合都需要识别身份证信息,以确定身份证持有者的身份。现有技术中大多是通过身份证读取器等硬件设备直接读取身份证卡片上的身份信息。At present, many occasions require identification of ID card information to determine the identity of the ID card holder. In the existing technology, most of the identity information on the ID card is directly read through hardware devices such as ID card readers.

随着技术的发展,身份证图像识别技术逐渐兴起,其主要是从身份证图像上的文字进行识别和提取,从而提取身份证信息,例如姓名、性别、出生日期、身份证号码、住址等。但由于身份证上的文字信息较多,提取出的文字信息较为零散、身份证图像上还可能添加有水印等其他文字,身份证图像很可能是倾斜的等多种原因,因此,有可能提取到错误的身份证信息,身份证信息的识别准确率不高。举例而言,有可能在进行文字识别时,得到错误的信息对应关系,诸如,在身份证图像为倾斜时可能将“姓名”和“男”认为一组,从而得出姓名是“男”的错误结论。With the development of technology, ID card image recognition technology has gradually emerged. It mainly recognizes and extracts text from ID card images, thereby extracting ID card information, such as name, gender, date of birth, ID card number, address, etc. However, due to the large amount of text information on the ID card, the extracted text information is relatively scattered, other text such as watermarks may be added to the ID card image, and the ID card image is likely to be tilted. Therefore, it is possible to extract wrong ID card information, and the recognition accuracy of ID card information is not high. For example, it is possible to obtain an incorrect information correspondence when performing text recognition. For example, when the ID card image is tilted, "name" and "male" may be considered as a group, thereby drawing the wrong conclusion that the name is "male".

发明内容Contents of the invention

有鉴于此,本发明的目的在于提供一种身份证信息的识别方法、装置、终端设备及存储介质,能够有效提升身份证信息的识别准确率。In view of this, the purpose of the present invention is to provide a method, device, terminal equipment and storage medium for identifying ID card information, which can effectively improve the identification accuracy of ID card information.

第一方面,本发明实施例提供了一种身份证信息的识别方法,包括:In a first aspect, embodiments of the present invention provide a method for identifying ID card information, including:

获取待识别身份证信息的身份证图像;对身份证图像进行文本行检测,得到多个文本框;获取身份证图像中文本框的位置信息;对文本框进行文字识别,得到文本框对应的文字信息;根据文本框的位置信息和文字信息,确定具有对应关系的文字信息;根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。Obtain an ID card image of the ID card information to be identified; perform text line detection on the ID card image to obtain multiple text boxes; obtain position information of the text boxes in the ID card image; perform text recognition on the text boxes to obtain text information corresponding to the text boxes; determine text information with a corresponding relationship based on the position information and text information of the text boxes; determine the ID card information corresponding to the ID card image based on the text information with a corresponding relationship.

结合第一方面,本发明实施例提供了第一方面的第一种可能的实施方式,其中,上述对身份证图像进行文本行检测,得到多个文本框的步骤,包括:获取身份证图像的顶点坐标,根据身份证图像的顶点坐标判断身份证图像是否倾斜;如果是,调正身份证图像;对调正后的身份证图像进行文本行检测,得到多个文本框。In conjunction with the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, wherein the above-mentioned step of detecting text lines on the ID card image to obtain multiple text boxes includes: obtaining the ID card image Based on the vertex coordinates of the ID card image, determine whether the ID card image is tilted; if so, correct the ID card image; perform text line detection on the adjusted ID card image to obtain multiple text boxes.

结合第一方面,本发明实施例提供了第一方面的第二种可能的实施方式,其中,上述对身份证图像进行文本行检测,得到多个文本框的步骤,包括:通过CTPN网络模型对身份证图像进行文本行检测,得到多个文本框。Combined with the first aspect, embodiments of the present invention provide a second possible implementation manner of the first aspect, in which the above-mentioned step of detecting text lines on the ID card image to obtain multiple text boxes includes: using a CTPN network model to The ID card image is subjected to text line detection and multiple text boxes are obtained.

结合第一方面,本发明实施例提供了第一方面的第三种可能的实施方式,其中,上述获取身份证图像中文本框的位置信息的步骤,包括:获取身份证图像中文本框的顶点坐标;根据文本框的顶点坐标,判断文本框是否倾斜;如果是,调正文本框;获取调正后的文本框的位置信息。In conjunction with the first aspect, embodiments of the present invention provide a third possible implementation of the first aspect, wherein the above-mentioned step of obtaining the position information of the text box in the ID card image includes: obtaining the vertices of the text box in the ID card image. coordinates; based on the vertex coordinates of the text box, determine whether the text box is tilted; if so, adjust the text box; obtain the position information of the adjusted text box.

结合第一方面,本发明实施例提供了第一方面的第四种可能的实施方式,其中,上述对文本框进行文字识别,得到文本框对应的文字信息的步骤,包括:通过CRNN网络模型对文本框进行文字识别,得到文本框对应的文字信息。Combined with the first aspect, embodiments of the present invention provide a fourth possible implementation manner of the first aspect, wherein the above step of performing text recognition on a text box and obtaining text information corresponding to the text box includes: using a CRNN network model to The text box performs text recognition and obtains the text information corresponding to the text box.

结合第一方面到第一方面的第四种可能的实施方式任一项,本发明实施例提供了第一方面的第五种可能的实施方式,其中,上述根据文本框的位置信息和文字信息,确定具有对应关系的文字信息的步骤,包括:根据文本框的位置信息,确定同行的文本框;根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框;根据具有对应关系的文本框,以及文本框的文字信息,确定具有对应关系的文字信息。In combination with any one of the first aspect to the fourth possible implementation manner of the first aspect, embodiments of the present invention provide a fifth possible implementation manner of the first aspect, wherein the above-mentioned position information and text information based on the text box , the steps of determining text information with corresponding relationships include: determining text boxes of the same peer based on the position information of the text boxes; determining text boxes with corresponding relationships among the text boxes of the same peers based on the location information of the text boxes of the same peers; The corresponding text boxes and the text information of the text boxes determine the text information with the corresponding relationship.

结合第一方面的第五种可能的实施方式,本发明实施例提供了第一方面的第六种可能的实施方式,其中,上述文本框的位置信息包括文本框的起始点坐标,起始点坐标包括起始横坐标和起始纵坐标;根据文本框的位置信息,确定同行的文本框的步骤,包括:将起始点纵坐标相差预设第一阈值内的文本框确定为同行的文本框;根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框的步骤,包括:将同行的文本框中起始点横坐标相差预设第二阈值内的文本框确定为同行的文本框中具有对应关系的文本框。In conjunction with the fifth possible implementation manner of the first aspect, embodiments of the present invention provide a sixth possible implementation manner of the first aspect, wherein the position information of the text box includes the starting point coordinates of the text box, the starting point coordinates It includes a starting abscissa and a starting ordinate; the step of determining the text boxes of the same row according to the position information of the text box includes: determining the text boxes whose ordinates differ from the starting point within a preset first threshold as the text boxes of the same row; According to the position information of the text boxes of the same peer, the step of determining the text boxes with corresponding relationships in the text boxes of the same peer includes: determining the text boxes of the same peer that are within a preset second threshold of the starting point abscissa difference of the text boxes of the same peer. Text boxes with corresponding relationships within text boxes.

结合第一方面的五种可能的实施方式,本发明实施例提供了第一方面的第七种可能的实施方式,其中,上述文本框的位置信息包括文本框的纵坐标取值范围和横坐标取值范围;根据文本框的位置信息,确定同行的文本框的步骤,包括:将纵坐标取值范围至少具有第一重叠长度的两个文本框确定为同行的文本框;根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框的步骤,包括:根据同行的文本框的横坐标取值范围,确定文本框的横坐标最小值;将同行的文本框中横坐标最小值相差预设第三阈值内的文本框确定为同行的文本框中具有对应关系的文本框。In combination with the five possible implementations of the first aspect, embodiments of the present invention provide a seventh possible implementation of the first aspect, wherein the position information of the text box includes the ordinate value range and the abscissa of the text box. The value range; the step of determining the text boxes of the same row according to the position information of the text boxes includes: determining two text boxes whose ordinate value range has at least the first overlapping length as the text boxes of the same row; according to the text boxes of the same row The steps of determining the corresponding text boxes in the text boxes of the same row include: determining the minimum value of the abscissa coordinate of the text box according to the value range of the abscissa coordinate of the text box of the same row; The text boxes whose minimum values differ within the preset third threshold are determined to be text boxes that have a corresponding relationship among the text boxes of the same row.

结合第一方面的五种可能的实施方式,本发明实施例提供了第一方面的第八种可能的实施方式,其中,上述根据具有对应关系的文本框,以及文本框的文字信息,确定具有对应关系的文字信息的步骤,包括:根据具有对应关系的文本框,以及文本框的文字信息,检查文本框的对应关系是否正确;将具有正确对应关系的文本框的文字信息确定为具有对应关系的文字信息。In combination with the five possible implementations of the first aspect, embodiments of the present invention provide an eighth possible implementation of the first aspect, wherein, based on the text boxes with corresponding relationships and the text information of the text boxes, it is determined that the The steps of corresponding text information include: checking whether the corresponding relationship of the text box is correct based on the text box with the corresponding relationship and the text information of the text box; determining the text information of the text box with the correct corresponding relationship as having the corresponding relationship text information.

结合第一方面,本发明实施例提供了第一方面的第九种可能的实施方式,其中,上述根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息的步骤,包括:基于具有对应关系的文字信息,确定具有对应关系的文字信息的信息类别;信息类别包括姓名类别、性别类别、民族类别、出生日期类别、住址类别和身份证号码类别中的一种或多种;根据信息类别,确定具有对应关系的文字信息中的关键字词以及与关键字词具有对应关系的文字;其中,关键字词包括姓名、性别、民族、出生、年、月、日、住址和公民身份证号码中的一种或多种;将与关键字词具有对应关系的文字确定为身份证信息。In combination with the first aspect, an embodiment of the present invention provides a ninth possible implementation of the first aspect, wherein the step of determining the identity card information corresponding to the identity card image based on the text information with a corresponding relationship includes: determining the information category of the text information with a corresponding relationship based on the text information with a corresponding relationship; the information category includes one or more of the name category, gender category, ethnicity category, date of birth category, address category and identity card number category; according to the information category, determining the keyword words in the text information with a corresponding relationship and the text with a corresponding relationship with the keyword words; wherein the keyword words include one or more of the name, gender, ethnicity, birth, year, month, day, address and citizen identity card number; determining the text with a corresponding relationship with the keyword words as the identity card information.

结合第一方面的第九种可能的实施方式,本发明实施例提供了第一方面的第十种可能的实施方式,上述方法还包括:根据信息类别,检查身份证信息是否正确;如果否,发起报错提示。In combination with the ninth possible implementation manner of the first aspect, embodiments of the present invention provide a tenth possible implementation manner of the first aspect. The above method further includes: checking whether the ID card information is correct according to the information category; if not, Initiate an error message.

结合第一方面的第十种可能的实施方式,本发明实施例提供了第一方面的第十一种可能的实施方式,其中,上述根据信息类别,检查身份证信息是否正确的步骤,包括:采用身份证信息中身份证号码类别对应的信息检查身份证信息中出生日期类别对应的信息和身份证信息中性别类别对应的信息是否正确;和/或,检查身份证信息中性别类别对应的信息是否为预设性别字词之一,其中,预设性别字词包括男或女;和/或,检查身份证信息中民族类别对应的信息是否为预设民族字词之一,其中,预设民族字词包括合法的民族字词;和/或,检查身份证信息中出生日期类别对应的信息是否为预设数字之一;其中,预设数字为合法的日期数字。In combination with the tenth possible implementation of the first aspect, an embodiment of the present invention provides an eleventh possible implementation of the first aspect, wherein the above-mentioned step of checking whether the ID card information is correct according to the information category includes: using the information corresponding to the ID card number category in the ID card information to check whether the information corresponding to the date of birth category in the ID card information and the information corresponding to the gender category in the ID card information are correct; and/or, checking whether the information corresponding to the gender category in the ID card information is one of the preset gender words, wherein the preset gender words include male or female; and/or, checking whether the information corresponding to the ethnic category in the ID card information is one of the preset ethnic words, wherein the preset ethnic words include legal ethnic words; and/or, checking whether the information corresponding to the date of birth category in the ID card information is one of the preset numbers; wherein the preset numbers are legal date numbers.

结合第一方面的第十种可能的实施方式,本发明实施例提供了第一方面的第十二种可能的实施方式,上述方法还包括:根据身份证信息中身份证号码类别对应的信息判断身份证图像是否合法。In combination with the tenth possible implementation manner of the first aspect, embodiments of the present invention provide a twelfth possible implementation manner of the first aspect. The above method further includes: judging based on the information corresponding to the ID card number category in the ID card information. Is the ID card image legal?

结合第一方面,本发明实施例提供了第一方面的第十三种可能的实施方式,其中,对文本框进行文字识别的步骤之前,上述方法还包括:根据文本框的位置信息与预先设置的身份证文本框的合法位置,判断是否存在位置非法的文本框;如果是,将位置非法的文本框删除。Combined with the first aspect, embodiments of the present invention provide a thirteenth possible implementation manner of the first aspect, wherein before the step of character recognition of the text box, the above method further includes: based on the position information of the text box and the preset settings The legal position of the ID card text box is determined to determine whether there is a text box with an illegal position; if so, delete the text box with an illegal position.

结合第一方面,本发明实施例提供了第一方面的第十四种可能的实施方式,其中,确定具有对应关系的文字信息的步骤之前,上述方法还包括:根据文本框的位置信息和文字信息,识别并过滤身份证图像上的非法文字信息;其中,非法文字信息所在的文本框的位置不属于预先设置的身份证文本框的合法位置。In conjunction with the first aspect, embodiments of the present invention provide a fourteenth possible implementation manner of the first aspect, wherein before the step of determining text information with a corresponding relationship, the above method further includes: based on the position information of the text box and the text Information, identify and filter illegal text information on the ID card image; among them, the position of the text box where the illegal text information is located does not belong to the legal position of the preset ID card text box.

第二方面,本发明实施例提供了一种身份证信息的识别装置,包括:待识别图像获取模块,用于获取待识别身份证信息的身份证图像;文本行检测模块,用于对身份证图像进行文本行检测,得到多个文本框;位置信息获取模块,用于获取身份证图像中文本框的位置信息;文字识别模块,用于对文本框进行文字识别,得到文本框对应的文字信息;对应关系确定模块,用于根据文本框的位置信息和文字信息,确定具有对应关系的文字信息;身份证信息确定模块,用于根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。In a second aspect, an embodiment of the present invention provides an identification device for identity card information, comprising: an image acquisition module for acquiring an identity card image of identity card information to be identified; a text line detection module for performing text line detection on the identity card image to obtain multiple text boxes; a position information acquisition module for acquiring position information of the text box in the identity card image; a text recognition module for performing text recognition on the text box to obtain text information corresponding to the text box; a corresponding relationship determination module for determining text information with a corresponding relationship based on the position information and text information of the text box; and an identity card information determination module for determining the identity card information corresponding to the identity card image based on the text information with a corresponding relationship.

第三方面,本发明实施例提供了一种终端设备,该终端设备包括存储器以及处理器,存储器用于存储支持处理器执行第一方面至第一方面的第十四种可能的实施方式中任一项所述方法的程序,处理器被配置为用于执行存储器中存储的程序。In a third aspect, embodiments of the present invention provide a terminal device. The terminal device includes a memory and a processor. The memory is used to store any of the fourteenth possible implementation modes of the first aspect to the first aspect. In a program of the method, the processor is configured to execute the program stored in the memory.

第四方面,本发明实施例提供了一种计算机存储介质,用于储存为第一方面至第一方面的第十四种可能的实施方式中任一项所述方法所用的计算机软件指令。In a fourth aspect, embodiments of the present invention provide a computer storage medium for storing computer software instructions used for the method described in any one of the first aspect to the fourteenth possible implementation manner of the first aspect.

本发明提供了一种身份证信息的识别方法、装置、终端设备及存储介质,能够首先对待识别身份证信息的身份证图像进行文本行检测,得到多个文本框;然后获取身份证图像中文本框的位置信息以及文本框对应的文字信息,进而根据文本框的位置信息和文字信息,确定具有对应关系的文字信息,并根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。与现有技术中大多直接对身份证图像上的文字进行识别而提取身份证信息,因身份证图像上文字零散、添加有水印或身份证图像倾斜等原因而存在提取到错误的身份证信息的问题相比,本发明实施例能够先检测身份证图像上的文本框,然后根据文本框的位置信息和文字信息,确定有对应关系的文字信息,能够避免提取到错误的身份证信息,有效地提升了身份证信息的识别准确率。The invention provides a method, device, terminal equipment and storage medium for identifying ID card information, which can first detect text lines on an ID card image to be recognized to obtain multiple text boxes; and then obtain the text in the ID card image. The position information of the frame and the text information corresponding to the text box, and then based on the position information and text information of the text box, the corresponding text information is determined, and based on the corresponding text information, the ID card information corresponding to the ID card image is determined . Unlike the existing technology, which mostly directly recognizes the text on the ID card image to extract the ID card information, the wrong ID card information may be extracted due to reasons such as scattered text on the ID card image, watermarks added or the ID card image being tilted. Compared with the problem, the embodiment of the present invention can first detect the text box on the ID card image, and then determine the corresponding text information based on the position information and text information of the text box, which can avoid extracting the wrong ID card information and effectively Improved the recognition accuracy of ID card information.

本发明的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本发明而了解。本发明的目的和其他优点在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Additional features and advantages of the invention will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention may be realized and attained by the structure particularly pointed out in the written description, claims and appended drawings.

为使本发明的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings.

附图说明Description of drawings

为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly explain the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings that need to be used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description The drawings illustrate some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without exerting any creative effort.

图1为本发明实施例提供的第一种身份证信息的识别方法的流程图;Figure 1 is a flow chart of the first identification method of ID card information provided by an embodiment of the present invention;

图2为本发明实施例提供的一种倾斜的身份证示意图;Figure 2 is a schematic diagram of a tilted ID card provided by an embodiment of the present invention;

图3为本发明实施例提供的一种调正后的身份证示意图;Figure 3 is a schematic diagram of an adjusted ID card provided by an embodiment of the present invention;

图4为本发明实施例提供的第二种身份证信息的识别方法的流程图;Figure 4 is a flow chart of a second identification method for ID card information provided by an embodiment of the present invention;

图5为本发明实施例提供的第三种身份证信息的识别方法的流程图;5 is a flow chart of a third method for identifying identity card information provided by an embodiment of the present invention;

图6为本发明实施例提供的第一种身份证信息的识别装置的结构框图;Figure 6 is a structural block diagram of a first identification device for ID card information provided by an embodiment of the present invention;

图7为本发明实施例提供的第二种身份证信息的识别装置的结构框图;Figure 7 is a structural block diagram of a second identification device for ID card information provided by an embodiment of the present invention;

图8为本发明实施例提供的第三种身份证信息的识别装置的结构框图;Figure 8 is a structural block diagram of a third identification device for ID card information provided by an embodiment of the present invention;

图9为本发明实施例提供的一种终端设备的结构示意图。FIG. 9 is a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.

考虑到现有技术中大多是直接对身份证图像进行文字识别和提取,识别准确率不高,为改善此问题,本发明实施例提供了一种身份证信息的识别方法、装置、终端设备及存储介质,能够先监测身份证图像上的文本框,然后根据文本框的位置信息和文字信息,确定有对应关系的文字信息,以避免提取到错误的身份证信息,这种方式能够有效地提升身份证信息的识别准确率。该技术可以应用于任何需要对身份证图像进行识别的场合。Considering that most of the existing technologies directly perform text recognition and extraction on ID card images, the recognition accuracy is not high. In order to improve this problem, embodiments of the present invention provide a method, device, terminal equipment, and device for identifying ID card information. The storage medium can first monitor the text box on the ID card image, and then determine the corresponding text information based on the position information and text information of the text box to avoid extracting the wrong ID card information. This method can effectively improve Recognition accuracy of ID card information. This technology can be applied to any occasion where identification of ID card images is required.

以下对本发明实施例进行详细介绍。The embodiments of the present invention are introduced in detail below.

本发明实施例首先提供了第一种身份证信息的识别方法,如图1所示,该方法可以由诸如电脑、手机、手持证件识别终端等具有处理能力的终端设备执行,该方法具体包括如下步骤:The embodiment of the present invention first provides a first method for identifying ID card information, as shown in Figure 1. This method can be executed by a terminal device with processing capabilities such as a computer, a mobile phone, a handheld ID recognition terminal, etc. The method specifically includes the following step:

步骤S102,获取待识别身份证信息的身份证图像;其中,待识别的身份证图像可以是人工直接上传的电子版身份证印刷件,或者是通过电子设备直接扫描实体身份证获得的身份证图像等,在此对身份证图像的获取方式不进行限定。步骤S104,对身份证图像进行文本行检测,得到多个文本框。Step S102, obtaining an ID card image of the ID card information to be identified; wherein the ID card image to be identified can be an electronic ID card print uploaded directly by humans, or an ID card image obtained by directly scanning a physical ID card through an electronic device, etc., and the method for obtaining the ID card image is not limited here. Step S104, performing text line detection on the ID card image to obtain multiple text boxes.

具体实施时,可以通过相关文本行检测算法对身份证图像进行文本检测,得到的文本框形状通常为矩形。During specific implementation, text detection can be performed on the ID card image through the relevant text line detection algorithm, and the shape of the resulting text box is usually a rectangle.

具体实施时,可以通过机器学习的方式构建文本框检测模型,模型的输入为身份证图像,输出为该身份证图像上的各文本框。During specific implementation, a text box detection model can be constructed through machine learning. The input of the model is an ID card image, and the output is each text box on the ID card image.

步骤S106,获取身份证图像中文本框的位置信息。Step S106: Obtain the position information of the text box in the ID card image.

在一种可选的实施方式中,可以通过在多个文本框共在的平面上构建平面直角坐标系,用每个文本框中相同位置的某一点的坐标表示其对应文本框的位置信息,诸如,用每个文本框的左上角的顶点坐标作为该文本框的位置信息。此外,还可以选取每个文本框的多个关键点,将多个关键点的坐标集合确定为每个文本框的位置信息。其中,关键点可以为文本框的边框上所在的点。关键点的数量多少可以根据实际需求而自行设定,在此不进行限制。In an optional implementation, a plane rectangular coordinate system can be constructed on a plane where multiple text boxes coexist, and the coordinates of a certain point at the same position in each text box can be used to represent the position information of its corresponding text box. For example, use the vertex coordinates of the upper left corner of each text box as the position information of the text box. In addition, you can also select multiple key points of each text box and determine the coordinate set of multiple key points as the position information of each text box. Among them, the key point can be a point on the border of the text box. The number of key points can be set according to actual needs and is not limited here.

步骤S108,对文本框进行文字识别,得到文本框对应的文字信息。Step S108: Perform text recognition on the text box to obtain text information corresponding to the text box.

具体实施时,可以通过相关文字识别算法对文本框进行文字识别,得到文本框对应的文字信息。During specific implementation, text recognition of the text box can be performed through relevant text recognition algorithms to obtain text information corresponding to the text box.

具体实施时,可以通过机器学习的方式构建文本框文字识别模型,模型的输入为身份证图像中的文本框对应的图像,输出为文本框图像中的文字信息。During specific implementation, a text box text recognition model can be constructed through machine learning. The input of the model is the image corresponding to the text box in the ID card image, and the output is the text information in the text box image.

步骤S110,根据文本框的位置信息和文字信息,确定具有对应关系的文字信息。Step S110: Determine text information with a corresponding relationship based on the position information and text information of the text box.

诸如,可根据身份证上真正具有文字对应关系的文本框的位置分布特征,诸如“姓名”与“张三”、“性别”与“女”、“民族”与“汉”在位置分布上相距较近,根据具有对应关系的文本框的位置分布特征对步骤S106得到的文本框的位置信息进行分析判断,得到“性别”与“女”具有对应关系,“民族”与“汉”具有对应关系,也即初步确定具有对应关系的文本信息。考虑到“女”和“民族”所在的文本框可能位置相距也较近,有可能得到“女”和“民族”相对应的错误结论,因此,本实施例还进一步结合文字信息验证两个相邻的文本框之间是否具有对应关系,从而将位置分布相近但不存在文字对应关系的文本框,诸如“女”与“民族”等错误的对应关系剔除,筛选出既符合位置分布特征又具有文字对应关系的文本框,从而确定有对应关系的文字信息。其中,实际执行时,上述步骤S106和步骤S108可不区分前后顺序。For example, according to the position distribution characteristics of the text boxes on the ID card that actually have text correspondences, such as "name" and "Zhang San", "gender" and "female", "ethnicity" and "Han" are far apart in position distribution Recently, the position information of the text box obtained in step S106 was analyzed and judged based on the position distribution characteristics of the corresponding text box, and it was found that "gender" and "female" have a corresponding relationship, and "ethnicity" and "Han" have a corresponding relationship. , that is, the text information with corresponding relationships is initially determined. Considering that the text boxes where "female" and "ethnicity" are located may be close to each other, it is possible to draw the wrong conclusion that "female" and "ethnicity" correspond to each other. Therefore, this embodiment further combines the text information to verify the two relative Whether there is a correspondence between adjacent text boxes, so as to eliminate text boxes with similar position distribution but no text correspondence, such as "female" and "ethnic", etc., and filter out the text boxes that both conform to the position distribution characteristics and have Text boxes for text correspondence, thereby determining corresponding text information. During actual execution, the order of the above-mentioned steps S106 and S108 may not be distinguished.

举例说明,正常情况下,文字信息“女”和“男”对应的文字信息为“性别”,当基于文本框的位置关系确定文字信息“女”所在的文本框与文字信息“民族”所在的文本框具有对应关系时,进一步基于文字信息“女”和“民族”,“女”应该对应的文字信息为“性别”而不是“民族”,因此,可以确定“女”与“民族”并不对应。For example, under normal circumstances, the text information corresponding to the text information "female" and "male" is "gender". When it is determined based on the positional relationship between the text boxes, the text box where the text information "female" is located and the text information "ethnicity" are located. When the text box has a corresponding relationship, further based on the text information "female" and "ethnicity", the text information that should correspond to "female" is "gender" rather than "ethnicity". Therefore, it can be determined that "female" and "ethnicity" are not the same. correspond.

步骤S112,根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。Step S112: Determine the ID card information corresponding to the ID card image based on the text information with the corresponding relationship.

在获知具有对应关系的文字信息后,即可确定身份证信息。身份证信息可包括姓名、性别、出生日期、住址、身份证号码中的至少一种信息。After knowing the corresponding text information, the ID card information can be determined. The ID card information may include at least one of name, gender, date of birth, address, and ID number.

诸如,根据上述步骤S110确定身份证图像中的“姓名”与“张三”具有对应关系,“性别”与“女”具有对应关系,“民族”与“汉”具有对应关系,所确定的身份证信息可以为,姓名:张三,性别:女,民族:汉。可以将所确定的身份证信息呈现出来,具体的,身份证信息可以呈现为“姓名-张三性别-女民族-汉”,或者可以直接呈现为“张三-女-汉”,确定的身份证信息的呈现形式可根据需求而设置,在此不进行限定。For example, according to the above step S110, it is determined that the "name" in the ID card image has a corresponding relationship with "Zhang San", the "gender" has a corresponding relationship with "female", and the "nationality" has a corresponding relationship with "Han", and the determined ID card information can be, name: Zhang San, gender: female, nationality: Han. The determined ID card information can be presented, specifically, the ID card information can be presented as "name-Zhang San gender-female nationality-Han", or can be directly presented as "Zhang San-female-Han", and the presentation form of the determined ID card information can be set according to needs, and is not limited here.

本发明提供的上述身份证信息的识别方法,能够首先对待识别身份证信息的身份证图像进行文本行检测,得到多个文本框;然后获取身份证图像中文本框的位置信息,以及文本框对应的文字信息,进而根据文本框的位置信息和文字信息,确定具有对应关系的文字信息,并根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。与现有技术中大多直接对身份证图像上的文字进行识别而提取身份证信息,因身份证图像上文字零散、添加有水印或身份证图像倾斜等原因而存在提取到错误的身份证信息的问题相比,本发明实施例能够先检测身份证图像上的文本框,然后根据文本框的位置信息和文字信息,确定有对应关系的文字信息,能够避免提取到错误的身份证信息,有效地提升了身份证信息的识别准确率。The above-mentioned identification method of ID card information provided by the present invention can first perform text line detection on the ID card image to be recognized to obtain multiple text boxes; and then obtain the position information of the text boxes in the ID card image, and the corresponding text boxes. text information, and then determine corresponding text information based on the position information and text information of the text box, and determine ID card information corresponding to the ID card image based on the corresponding text information. Unlike the existing technology, which mostly directly recognizes the text on the ID card image to extract the ID card information, there is a possibility that the wrong ID card information is extracted due to reasons such as scattered text on the ID card image, watermarks added or the ID card image being tilted. Compared with the problem, the embodiment of the present invention can first detect the text box on the ID card image, and then determine the corresponding text information based on the position information and text information of the text box, which can avoid extracting the wrong ID card information and effectively Improved the recognition accuracy of ID card information.

在一种可选的实施方式中,上述步骤S104,也即对身份证图像进行文本行检测,得到多个文本框的步骤,包括:In an optional implementation, the above step S104, that is, the step of detecting text lines on the ID card image to obtain multiple text boxes, includes:

(1)获取身份证图像的顶点坐标,根据身份证图像的顶点坐标判断身份证图像是否倾斜。其中,身份证图像的顶点坐标可以为身份证图像上的左上角顶点、左下角顶点、右上角顶点和右下角顶点。根据顶点坐标判断身份证图像是否倾斜时,可以判断身份证图像的左上角顶点和左下角顶点的横坐标是否相同,以及左上角顶点纵坐标与右上角顶点纵坐标是否相同,如有不同,则说明身份证图像倾斜。(1) Obtain the vertex coordinates of the ID card image, and determine whether the ID card image is tilted based on the vertex coordinates of the ID card image. Among them, the vertex coordinates of the ID card image can be the upper left corner vertex, the lower left corner vertex, the upper right corner vertex and the lower right corner vertex on the ID card image. When judging whether the ID card image is tilted based on the vertex coordinates, you can determine whether the abscissas of the upper left vertex and the lower left vertex of the ID card image are the same, and whether the ordinates of the upper left vertex and the upper right vertex are the same. If they are different, then Explain that the ID card image is tilted.

(2)当(1)中的判断结果为是时,调正身份证图像。(2) When the judgment result in (1) is yes, adjust the ID card image.

其中,调正后的身份证图像的左上角顶点横坐标与左下角顶点横坐标相同,且左上角顶点纵坐标与右上角顶点纵坐标相同,且左上角顶点与右上角顶点之间的距离大于左上角顶点与左下角顶点之间的距离。Among them, the abscissa coordinate of the upper left vertex of the corrected ID card image is the same as the abscissa of the lower left vertex, and the ordinate of the upper left vertex is the same as the ordinate of the upper right vertex, and the distance between the upper left vertex and the upper right vertex is greater than The distance between the upper left vertex and the lower left vertex.

调正的方式不限,本领域技术人员可以合理选择。The adjustment method is not limited and can be reasonably selected by those skilled in the art.

(3)对调正后的身份证图像进行文本行检测,得到多个文本框。(3) Perform text line detection on the corrected ID card image to obtain multiple text boxes.

在另一种可选的实施方式中,实施上述步骤S104时,也可以不对身份证图像进行调整,而是直接对身份证图像进行文本行检测,如果检测出的文本框歪斜,再直接对文本框进行位置调整。In another optional implementation, when performing the above step S104, the ID card image may not be adjusted, but text lines may be directly detected on the ID card image. If the detected text box is skewed, the text may be directly Adjust the position of the frame.

无论是何种实施方式,均可通过CTPN网络模型对身份证图像进行文本行检测,得到多个文本框。Regardless of the implementation method, the CTPN network model can be used to detect text lines on the ID card image to obtain multiple text boxes.

其中,CTPN(Connectionist Text Proposal Network)网络模型,也称连接文本提议网络模型,是一个全卷积网络,允许任意大小的输入图像。它通过在卷积特征映射中密集地滑动小窗口来检测文本行,并且输出一系列细粒度的(例如,宽度为固定的16个像素)文本提议,进而直接在卷积映射的一系列细粒度文本提议中检测文本行。CTPN网络模型设置有垂直锚点机制,能够联合预测每个提议的精确位置和文本/非文本分数,从而实现文本的准确定位。采用CTPN克服了相关技术中通过建立在字符检测基础上的自下而上方法带来的一些主要限制;诸如,在卷积层中使用滑动窗口允许共享卷积计算,相较于相关技术中昂贵的基于滑动窗口的方法,极大地减少了计算量。并且通过垂直锚点的设计和细粒度的检测策略,能够使用单尺度图像处理各种尺度和长宽比的文本行,因而进一步减少了计算量,同时预测了文本行的准确位置。Among them, the CTPN (Connectionist Text Proposal Network) network model, also known as the Connectionist Text Proposal Network model, is a fully convolutional network that allows input images of any size. It detects text lines by densely sliding small windows in a convolutional feature map, and outputs a series of fine-grained (e.g., fixed width of 16 pixels) text proposals, which are then directly processed by a series of fine-grained text proposals in the convolutional feature map. Detect lines of text in text proposals. The CTPN network model is equipped with a vertical anchor mechanism, which can jointly predict the precise location and text/non-text score of each proposal, thereby achieving accurate text positioning. Adopting CTPN overcomes some major limitations brought by the bottom-up approach based on character detection in related technologies; such as the use of sliding windows in the convolutional layer allows shared convolution computation, which is more expensive than in related technologies. The sliding window-based method greatly reduces the amount of calculation. And through the design of vertical anchor points and fine-grained detection strategies, single-scale images can be used to process text lines of various scales and aspect ratios, thus further reducing the amount of calculation and predicting the accurate position of text lines.

在一种可选的实施方式中,在获取身份证图像中文本框的位置信息时,可以参照如下步骤1~步骤4实现:In an optional implementation, when obtaining the position information of the text box in the ID card image, the following steps 1 to 4 may be referred to:

步骤1,获取身份证图像中文本框的顶点坐标。诸如,获取文本框的顶角坐标,一种实施方式中,可以统一获取每个文本框的同一顶点坐标,诸如获取文本框的左上角顶点坐标。在另一实施方式中,可以获取每个文本框左上角、左下角、右上角、右下角共四个顶点坐标。Step 1, obtain the vertex coordinates of the text box in the ID card image. For example, obtain the vertex coordinates of the text box. In one embodiment, the same vertex coordinates of each text box can be uniformly obtained, such as obtaining the vertex coordinates of the upper left corner of the text box. In another embodiment, the four vertex coordinates of the upper left corner, lower left corner, upper right corner, and lower right corner of each text box can be obtained.

步骤2,根据文本框的顶点坐标,判断文本框是否倾斜。Step 2: Determine whether the text box is tilted based on the vertex coordinates of the text box.

在一种实施方式中,可以单独判断每个文本框是否倾斜。具体而言,如果获取的是文本框的四个顶角坐标,则可以根据每个文本框的四个顶角坐标来分别判断文本框是否倾斜,诸如,如果判断文本框的左上角顶点和左下角顶点的横坐标相同,且左上角顶点纵坐标与右上角顶点纵坐标相同,则确定文本框不倾斜。反之,如有不同,则说明文本框倾斜。In one implementation, whether each text box is tilted can be determined individually. Specifically, if you obtain the four vertex coordinates of the text box, you can determine whether the text box is tilted based on the four vertex coordinates of each text box. For example, if you determine the upper left corner vertex and the lower left corner of the text box, If the abscissas of the corner vertices are the same, and the ordinates of the upper-left vertex are the same as the ordinates of the upper-right vertex, then it is determined that the text box is not tilted. On the contrary, if there is a difference, it means that the text box is tilted.

在另一种实施方式中,可以根据多个文本框的位置综合判断文本框是否倾斜。具体而言,如果获取的是文本框的同一顶点坐标,可以根据水平相邻的文本框和/或竖直相邻的文本框的来判别文本框是否倾斜。具体的,为便于理解,参见图2所示的一种倾斜的身份证示意图,在图2中示意出了倾斜的身份证图像200及身份证图像200上的多个倾斜的文本框(图2中简单示意出了4个文本框,分别为第一文本框202a、第二文本框202b、第三文本框204a、第四文本框204b)。其中,前述文本框的形状为长方形,并选取每个文本框的左上角顶点坐标表征文本框的位置。此外,为更加直观的展示各文本框顶点坐标间的关系,在图2中还示意出了平面直角坐标轴;其中,x轴为横轴;y轴为纵轴;0表示原点。第一文本框202a与第二文本框202b的顶点纵坐标相差2by-2ay;第一文本框202a与第三文本框204a的顶点横坐标相差4ax-2ax;第三文本框204a与第四文本框204b的顶点纵坐标相差4by-4ay;第四文本框204b与第二文本框202b的顶点横坐标相差4bx-2bx。In another implementation, whether the text box is tilted can be comprehensively determined based on the positions of multiple text boxes. Specifically, if the same vertex coordinates of the text box are obtained, whether the text box is tilted can be determined based on horizontally adjacent text boxes and/or vertically adjacent text boxes. Specifically, for ease of understanding, refer to the schematic diagram of a tilted ID card shown in FIG. 2 , which shows a tilted ID card image 200 and multiple tilted text boxes on the ID card image 200 ( FIG. 2 4 text boxes are simply illustrated in the figure, namely the first text box 202a, the second text box 202b, the third text box 204a, and the fourth text box 204b). Wherein, the shape of the aforementioned text box is a rectangle, and the coordinates of the upper left corner vertex of each text box are selected to represent the position of the text box. In addition, in order to more intuitively display the relationship between the vertex coordinates of each text box, Figure 2 also shows the plane rectangular coordinate axis; where the x-axis is the horizontal axis; the y-axis is the vertical axis; 0 represents the origin. The vertical coordinates of the vertices of the first text box 202a and the second text box 202b differ by 2by-2ay; the abscissa coordinates of the vertices of the first text box 202a and the third text box 204a differ by 4ax-2ax; the third text box 204a and the fourth text box The vertical coordinate difference of the vertex of 204b is 4by-4ay; the horizontal coordinate difference of the vertex of the fourth text box 204b and the second text box 202b is 4bx-2bx.

可以理解的是,如果文本框未倾斜,则2by-2ay、4by-4ay、4ax-2ax以及4bx-2bx的值应该均为0,如不为零,则证明文本框歪斜。It can be understood that if the text box is not tilted, the values of 2by-2ay, 4by-4ay, 4ax-2ax, and 4bx-2bx should all be 0. If they are not zero, it proves that the text box is skewed.

应当注意的是,图2仅为简要示意,简单地示意出了姓名和性别,并未将住址、民族、出生年月日等信息详细示意出。图2为一种身份证的简单示意图,并非与实际身份证上的排版相对应,也不应当被视为限制。It should be noted that Figure 2 is only a brief illustration. It simply shows the name and gender, but does not show the address, ethnicity, date of birth and other information in detail. Figure 2 is a simple schematic diagram of an ID card. It does not correspond to the layout on the actual ID card, nor should it be considered a limitation.

步骤3,当文本框倾斜时,调正文本框。Step 3: If the text box is tilted, adjust the text box.

在一种可选的实施方式中,可以单独调整每个文本框的位置,使调正后的文本框的左上角顶点横坐标与左下角顶点横坐标相同,且左上角顶点纵坐标与右上角顶点纵坐标相同。在具体实施时,可以首先调正一个基准文本框(如上述第一文本框202a),然后将与该基准文本框横向相邻的文本框的顶点纵坐标调整至与该基准文本框的顶点纵坐标相同,并以该横向相邻的文本框调整后的顶点为准,调正该横向相邻的文本框;同理,将与该基准文本框纵向相邻的文本框的顶点横坐标调整至与基准文本框的顶点横坐标相同,并将该纵向相邻的文本框调整后的顶点为准,调正该纵向相邻的文本框。通过上述方式即可调正身份证图像上的各文本框的位置。通过设置某一文本框顶点坐标为参照点的方式调整其它文本框的顶点坐标,能够有效地提升调正文本框的效率。In an optional implementation, the position of each text box can be adjusted individually, so that the abscissa coordinate of the upper left corner vertex of the adjusted text box is the same as the abscissa coordinate of the lower left corner vertex, and the ordinate coordinate of the upper left corner vertex is the same as the upper right corner vertex. The vertical coordinates of the vertices are the same. In specific implementation, a reference text box (such as the above-mentioned first text box 202a) can be adjusted first, and then the vertical coordinate of the vertex of the text box horizontally adjacent to the reference text box is adjusted to the vertical coordinate of the vertex of the reference text box. The coordinates are the same, and the horizontally adjacent text box is adjusted based on the adjusted vertex of the horizontally adjacent text box; similarly, the abscissa coordinate of the vertex of the text box vertically adjacent to the reference text box is adjusted to The horizontal coordinates of the vertices of the reference text box are the same, and the adjusted vertices of the vertically adjacent text boxes are used as the basis to adjust the vertically adjacent text boxes. Through the above method, you can adjust the position of each text box on the ID card image. By setting the vertex coordinates of a certain text box as a reference point to adjust the vertex coordinates of other text boxes, the efficiency of adjusting text boxes can be effectively improved.

具体的,为便于理解,参见图3,本发明实施例提供了一种调正后的身份证示意图。在图2的基础上,以文本框的左上角顶点坐标表示文本框的顶点坐标为例,并以左上文本框(如上述第一文本框202a)的顶点坐标作为参照,对各文本框进行调正,第二文本框202b的顶点纵坐标与第一文本框202a的顶点纵坐标调整为一致,均为2ay;第三文本框204a的顶点横坐标与第一文本框202a的顶点横坐标调整为一致,均为2ax;相应的,第四文本框204b的顶点纵坐标与第三文本框204a的顶点纵坐标调整为一致,均为4ay;第四文本框204b的顶点横坐标与第二文本框202b的顶点横坐标调整为一致,均为2bx。各文本框也以自身调整后的顶点坐标为基准调正自身的位置,调正后的文本框的左上角顶点横坐标与左下角顶点横坐标相同,且左上角顶点纵坐标与右上角顶点纵坐标相同。Specifically, for ease of understanding, refer to FIG. 3 , which is a schematic diagram of an adjusted ID card according to an embodiment of the present invention. On the basis of Figure 2, taking the vertex coordinates of the upper left corner of the text box to represent the vertex coordinates of the text box as an example, and using the vertex coordinates of the upper left text box (such as the above-mentioned first text box 202a) as a reference, adjust each text box. Positive, the ordinate of the vertex of the second text box 202b is adjusted to be consistent with the ordinate of the vertex of the first text box 202a, both are 2ay; the abscissa of the vertex of the third text box 204a is adjusted to the abscissa of the vertex of the first text box 202a. are consistent, both are 2ax; correspondingly, the ordinate of the vertex of the fourth text box 204b is adjusted to be consistent with the ordinate of the vertex of the third text box 204a, both are 4ay; the abscissa of the vertex of the fourth text box 204b is consistent with that of the second text box The abscissa coordinates of the vertices of 202b are adjusted to be consistent, both are 2bx. Each text box also adjusts its position based on its adjusted vertex coordinates. The abscissa coordinate of the upper left vertex of the adjusted text box is the same as the abscissa of the lower left vertex, and the ordinate of the upper left vertex is the same as the ordinate of the upper right vertex. The coordinates are the same.

步骤4,获取调正后的文本框的位置信息。Step 4, obtaining the position information of the adjusted text box.

同样,可以获取调正后的各文本框的一个或多个顶点坐标或者边框线条上的关键点坐标等。Similarly, you can obtain the coordinates of one or more vertices of each adjusted text box or the coordinates of key points on the border lines, etc.

在检测出文本框之后,可以对文本框进行文字识别,得到文本框对应的文字信息。本实施例给出了一种具体的文字识别方式:通过CRNN网络模型对文本框进行文字识别,得到文本框对应的文字信息。After detecting the text box, text recognition can be performed on the text box to obtain text information corresponding to the text box. This embodiment provides a specific text recognition method: text recognition is performed on the text box through the CRNN network model to obtain the text information corresponding to the text box.

其中,CRNN(Convolutional Recurrent Neural Network)网络模型,也称卷积循环神经网络,是一种端到端的文字识别的网络模型。可以与CTPN网络模型搭配使用,包括卷积层,循环层和转录层。在CRNN的底部,卷积层自动从每个输入图像中提取特征序列。在卷积网络之上,构建了一个循环网络,用于对卷积层输出的特征序列的每一帧进行预测。采用CRNN顶部的转录层将循环层的每帧预测转化为标签序列。虽然CRNN由不同类型的网络架构(如CNN和RNN)构成,但可以通过一个损失函数进行联合端到端的训练。采用CRNN网络模型对文本框进行文字识别,能够更为准确可靠地得到文字识别结果。Among them, the CRNN (Convolutional Recurrent Neural Network) network model, also known as the convolutional recurrent neural network, is an end-to-end text recognition network model. Can be used with CTPN network models, including convolutional layers, recurrent layers and transcription layers. At the bottom of CRNN, convolutional layers automatically extract feature sequences from each input image. On top of the convolutional network, a recurrent network is constructed to predict each frame of the feature sequence output by the convolutional layer. A transcription layer on top of the CRNN is used to convert the per-frame predictions of the recurrent layer into a label sequence. Although CRNN is composed of different types of network architectures (such as CNN and RNN), it can be jointly trained end-to-end through a loss function. Using the CRNN network model to perform text recognition on text boxes can obtain text recognition results more accurately and reliably.

进一步,考虑到待识别身份证图像上可能存在身份证证件信息以外的干扰文本,诸如“本身份证仅用于XX场合”等写在空白处的杂质信息或者水印等,这些干扰文本的文本框的位置与身份证信息文本框的合法位置不同,本发明实施例可通过判断干扰文本的文本框的位置非法,对干扰文本进行过滤。具体的,在一种可选的方式中,可以在执行对文本框进行文字识别的步骤之前,根据文本框的位置信息与预先设置的身份证文本框的合法位置,判断是否存在位置非法的文本框;如果是,将位置非法的文本框删除。在另一种选的方式中,可以在确定具有对应关系的文字信息之前,根据文本框的位置信息和文字信息,识别并过滤身份证图像上的非法文字信息;其中,非法文字信息所在的文本框的位置不属于预先设置的身份证文本框的合法位置。Furthermore, considering that there may be interfering text other than ID card information on the ID card image to be recognized, such as "This ID card is only used for XX occasions" and other impurity information written in the blank space or watermarks, etc., the text boxes of these interfering texts The position is different from the legal position of the ID card information text box. The embodiment of the present invention can filter the interfering text by judging that the position of the text box of the interfering text is illegal. Specifically, in an optional method, before performing the step of character recognition of the text box, it can be determined whether there is text with illegal position based on the position information of the text box and the legal position of the preset ID card text box. box; if so, delete the text box with illegal position. In another alternative method, before determining the corresponding text information, the illegal text information on the ID card image can be identified and filtered based on the position information and text information of the text box; wherein, the text where the illegal text information is located The position of the box does not belong to the legal position of the preset ID card text box.

此外,本发明实施例还提供了第二种身份证信息的识别方法,该方法在图1所示的方法的基础上实现,该方法进一步描述了根据文本框的位置信息和文字信息,确定具有对应关系的文字信息的具体过程,参见图4,该方法包括如下步骤:In addition, the embodiment of the present invention also provides a second method for identifying ID card information. This method is implemented on the basis of the method shown in Figure 1. This method further describes that based on the position information and text information of the text box, it is determined that the For the specific process of corresponding text information, see Figure 4. The method includes the following steps:

步骤S402,获取待识别身份证信息的身份证图像;Step S402, obtaining an ID card image of the ID card information to be identified;

步骤S404,对身份证图像进行文本行检测,得到多个文本框;Step S404, perform text line detection on the ID card image to obtain multiple text boxes;

步骤S406,获取身份证图像中文本框的位置信息;Step S406, obtain the position information of the text box in the ID card image;

步骤S408,对文本框进行文字识别,得到文本框对应的文字信息;Step S408: Perform text recognition on the text box to obtain text information corresponding to the text box;

步骤S410,根据文本框的位置信息,确定同行的文本框;Step S410, determine the text box of the same peer according to the position information of the text box;

可以依据实际应用时身份证上同行文本框的分布位置特征信息,诸如在多个文本框共在的平面直角坐标系中,同行的文本框上的对应坐标点的纵坐标的特征信息。如,无论身份证图像倾斜与否,同行的文本框对应坐标点的纵坐标之间的间距都相差在预设阈值范围内。举例而言,如果身份证图像未倾斜,两个同行的文本框各自的左上角顶点纵坐标应当相同,如果身份证图像倾斜,两个同行的文本框各自的左上角顶点纵坐标有所偏差,但也会相距在一定范围内。或者,同行的文本框的纵向边框的纵坐标取值范围会具有一定的重叠程度。The characteristic information of the distribution position of the text boxes in the same row on the ID card can be used in actual application, such as the characteristic information of the ordinates of the corresponding coordinate points on the text boxes in the same row in the plane rectangular coordinate system where multiple text boxes coexist. For example, regardless of whether the ID card image is tilted or not, the spacing between the ordinates of the corresponding coordinate points of the text boxes in the same row is within the preset threshold range. For example, if the ID card image is not tilted, the ordinates of the upper left corner vertices of the two text boxes in the same row should be the same. If the ID card image is tilted, the ordinates of the upper left corner vertices of the two text boxes in the same row will deviate, but they will also be within a certain range. Alternatively, the ordinate value range of the vertical borders of the text boxes in the same row will have a certain degree of overlap.

步骤S412,根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框;Step S412: Determine text boxes with corresponding relationships among the text boxes of the same party based on the position information of the text boxes of the same party;

诸如,可以通过同行的文本框在平面直角坐标系中的横坐标进行分析,将横坐标相差较小,也即相距较近的文本框确定为具有对应关系的文本框。For example, the abscissa coordinates of the text boxes in the same row in the plane rectangular coordinate system can be analyzed, and the text boxes with a small difference in abscissa coordinates, that is, close to each other, can be determined as text boxes with a corresponding relationship.

步骤S414,根据具有对应关系的文本框,以及文本框的文字信息,确定具有对应关系的文字信息。Step S414: Determine the text information that has the corresponding relationship based on the text box that has the corresponding relationship and the text information of the text box.

可根据具有对应关系的文本框,以及文本框的文字信息,检查文本框的对应关系是否正确;将具有正确对应关系的文本框的文字信息确定为具有对应关系的文字信息。诸如,“性别”与“女”所在的文本框相近、“民族”与“汉”所在的文本框相近,在步骤S412中确定文本框具有对应关系,经文字信息核验确定“性别”与“女”为具有对应关系的文字信息、“民族”与“汉”为具有对应关系的文字信息。由于身份证图像中“女”和“民族”也相邻,如果步骤S412将“女”和“民族”所在的文本框也确定为具有对应关系,则在步骤S414中可以通过文字信息核验确定“女”和“民族”不具有对应关系。Whether the corresponding relationship of the text box is correct can be checked based on the text box with the corresponding relationship and the text information of the text box; the text information of the text box with the correct corresponding relationship can be determined as the text information with the corresponding relationship. For example, the text boxes where "gender" and "female" are located are similar, and the text boxes where "ethnicity" and "Han" are located are similar. In step S412, it is determined that the text boxes have a corresponding relationship, and it is determined that "gender" and "female" are verified through text information verification. ” is text information with a corresponding relationship, and “ethnicity” and “Han” are text information with a corresponding relationship. Since "female" and "ethnicity" are also adjacent in the ID card image, if step S412 determines that the text box where "female" and "ethnicity" are located has a corresponding relationship, then in step S414, it can be determined through text information verification that " There is no corresponding relationship between "female" and "ethnic".

步骤S416,根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。Step S416: Determine the ID card information corresponding to the ID card image based on the text information with the corresponding relationship.

本发明实施例提供的上述第二种身份证信息的识别方法,首先根据文本框的位置信息,确定同行的文本框,然后根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框;进而根据具有对应关系的文本框,以及文本框的文字信息,确定具有对应关系的文字信息。本发明实施例提供的上述方式通过先确定文本框的对应关系,然后再结合文本框的文字信息确定具有对应关系的文字信息,有助于提升身份证信息识别的准确率。The above-mentioned second identification method of ID card information provided by the embodiment of the present invention first determines the text box of the peer based on the position information of the text box, and then determines that the text box of the peer has a corresponding relationship based on the position information of the text box of the peer. the text box; and then determine the text information with the corresponding relationship based on the text box with the corresponding relationship and the text information of the text box. The above method provided by the embodiment of the present invention helps to improve the accuracy of identification of ID card information by first determining the corresponding relationship of the text box, and then combining the text information of the text box to determine the text information with the corresponding relationship.

在获取身份证图像中文本框的位置信息,以及确定同行的文本框和同行具有对应关系的文本框时,可以参照如下两种主要的实现方式:When obtaining the position information of the text box in the ID card image and determining the text boxes in the same line and the text boxes in the same line with corresponding relationships, the following two main implementation methods can be referred to:

方式一:method one:

获取的上述文本框的位置信息包括文本框的起始点坐标,起始点坐标包括起始横坐标和起始纵坐标;其中,文本框大多为矩形,起始点可以为文本框的任一顶点的坐标,诸如可将文本框的左上角顶点的坐标作为起始点坐标。The obtained position information of the above text box includes the starting point coordinates of the text box, and the starting point coordinates include the starting abscissa and the starting ordinate; among them, most text boxes are rectangles, and the starting point can be the coordinates of any vertex of the text box. , for example, the coordinates of the upper left corner vertex of the text box can be used as the starting point coordinates.

上述步骤S410可以是通过文本框的起始纵坐标确定同行的文本框,具体的,包括如下步骤:将起始点纵坐标相差预设第一阈值内的文本框确定为同行的文本框。The above step S410 may be to determine the text boxes in the same line by the starting ordinate of the text box, specifically, including the following steps: determining the text boxes whose starting point ordinates differ by a preset first threshold as the text boxes in the same line.

考虑到实际获取的身份证图像存在歪斜的情况,对身份证图像进行文本行检测得到的多个文本框可能歪斜,致使同行的文本框在平面直角坐标系上的纵坐标的值有具有偏差,故可预先设置第一阈值,当多个文本框的起始点的纵坐标的相差值小于预设第一阈值时,将该多个文本框确定为同行的文本框。该预设第一阈值可根据经验值设置,在此不进行限制。Considering that the actually obtained ID card image is skewed, the multiple text boxes obtained by text line detection on the ID card image may be skewed, causing the vertical coordinate values of the text boxes in the same row to be skewed on the plane rectangular coordinate system. Therefore, the first threshold can be set in advance. When the difference value of the ordinates of the starting points of multiple text boxes is less than the preset first threshold, the multiple text boxes are determined to be text boxes of the same row. The preset first threshold can be set based on empirical values and is not limited here.

基于此,上述步骤S412,也即根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框的步骤,包括:将同行的文本框中起始点横坐标相差预设第二阈值内的文本框确定为同行的文本框中具有对应关系的文本框。Based on this, the above-mentioned step S412, that is, the step of determining text boxes with corresponding relationships in the text boxes of the same party based on the position information of the text boxes of the same party, includes: setting the abscissa difference of the starting points in the text boxes of the same party by a preset second second. The text boxes within the threshold are determined to be text boxes with corresponding relationships among the text boxes of the same row.

其中,实际身份证上同行中具有对应关系的文本框之间的距离相较于没有对应关系的文本框间的距离更小,也即同行中具有对应关系的文本框在位置分布上较为相近,故以同行的文本框中起始点横坐标相差值作为文本框间的距离,与预设第二阈值进行比较,将同行的文本框中起始点横坐标相差预设第二阈值内的文本框确定为同行的文本框中具有对应关系的文本框。该预设第二阈值可根据经验值设置,在此不进行限制。Among them, the distance between corresponding text boxes in the same peer group on the actual ID card is smaller than the distance between text boxes that have no corresponding relationship. That is, the corresponding text boxes in the same peer group are relatively similar in location distribution. Therefore, the difference between the abscissa coordinates of the starting points in the text boxes of the same row is used as the distance between the text boxes, and compared with the preset second threshold, the text boxes within the preset second threshold of the difference between the abscissa coordinates of the starting points in the text boxes of the same row are determined. It is a text box with a corresponding relationship among the text boxes of the same row. The preset second threshold can be set based on empirical values and is not limited here.

方式二:Method two:

获取的上述文本框的位置信息包括文本框的纵坐标取值范围和横坐标取值范围;其中,文本框大多为矩形,文本框的纵坐标取值范围和横坐标取值范围可以根据文本框的四个顶点的坐标所确定。The obtained position information of the above-mentioned text box includes the ordinate value range and the abscissa value range of the text box; among them, most text boxes are rectangles, and the ordinate value range and abscissa value range of the text box can be determined according to the text box. Determined by the coordinates of the four vertices.

上述步骤S410可以是通过文本框的纵坐标取值范围确定同行的文本框,具体的,包括如下步骤:将纵坐标取值范围至少具有第一重叠长度的两个文本框确定为同行的文本框。诸如,如果身份证未发生歪斜,则第一文本框的纵坐标取值范围(也即第一文本框的纵边映射到Y轴上的取值范围)与其同行的第二文本框的纵坐标取值范围应当相同(也即,完全重叠),如果身份证发生歪斜,同行的文本框也会相应发生歪斜(具体可参见图2),但第一文本框的纵坐标取值范围与第二文本框的纵坐标取值范围仍旧会有一定程度的重叠。The above step S410 may be to determine the text boxes of the same row according to the ordinate value range of the text box. Specifically, it includes the following steps: determining two text boxes whose ordinate value range has at least a first overlapping length as the text boxes of the same row. . For example, if the ID card is not skewed, the ordinate value range of the first text box (that is, the vertical edge of the first text box is mapped to the value range on the Y-axis) is the ordinate value range of the second text box in the same row. The value range should be the same (that is, completely overlapping). If the ID card is skewed, the text boxes in the same row will also be skewed accordingly (see Figure 2 for details), but the ordinate value range of the first text box is the same as that of the second text box. There will still be a certain degree of overlap in the ordinate value range of the text boxes.

考虑到实际获取的身份证图像存在歪斜的情况,对身份证图像进行文本行检测得到的多个文本框可能歪斜,致使同行的文本框在平面直角坐标系上的纵坐标取值范围无法完全重叠,而是存在一定的偏差,故预先设置第一重叠长度,当两个文本框的纵坐标取值范围的重叠区域大于第一重叠长度时,将前述两个文本框确定为同行的文本框。该第一重叠长度可根据经验值设置,在此不进行限制。Considering that the actually obtained ID card image is skewed, the multiple text boxes obtained by text line detection on the ID card image may be skewed, causing the ordinate value ranges of the same text boxes on the plane rectangular coordinate system to not completely overlap. , but there is a certain deviation, so the first overlapping length is preset. When the overlapping area of the ordinate value range of the two text boxes is greater than the first overlapping length, the two text boxes are determined to be in the same row. The first overlap length can be set based on empirical values and is not limited here.

基于此,上述步骤S412,也即根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框的步骤,包括:根据同行的文本框的横坐标取值范围,确定文本框的横坐标最小值;具体而言,文本框的横坐标最小值也即为文本框的左上角顶点横坐标或左下角顶点横坐标。将同行的文本框中横坐标最小值相差预设第三阈值内的文本框确定为同行的文本框中具有对应关系的文本框。Based on this, the above-mentioned step S412, that is, the step of determining text boxes with corresponding relationships among the text boxes of the same party based on the position information of the text boxes of the same party, includes: determining the text box according to the abscissa value range of the text boxes of the same party. The minimum value of the abscissa coordinate of the text box; specifically, the minimum value of the abscissa coordinate of the text box is the abscissa coordinate of the upper left corner vertex or the lower left corner vertex abscissa of the text box. The text boxes in the text boxes of the same row that differ within a preset third threshold value from the minimum value of the abscissa in the text boxes of the same row are determined to be text boxes with a corresponding relationship in the text boxes of the same row.

其中,实际身份证上同行中具有对应关系的文本框之间的距离相较于没有对应关系的文本框间的距离更小,也即同行中具有对应关系的文本框在位置分布上较为相近,故以同行的文本框中横坐标最小值相差值作为文本框间的距离,与预设第三阈值进行比较,将同行的文本框中起始点横坐标相差预设第三阈值内的文本框确定为同行的文本框中具有对应关系的文本框。该预设第三阈值可根据经验值设置,在此不进行限制。Among them, the distance between corresponding text boxes in the same peer group on the actual ID card is smaller than the distance between text boxes that have no corresponding relationship. That is to say, the position distribution of the corresponding text boxes in the same peer group is relatively similar. Therefore, the difference between the minimum abscissa coordinates of the text boxes in the same row is used as the distance between the text boxes, and compared with the preset third threshold, the text boxes within the preset third threshold of the starting point abscissa difference of the text boxes in the same row are determined. It is a text box with a corresponding relationship among the text boxes of the same row. The preset third threshold can be set based on experience values and is not limited here.

本发明实施例还提供了第三种身份证信息的识别方法,该方法在图1所示的方法的基础上实现,该方法进一步描述了根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息的具体过程,参见图5,该方法包括如下步骤:The embodiment of the present invention also provides a third method for identifying ID card information, which is implemented on the basis of the method shown in FIG. 1 . The method further describes a specific process of determining the ID card information corresponding to the ID card image according to the text information having a corresponding relationship. Referring to FIG. 5 , the method includes the following steps:

步骤S502,获取待识别身份证信息的身份证图像;Step S502, obtain the ID card image of the ID card information to be recognized;

步骤S504,对身份证图像进行文本行检测,得到多个文本框;Step S504: Perform text line detection on the ID card image to obtain multiple text boxes;

步骤S506,获取身份证图像中文本框的位置信息;Step S506, obtaining the position information of the text box in the ID card image;

步骤S510,根据文本框的位置信息和文字信息,确定具有对应关系的文字信息;Step S510, determine text information with a corresponding relationship based on the position information and text information of the text box;

步骤S512,基于具有对应关系的文字信息,确定具有对应关系的文字信息的信息类别;Step S512: Based on the text information with the corresponding relationship, determine the information category of the text information with the corresponding relationship;

诸如,信息类别包括姓名类别、性别类别、民族类别、出生日期类别、住址类别和身份证号码类别中的一种或多种。For example, the information category includes one or more of name category, gender category, ethnicity category, date of birth category, address category and ID number category.

步骤S514,根据信息类别,确定具有对应关系的文字信息中的关键字词以及与关键字词具有对应关系的文字;Step S514, determining the key words in the text information having a corresponding relationship and the text having a corresponding relationship with the key words according to the information category;

其中,关键字词包括姓名、性别、民族、出生、年、月、日、住址和公民身份证号码中的一种或多种。Among them, the key words include one or more of name, gender, ethnicity, birth, year, month, day, address and citizen ID number.

步骤S516,将与关键字词具有对应关系的文字确定为身份证信息。Step S516, determining the text corresponding to the keyword as the ID card information.

具体的,诸如关键字词“姓名”对应文字为“张三”;关键字词“性别”对应文字为“男”;关键字词“民族”对应文字为“汉”,则将与上述关键字词具有对应关系的文字“张三-男-汉”提取出来确定为身份证信息。Specifically, for example, the keyword "name" corresponds to "Zhang San"; the keyword "gender" corresponds to "male"; the keyword "ethnicity" corresponds to "Han", then the text "Zhang San-male-Han" that has a corresponding relationship with the above keywords is extracted and determined as the ID card information.

本发明实施例提供的上述第三种身份证信息的识别方法,首先确定具有对应关系的文字信息的信息类别,然后根据信息类别,确定具有对应关系的文字信息中的关键字词以及与关键字词具有对应关系的文字;进而将与关键字词具有对应关系的文字确定为身份证信息。本发明实施例提供的上述方式通过根据信息类别确定具有对应关系的文字信息中的关键字词,将与关键字词有对应关系的文字确定为身份证信息,能够提取出有效的身份证信息,有助于提升身份证信息识别的准确率。The above-mentioned third identification method of ID card information provided by the embodiment of the present invention first determines the information category of the text information with the corresponding relationship, and then determines the key words in the text information with the corresponding relationship and the keywords according to the information category. The text that has a corresponding relationship with the keyword; then the text that has a corresponding relationship with the key word is determined as the ID card information. The above method provided by the embodiment of the present invention can extract valid ID card information by determining the key words in the text information with corresponding relationships according to the information category, and determining the text with the corresponding relationship with the key words as ID card information. Helps improve the accuracy of identification of ID card information.

进一步考虑到实际应用时,存在待识别的身份证图像可能为非法身份证的身份证图像,本发明实施例提供的上述第三种身份证信息的识别方法还包括:根据信息类别,检查身份证信息是否正确;当检查的结果为否时,发起报错提示。报错提示的方式有多种,诸如,直接将错误的身份证信息置空,或者填写为表征错误的指定值“Error”或其它值,或者也可以直接将错误的身份证信息通过高亮等方式进行标注,任何形式的报错提示方式均可,在此不进行限制。Further considering the practical application, there is an ID card image to be recognized that may be an illegal ID card image. The above-mentioned third identification method of ID card information provided by the embodiment of the present invention also includes: checking the ID card according to the information category. Check whether the information is correct; when the result of the check is no, an error message will be issued. There are many ways to report errors. For example, you can directly leave the wrong ID card information blank, or fill in the specified value "Error" or other values that represent the error, or you can also directly highlight the wrong ID card information. For marking, any form of error prompting method is acceptable, and there are no restrictions here.

在具体实施时,根据信息类别,可通过执行如下判断条件检查身份证信息是否正确:In specific implementation, according to the information category, you can check whether the ID card information is correct by executing the following judgment conditions:

判断条件1:采用身份证信息中身份证号码类别对应的信息检查身份证信息中出生日期类别对应的信息和身份证信息中性别类别对应的信息是否正确。:诸如,身份证号码11-12位及13-14位分别表示出生年、月及日,通过身份证号码上指定位值的数字可核查身份证信息中的出生日期是否正确,此外,身份证号码上某一指定位值的奇偶表征性别,奇数表征男性,偶数表征女性,通过该指定位置的奇偶,则可核查身份证信息中的性别是否正确。Judgment condition 1: Use the information corresponding to the ID card number category in the ID card information to check whether the information corresponding to the date of birth category in the ID card information and the information corresponding to the gender category in the ID card information are correct. :For example, the 11-12 digits and 13-14 digits of the ID card number represent the year, month and day of birth respectively. You can check whether the date of birth in the ID card information is correct by using the specified digits on the ID card number. In addition, the ID card number The odd or even value of a specified position on the number represents gender, the odd number represents male, and the even number represents female. Through the odd or even value of the specified position, you can check whether the gender in the ID card information is correct.

判断条件2:检查身份证信息中性别类别对应的信息是否为预设性别字词之一,其中,预设性别字词包括男或女;Judgment condition 2: Check whether the information corresponding to the gender category in the ID card information is one of the preset gender words, where the preset gender words include male or female;

判断条件3:检查身份证信息中民族类别对应的信息是否为预设民族字词之一,其中,预设民族字词包括合法的民族字词,诸如汉族、回族、满族和维吾尔族等;Judgment condition 3: Check whether the information corresponding to the ethnic category in the ID card information is one of the preset ethnic words, where the preset ethnic words include legal ethnic words, such as Han, Hui, Manchu and Uyghur;

判断条件4:检查身份证信息中出生日期类别对应的信息是否为预设数字之一;其中,预设数字为合法的日期数字。诸如,月份的合法日期数字为1~12,单独天数的合法日期数字为1~31等。Judgment condition 4: Check whether the information corresponding to the date of birth category in the ID card information is one of the preset numbers; where the preset number is a legal date number. For example, the legal date numbers for months are 1 to 12, the legal date numbers for individual days are 1 to 31, etc.

在具体实施时,可以选用上述判断条件的一种或多种来检查身份证信息正确与否。During specific implementation, one or more of the above judgment conditions can be selected to check whether the ID card information is correct or not.

此外,本实施例提供的身份证信息的识别方法还包括:根据身份证信息中身份证号码类别对应的信息判断身份证图像是否合法。In addition, the identification method of ID card information provided in this embodiment also includes: determining whether the ID card image is legal based on the information corresponding to the ID card number category in the ID card information.

诸如,可根据身份证号的编号规则检验身份证号码是否合法,如果否,则该身份证号码类别对应的身份证图像不合法。For example, it can be checked whether the ID number is legal according to the numbering rules of the ID number. If not, the ID card image corresponding to the ID number category is illegal.

具体的,身份证号码共有18位,从左到右各位编号规则如下:1-2位表示省级行政区代码;3-4位表示地级行政区划分代码;5-6位表示县区行政区分代码;7-10位、11-12位及13-14位分别表示出生年、月及日;15-17位表示顺序码,为同一地区同年、同月、同日出生人的编号,其中,奇数是男性,偶数是女性;18位为校验码,通过将身份证号码前17位数分别乘以不同的系数;其中,从第1位到第17位的系数分别为:7-9-10-5-8-4-2-1-6-3-7-9-10-5-8-4-2;将该17位数字和系数相乘的结果相加,再除以11,得到的余数即为前述校验码,其中,余数为0-9时用0-9表示,余数为10时,则用X(罗马数字10)表示。在具体实施时,可以通过上述编码规则来核验提取出的身份证号码是否合法。Specifically, the ID card number has 18 digits, and the numbering rules from left to right are as follows: digits 1-2 represent provincial administrative district codes; digits 3-4 represent prefecture-level administrative district codes; digits 5-6 represent county administrative district codes. ; Digits 7-10, 11-12 and 13-14 respectively represent the year, month and day of birth; digits 15-17 represent the sequence code, which is the number of a person born in the same year, month and day in the same area, among which the odd number is a male , even numbers are women; 18 digits are the check code, by multiplying the first 17 digits of the ID number by different coefficients; among them, the coefficients from the 1st to the 17th digit are: 7-9-10-5 -8-4-2-1-6-3-7-9-10-5-8-4-2; add the result of multiplying the 17-digit number and the coefficient, and then divide it by 11, the remainder is is the aforementioned check code, in which, when the remainder is 0-9, it is represented by 0-9, and when the remainder is 10, it is represented by X (Roman numeral 10). During specific implementation, the above encoding rules can be used to verify whether the extracted ID number is legal.

对应上述第一种身份证信息的识别方法,本发明实施例提供了第一种身份证信息的识别装置,包括:Corresponding to the first identification card information recognition method described above, an embodiment of the present invention provides a first identification card information recognition device, including:

待识别图像获取模块602,用于获取待识别身份证信息的身份证图像;The image to be recognized acquisition module 602 is used to obtain the ID card image of the ID card information to be recognized;

文本行检测模块604,用于对身份证图像进行文本行检测,得到多个文本框;The text line detection module 604 is used to detect text lines on the ID card image to obtain multiple text boxes;

位置信息获取模块606,用于获取身份证图像中文本框的位置信息;The location information acquisition module 606 is used to obtain the location information of the text box in the ID card image;

文字识别模块608,用于对文本框进行文字识别,得到文本框对应的文字信息;The text recognition module 608 is used to perform text recognition on the text box and obtain the text information corresponding to the text box;

对应关系确定模块610,用于根据文本框的位置信息和文字信息,确定具有对应关系的文字信息;Correspondence determination module 610 is used to determine text information with corresponding relationships based on the position information and text information of the text box;

身份证信息确定模块612,用于根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。The ID card information determination module 612 is used to determine the ID card information corresponding to the ID card image according to the text information having a corresponding relationship.

本发明提供了第一种身份证信息的识别装置,能够首先对待识别身份证信息的身份证图像进行文本行检测,得到多个文本框;然后获取身份证图像中文本框的位置信息以及文本框对应的文字信息,进而根据文本框的位置信息和文字信息,确定具有对应关系的文字信息,并根据具有对应关系的文字信息,确定与身份证图像对应的身份证信息。与现有技术中大多直接对身份证图像上的文字进行识别而提取身份证信息,因身份证图像上文字零散、添加有水印或身份证图像倾斜等原因而存在提取到错误的身份证信息的问题相比,本发明实施例能够先检测身份证图像上的文本框,然后根据文本框的位置信息和文字信息,确定有对应关系的文字信息,能够避免提取到错误的身份证信息,有效地提升了身份证信息的识别准确率。The present invention provides a first identification device for ID card information, which can first perform text line detection on an ID card image to be recognized to obtain multiple text boxes; and then obtain the position information of the text box and the text box in the ID card image. The corresponding text information is determined based on the position information and text information of the text box, and the corresponding text information is determined, and the ID card information corresponding to the ID card image is determined based on the corresponding text information. Unlike the existing technology, which mostly directly recognizes the text on the ID card image to extract the ID card information, the wrong ID card information may be extracted due to reasons such as scattered text on the ID card image, watermarks added or the ID card image being tilted. Compared with the problem, the embodiment of the present invention can first detect the text box on the ID card image, and then determine the corresponding text information based on the position information and text information of the text box, which can avoid extracting the wrong ID card information and effectively Improved the recognition accuracy of ID card information.

在一种实施方式中,上述文本行检测模块包括如下单元:In one implementation, the text line detection module includes the following units:

身份证倾斜判断单元,用于获取身份证图像的顶点坐标,根据身份证图像的顶点坐标判断身份证图像是否倾斜;The ID card tilt determination unit is used to obtain the vertex coordinates of the ID card image and determine whether the ID card image is tilted based on the vertex coordinates of the ID card image;

图像调正单元,用于当身份证倾斜判断单元的判断结果为是时,调正身份证图像;An image correction unit, used for correcting the ID card image when the judgment result of the ID card tilt judgment unit is yes;

其中,调正后的身份证图像的左上角顶点横坐标与左下角顶点横坐标相同,且左上角顶点纵坐标与右上角顶点纵坐标相同,且左上角顶点与右上角顶点之间的距离大于左上角顶点与左下角顶点之间的距离;The horizontal coordinate of the upper left corner vertex of the adjusted ID card image is the same as the horizontal coordinate of the lower left corner vertex, the vertical coordinate of the upper left corner vertex is the same as the vertical coordinate of the upper right corner vertex, and the distance between the upper left corner vertex and the upper right corner vertex is greater than the distance between the upper left corner vertex and the lower left corner vertex;

文本行检测单元,用于对调正后的身份证图像进行文本行检测,得到多个文本框。The text line detection unit is used to detect text lines on the corrected ID card image to obtain multiple text boxes.

在一种具体实施方式中,上述文本行检测模块还用于通过CTPN网络模型对身份证图像进行文本行检测,得到多个文本框。In a specific implementation, the above text line detection module is also used to detect text lines on the ID card image through the CTPN network model to obtain multiple text boxes.

在一种实施方式中,上述位置信息获取模块包括:坐标获取单元,获取身份证图像中文本框的顶点坐标;文本框倾斜判断单元,用于根据文本框的顶点坐标,判断文本框是否倾斜;文本框调正单元,用于当文本框倾斜判断单元的判断结果为是时,调正文本框;位置信息获取单元,用于获取调正后的文本框的位置信息。In one implementation, the above-mentioned position information acquisition module includes: a coordinate acquisition unit, which acquires the vertex coordinates of the text box in the ID card image; a text frame tilt determination unit, used to determine whether the text box is tilted based on the vertex coordinates of the text box; The text box adjustment unit is used to adjust the text box when the judgment result of the text box tilt judgment unit is yes; the position information acquisition unit is used to obtain the position information of the adjusted text box.

在一种具体实施方式中,上述文字信息确定模块还用于:通过CRNN网络模型对文本框进行文字识别,得到文本框对应的文字信息。In a specific implementation, the above-mentioned text information determination module is also used to perform text recognition on the text box through a CRNN network model to obtain text information corresponding to the text box.

进一步,上述第一种身份证信息的识别方法装置还包括非法文本框删除模块,用于在对文本框进行文字识别之前,根据文本框的位置信息与预先设置的身份证文本框的合法位置,判断是否存在位置非法的文本框;当存在位置非法的文本框时,将位置非法的文本框删除。Furthermore, the above-mentioned first ID card information identification method device also includes an illegal text box deletion module, which is used to, before performing text recognition on the text box, based on the position information of the text box and the preset legal position of the ID card text box, Determine whether there is a text box with an illegal position; when there is a text box with an illegal position, delete the text box with an illegal position.

此外,上述第一种身份证信息的识别方法装置还包括非法文字信息过滤模块,用于在确定具有对应关系的文字信息之前,根据文本框的位置信息和文字信息,识别并过滤身份证图像上的非法文字信息;其中,非法文字信息所在的文本框的位置不属于预先设置的身份证文本框的合法位置。In addition, the above-mentioned first ID card information identification method device also includes an illegal text information filtering module, which is used to identify and filter the illegal text information on the ID card image based on the position information and text information of the text box before determining the text information with the corresponding relationship. The illegal text information; among them, the position of the text box where the illegal text information is located does not belong to the legal position of the preset ID card text box.

对应上述第二种身份证信息的识别方法,本发明实施例提供了第二种身份证信息的识别装置,该装置在图6所示的装置基础上,进一步示出了对应关系确定模块610的具体结构,参见图7,该对应关系确定模块610包括:Corresponding to the above-mentioned second identification method of ID card information, embodiments of the present invention provide a second identification device of ID card information. Based on the device shown in Figure 6, this device further shows the corresponding relationship determination module 610. For the specific structure, see Figure 7. The correspondence determination module 610 includes:

同行文本框确定单元702,用于根据文本框的位置信息,确定同行的文本框;The peer text box determination unit 702 is used to determine the peer text box according to the position information of the text box;

对应文本框确定单元704,用于根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框。The corresponding text box determining unit 704 is configured to determine, based on the position information of the text boxes of the same party, the text boxes that have a corresponding relationship among the text boxes of the same party.

对应文字信息确定单元706,用于根据具有对应关系的文本框,以及文本框的文字信息,确定具有对应关系的文字信息。The corresponding text information determining unit 706 is used to determine text information with a corresponding relationship based on the text boxes with the corresponding relationship and the text information of the text boxes.

本发明实施例提供的上述第二种身份证信息的识别装置,首先根据文本框的位置信息,确定同行的文本框,然后根据同行的文本框的位置信息,确定同行的文本框中具有对应关系的文本框;进而根据具有对应关系的文本框,以及文本框的文字信息,确定具有对应关系的文字信息。本发明实施例通过先确定文本框的对应关系,然后再结合文本框的文字信息确定具有对应关系的文字信息,有助于提升身份证信息识别的准确率。The above-mentioned second identification device for ID card information provided by the embodiment of the present invention first determines the text box of the peer based on the position information of the text box, and then determines that the text box of the peer has a corresponding relationship based on the position information of the text box of the peer. the text box; and then determine the text information with the corresponding relationship based on the text box with the corresponding relationship and the text information of the text box. The embodiment of the present invention helps to improve the accuracy of identification of ID card information by first determining the corresponding relationship of the text box, and then combining the text information of the text box to determine the text information with the corresponding relationship.

在一种具体实施方式中,当上述文本框的位置信息包括文本框的起始点坐标,起始点坐标包括起始横坐标和起始纵坐标时,同行文本框确定单元还用于将起始点纵坐标相差预设第一阈值内的文本框确定为同行的文本框。基于此,上述对应文本框确定单元还用于将同行的文本框中起始点横坐标相差预设第二阈值内的文本框确定为同行的文本框中具有对应关系的文本框。In a specific implementation, when the position information of the text box includes the starting point coordinates of the text box, and the starting point coordinates include the starting abscissa and the starting ordinate, the peer text box determination unit is also used to change the starting point vertically. Text boxes whose coordinates differ within a preset first threshold are determined to be text boxes of the same row. Based on this, the above-mentioned corresponding text box determination unit is also used to determine the text boxes in the text boxes of the same row whose starting point abscissas differ within a preset second threshold as the text boxes in the text boxes of the same row that have a corresponding relationship.

在另一种具体实施方式中,当上述文本框的位置信息包括文本框的纵坐标取值范围和横坐标取值范围时,同行文本框确定单元还用于将纵坐标取值范围至少具有第一重叠长度的两个文本框确定为同行的文本框;基于此,上述对应文本框确定单元还用于根据同行的文本框的横坐标取值范围,确定文本框的横坐标最小值;将同行的文本框中横坐标最小值相差预设第三阈值内的文本框确定为同行的文本框中具有对应关系的文本框。In another specific embodiment, when the position information of the above-mentioned text box includes the vertical coordinate value range and the horizontal coordinate value range of the text box, the same-line text box determination unit is also used to determine two text boxes whose vertical coordinate value ranges have at least a first overlapping length as text boxes in the same line; based on this, the above-mentioned corresponding text box determination unit is also used to determine the minimum horizontal coordinate value of the text box according to the horizontal coordinate value range of the text boxes in the same line; and determine the text boxes whose horizontal coordinate minimum values among the text boxes in the same line differ by a preset third threshold as text boxes in the same line with corresponding relationships.

上述对应文字信息确定单元还用于根据具有对应关系的文本框,以及文本框的文字信息,检查文本框的对应关系是否正确;将具有正确对应关系的文本框的文字信息确定为具有对应关系的文字信息。The above-mentioned corresponding text information determination unit is also used to check whether the corresponding relationship of the text box is correct based on the text box with the corresponding relationship and the text information of the text box; and determine the text information of the text box with the correct corresponding relationship as having the corresponding relationship. text information.

对应上述第三种身份证信息的识别方法,本发明实施力提供了第三种身份证信息的识别装置,该装置在图6所示的装置基础上,进一步示出了身份证信息确定模块612的具体结构,参见图8,该身份证信息确定模块612包括:Corresponding to the above-mentioned third identification method of ID card information, the implementation force of the present invention provides a third identification device of ID card information. Based on the device shown in Figure 6, this device further shows an ID card information determination module 612. For the specific structure, see Figure 8. The ID card information determination module 612 includes:

信息类别确定单元802,用于基于具有对应关系的文字信息,确定具有对应关系的文字信息的信息类别;信息类别包括姓名类别、性别类别、民族类别、出生日期类别、住址类别和身份证号码类别中的一种或多种;The information category determination unit 802 is used to determine the information category of the text information with the corresponding relationship based on the text information with the corresponding relationship; the information category includes the name category, gender category, ethnic category, date of birth category, address category and ID number category. one or more of;

关键字词及对应文字确定单元804,用于根据信息类别,确定具有对应关系的文字信息中的关键字词以及与关键字词具有对应关系的文字;其中,关键字词包括姓名、性别、民族、出生、年、月、日、住址和公民身份证号码中的一种或多种;The key words and corresponding text determination unit 804 is used to determine the key words in the text information with corresponding relationships and the text with corresponding relationships with the key words according to the information category; wherein the key words include name, gender, ethnicity , one or more of birth, year, month, day, address and citizen ID number;

身份证信息确定单元806,用于将与关键字词具有对应关系的文字确定为身份证信息。The identity card information determining unit 806 is used to determine the text corresponding to the keyword as the identity card information.

本发明实施例提供的上述第三种身份证信息的识别装置,首先确定具有对应关系的文字信息的信息类别,然后根据信息类别,确定具有对应关系的文字信息中的关键字词以及与关键字词具有对应关系的文字;进而将与关键字词具有对应关系的文字确定为身份证信息。本发明实施例通过根据信息类别确定具有对应关系的文字信息中的关键字词,将与关键字词有对应关系的文字确定为身份证信息,能够提取出有效的身份证信息,有助于提升身份证信息识别的准确率。The above-mentioned third identification device for ID card information provided by the embodiment of the present invention first determines the information category of the text information with the corresponding relationship, and then determines the keywords in the text information with the corresponding relationship and the keywords based on the information category. The text that has a corresponding relationship with the keyword; then the text that has a corresponding relationship with the key word is determined as the ID card information. The embodiment of the present invention determines the key words in the text information with corresponding relationships according to the information category, and determines the words corresponding to the key words as ID card information, which can extract valid ID card information and help improve the quality of the information. The accuracy of identification of ID card information.

进一步,上述第三种身份证信息的识别装置还包括检查模块及报错模块;其中,检查模块,用于根据信息类别,检查身份证信息是否正确;报错模块,用于当检查模块的判断结果为否时,发起报错提示。Furthermore, the above-mentioned third identification device for ID card information also includes a checking module and an error reporting module; wherein, the checking module is used to check whether the ID card information is correct according to the information category; and the error reporting module is used when the judgment result of the checking module is If not, an error message will be issued.

具体的,上述检查模块还用于采用身份证信息中身份证号码类别对应的信息检查身份证信息中出生日期类别对应的信息和身份证信息中性别类别对应的信息是否正确;和/或,检查身份证信息中性别类别对应的信息是否为预设性别字词之一,其中,预设性别字词包括男或女;和/或,检查身份证信息中民族类别对应的信息是否为预设民族字词之一,其中,预设民族字词包括合法的民族字词;和/或,检查身份证信息中出生日期类别对应的信息是否为预设数字之一;其中,预设数字为合法的日期数字。Specifically, the above-mentioned inspection module is also used to use the information corresponding to the ID card number category in the ID card information to check whether the information corresponding to the date of birth category in the ID card information and the information corresponding to the gender category in the ID card information are correct; and/or, to check whether the information corresponding to the gender category in the ID card information is one of the preset gender words, wherein the preset gender words include male or female; and/or, to check whether the information corresponding to the ethnic category in the ID card information is one of the preset ethnic words, wherein the preset ethnic words include legal ethnic words; and/or, to check whether the information corresponding to the date of birth category in the ID card information is one of the preset numbers; wherein the preset numbers are legal date numbers.

进一步,上述第三种身份证信息的识别装置还包括合法判断模块,用于根据身份证信息中身份证号码类别对应的信息判断身份证图像是否合法。Furthermore, the above-mentioned third identification device for ID card information also includes a legality judgment module, which is used to determine whether the ID card image is legal based on the information corresponding to the ID card number category in the ID card information.

本实施例所提供的上述装置,其实现原理及产生的技术效果和前述实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。The implementation principle and technical effects of the above-mentioned device provided in this embodiment are the same as those in the previous embodiment. This is a brief description. For matters not mentioned in the device embodiment, please refer to the corresponding content in the above-mentioned method embodiment.

进一步,本实施例还提供了一种终端设备,该终端设备包括处理器和存储器,其中,存储器用于存储一条或多条计算机指令,一条或多条计算机指令被处理器执行,以实现上述身份证信息的识别方法。Furthermore, this embodiment also provides a terminal device, which includes a processor and a memory, wherein the memory is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor to realize the above identity. How to identify certification information.

参见图9所示的一种终端设备的结构示意图,示出了终端设备900,包括:处理器90,存储器91,总线92和通信接口93,处理器90、通信接口93和存储器91通过总线92连接;处理器90用于执行存91中存储的可执行模块,例如计算机程序。Referring to the schematic structural diagram of a terminal device shown in Figure 9, the terminal device 900 is shown, including: a processor 90, a memory 91, a bus 92 and a communication interface 93. The processor 90, the communication interface 93 and the memory 91 pass through the bus 92 Connection; processor 90 is used to execute executable modules stored in memory 91, such as computer programs.

其中,存储器91可能包含高速随机存取存储器(RAM,Random Access Memory),也可能还包括非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。通过至少一个通信接口93(可以是有线或者无线)实现该系统网元与至少一个其他网元之间的通信连接,可以使用互联网,广域网,本地网,城域网等。The memory 91 may include high-speed random access memory (RAM), or may also include non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 93 (which can be wired or wireless), and the Internet, wide area network, local network, metropolitan area network, etc. can be used.

总线92可以是ISA总线、PCI总线或EISA总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The bus 92 may be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of presentation, only one bidirectional arrow is used in Figure 9, but it does not mean that there is only one bus or one type of bus.

其中,存储器91用于存储程序,所述处理器90在接收到执行指令后,执行所述程序,前述本发明实施例任一实施例揭示的流过程定义的装置所执行的方法可以应用于处理器90中,或者由处理器90实现。The memory 91 is used to store the program. The processor 90 executes the program after receiving the execution instruction. The method executed by the device for stream process definition disclosed in any of the embodiments of the present invention can be applied to processing. in the processor 90, or implemented by the processor 90.

处理器90可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器90中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器90可以是通用处理器,包括中央处理器(Central Processing Unit,简称CPU)、网络处理器(Network Processor,简称NP)等;还可以是数字信号处理器(Digital SignalProcessing,简称DSP)、专用集成电路(Application Specific Integrated Circuit,简称ASIC)、现成可编程门阵列(Field-Programmable Gate Array,简称FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器91,处理器90读取存储器91中的信息,结合其硬件完成上述方法的步骤。The processor 90 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above method can be completed by instructions in the form of hardware integrated logic circuits or software in the processor 90 . The above-mentioned processor 90 can be a general-purpose processor, including a Central Processing Unit (CPU for short), a Network Processor (NP for short), etc.; it can also be a Digital Signal Processing (DSP for short) , Application Specific Integrated Circuit (ASIC for short), Field-Programmable Gate Array (FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. Each method, step and logical block diagram disclosed in the embodiment of the present invention can be implemented or executed. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly implemented by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other mature storage media in this field. The storage medium is located in the memory 91. The processor 90 reads the information in the memory 91 and completes the steps of the above method in combination with its hardware.

进一步,本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述任一项身份证信息的识别方法的步骤。具体实现可参见方法实施例,在此不再赘述。Furthermore, embodiments of the present invention also provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, the steps of any of the above identification methods for ID card information are executed. For specific implementation, please refer to the method embodiments and will not be described again here.

本发明实施例所提供的身份证信息的识别方法、装置以及终端设备的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行前面方法实施例中所述的方法,具体实现可参见方法实施例,在此不再赘述。The identification method, device, and computer program product for terminal equipment provided by the embodiments of the present invention include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the previous method embodiments. The specific implementation of the method can be found in the method embodiments and will not be described again here.

另外,在本发明实施例的描述中,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通。对于本领域的普通技术人员而言,可以具体情况理解上述术语在本发明中的具体含义。In addition, in the description of the embodiments of the present invention, unless otherwise clearly stated and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense. For example, it can be a fixed connection or a detachable connection. , or integrally connected; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be an internal connection between two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood on a case-by-case basis.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code. .

在本发明的描述中,需要说明的是,术语“中心”、“上”、“下”、“左”、“右”、“竖直”、“水平”、“内”、“外”等指示的方位或位置关系为基于附图所示的方位或位置关系,仅是为了便于描述本发明和简化描述,而不是指示或暗示所指的装置或元件必须具有特定的方位、以特定的方位构造和操作,因此不能理解为对本发明的限制。此外,术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性。In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

最后应说明的是:以上所述实施例,仅为本发明的具体实施方式,用以说明本发明的技术方案,而非对其限制,本发明的保护范围并不局限于此,尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的精神和范围,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present invention and are used to illustrate the technical solutions of the present invention rather than to limit them. The protection scope of the present invention is not limited thereto. Although refer to the foregoing The embodiments illustrate the present invention in detail. Those of ordinary skill in the art should understand that any person familiar with the technical field can still modify the technical solutions recorded in the foregoing embodiments within the technical scope disclosed by the present invention. It may be easy to think of changes, or equivalent substitutions of some of the technical features; and these modifications, changes or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and they should all be included in the present invention. within the scope of protection. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims (17)

1. The identification method of the identity card information is characterized by comprising the following steps:
acquiring an identity card image of identity card information to be identified;
performing text line detection on the identity card image to obtain a plurality of text boxes;
acquiring the position information of the text box in the identity card image;
Performing character recognition on the text box to obtain character information corresponding to the text box;
determining text information with a corresponding relation according to the position information and the text information of the text box;
according to the text information with the corresponding relation, determining the identity card information corresponding to the identity card image;
the step of determining the text information with the corresponding relation according to the position information and the text information of the text box comprises the following steps:
determining the text boxes of the same line according to the position information of the text boxes;
determining text boxes with corresponding relations in the text boxes of the same line according to the position information of the text boxes of the same line;
and determining the text information with the corresponding relation according to the text box with the corresponding relation and the text information of the text box.
2. The method of claim 1, wherein the step of performing text line detection on the identification card image to obtain a plurality of text boxes comprises:
acquiring vertex coordinates of the identity card image, and judging whether the identity card image is inclined or not according to the vertex coordinates of the identity card image;
if yes, the identity card image is regulated;
And detecting the text lines of the aligned identity card images to obtain a plurality of text boxes.
3. The method of claim 1, wherein the step of performing text line detection on the identification card image to obtain a plurality of text boxes comprises:
and detecting the text lines of the identity card image through a CTPN network model to obtain a plurality of text boxes.
4. The method of claim 1, wherein the step of obtaining location information of the text box in the identification card image comprises:
obtaining vertex coordinates of the text box in the identity card image;
judging whether the text box is inclined or not according to the vertex coordinates of the text box;
if yes, the text box is adjusted;
and acquiring the position information of the aligned text box.
5. The method of claim 1, wherein the step of performing text recognition on the text box to obtain text information corresponding to the text box comprises:
and carrying out character recognition on the text box through the CRNN network model to obtain character information corresponding to the text box.
6. The method of claim 1, wherein the location information of the text box comprises a start point coordinate of the text box, the start point coordinate comprising a start abscissa and a start ordinate;
The step of determining the text boxes of the same line according to the position information of the text boxes comprises the following steps:
determining the text boxes within a preset first threshold value of the difference of the ordinate of the starting point as the text boxes of the same row;
the step of determining the text boxes with the corresponding relation in the text boxes of the same line according to the position information of the text boxes of the same line comprises the following steps:
and determining the text boxes in the starting point abscissa differences among the text boxes in the same row within a preset second threshold as the text boxes with corresponding relations among the text boxes in the same row.
7. The method of claim 1, wherein the location information of the text box includes an ordinate range and an abscissa range of values of the text box;
the step of determining the text boxes of the same line according to the position information of the text boxes comprises the following steps:
determining two text boxes with at least a first overlapping length in the ordinate value range as the text boxes in the same row;
the step of determining the text boxes with the corresponding relation in the text boxes of the same line according to the position information of the text boxes of the same line comprises the following steps:
determining the minimum value of the abscissa of the text boxes according to the value range of the abscissa of the text boxes in the same row;
And determining the text boxes in the minimum difference of the abscissa values in the text boxes in the same row within a preset third threshold as the text boxes with corresponding relations in the text boxes in the same row.
8. The method according to claim 1, wherein the step of determining text information having a correspondence relationship from the text box having a correspondence relationship and text information of the text box includes:
checking whether the corresponding relation of the text box is correct or not according to the text box with the corresponding relation and the text information of the text box;
and determining the text information of the text box with the correct corresponding relation as the text information with the corresponding relation.
9. The method of claim 1, wherein the step of determining the identification card information corresponding to the identification card image according to the text information having the correspondence relationship comprises:
determining information category of the text information with the corresponding relation based on the text information with the corresponding relation; the information category comprises one or more of a name category, a gender category, a ethnicity category, a birth date category, an address category and an identification card number category;
According to the information category, determining key words in the text information with the corresponding relation and text with the corresponding relation with the key words; wherein the key words comprise one or more of name, gender, ethnicity, birth, year, month, day, address and citizen ID card number;
and determining the characters with the corresponding relation with the key words as identity card information.
10. The method according to claim 9, wherein the method further comprises:
checking whether the identity card information is correct according to the information category;
if not, initiating error reporting prompt.
11. The method of claim 10, wherein the step of checking whether the identification card information is correct based on the information category comprises:
checking whether information corresponding to the birth date category in the identity card information and information corresponding to the neutral category in the identity card information are correct or not by adopting the information corresponding to the identity card number category in the identity card information;
and/or the number of the groups of groups,
checking whether the information corresponding to the gender category in the identity card information is one of preset gender words, wherein the preset gender words comprise men or women;
And/or the number of the groups of groups,
checking whether the information corresponding to the national category in the identity card information is one of preset national words, wherein the preset national words comprise legal national words;
and/or the number of the groups of groups,
checking whether the information corresponding to the birth date category in the identity card information is one of preset numbers or not; wherein the preset number is a legal date number.
12. The method according to claim 10, wherein the method further comprises:
judging whether the identity card image is legal or not according to the information corresponding to the identity card number category in the identity card information.
13. The method of claim 1, wherein prior to the step of text recognition of the text box, the method further comprises:
judging whether a text box with illegal positions exists or not according to the position information of the text box and the legal positions of the preset identity card text boxes;
if yes, deleting the text box with illegal position.
14. The method of claim 1, wherein prior to the step of determining text information having a correspondence, the method further comprises:
identifying and filtering illegal character information on the identity card image according to the position information and the character information of the text box; the position of the text box where the illegal word information is located does not belong to the legal position of the preset identity card text box.
15. An identification device for identification card information, comprising:
the image acquisition module to be identified is used for acquiring an identity card image of the identity card information to be identified;
the text line detection module is used for detecting the text lines of the identity card image to obtain a plurality of text boxes;
the position information acquisition module is used for acquiring the position information of the text box in the identity card image;
the text recognition module is used for recognizing the text box to obtain text information corresponding to the text box;
the corresponding relation determining module is used for determining text information with a corresponding relation according to the position information and the text information of the text box;
the identity card information determining module is used for determining identity card information corresponding to the identity card image according to the text information with the corresponding relation;
the correspondence determining module includes:
the same-line text box determining unit is used for determining the text boxes of the same line according to the position information of the text boxes;
the corresponding text box determining unit is used for determining text boxes with corresponding relations in the text boxes of the same line according to the position information of the text boxes of the same line;
And the corresponding text information determining unit is used for determining text information with a corresponding relation according to the text box with the corresponding relation and the text information of the text box.
16. A terminal device, characterized in that it comprises a memory for storing a program supporting the processor to perform the method of any one of claims 1 to 14, and a processor configured to execute the program stored in the memory.
17. A computer storage medium storing computer software instructions for use with the method of any one of claims 1 to 14.
CN201811317603.9A 2018-11-06 2018-11-06 Identification method, device, terminal equipment and storage medium for ID card information Active CN111144400B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811317603.9A CN111144400B (en) 2018-11-06 2018-11-06 Identification method, device, terminal equipment and storage medium for ID card information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811317603.9A CN111144400B (en) 2018-11-06 2018-11-06 Identification method, device, terminal equipment and storage medium for ID card information

Publications (2)

Publication Number Publication Date
CN111144400A CN111144400A (en) 2020-05-12
CN111144400B true CN111144400B (en) 2024-03-29

Family

ID=70516542

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811317603.9A Active CN111144400B (en) 2018-11-06 2018-11-06 Identification method, device, terminal equipment and storage medium for ID card information

Country Status (1)

Country Link
CN (1) CN111144400B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111985465B (en) * 2020-08-17 2024-09-06 中移(杭州)信息技术有限公司 Text recognition method, device, equipment and storage medium
CN112185520B (en) * 2020-09-27 2024-06-07 志诺维思(北京)基因科技有限公司 Text structuring processing system and method for medical pathology report picture
CN112396060B (en) * 2020-11-17 2024-03-15 中国平安人寿保险股份有限公司 Identification card recognition method based on identification card segmentation model and related equipment thereof
CN112434633B (en) * 2020-12-02 2025-04-18 携程计算机技术(上海)有限公司 Driver's license information recognition method, device, electronic device and storage medium
CN112836470B (en) * 2021-02-25 2024-08-13 珠海金山办公软件有限公司 Typesetting method and device for documents
CN112949523A (en) * 2021-03-11 2021-06-11 兴业银行股份有限公司 Method and system for extracting key information from identity card image picture
CN113065423A (en) * 2021-03-19 2021-07-02 国网电子商务有限公司 Ticket key information extraction method and device based on deep learning
CN114038004A (en) * 2021-11-19 2022-02-11 北京恒安嘉新安全技术有限公司 A method, device, device and storage medium for extracting certificate information
CN115471841B (en) * 2022-08-10 2025-08-29 北京结慧科技有限公司 Image recognition method, image review method and electronic equipment
CN118036597B (en) * 2024-02-23 2024-11-08 重庆亲笔签数字科技有限公司 Structured information extraction method, system and medium based on self-adaptive space measurement
CN118262375B (en) * 2024-03-01 2025-01-14 北京健康有益科技有限公司 Method and device for extracting index measurement value of medical instrument

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488984A (en) * 2013-10-11 2014-01-01 从兴技术有限公司 Method and device for identifying second-generation identity cards based on intelligent mobile equipment
CN106295629A (en) * 2016-07-15 2017-01-04 北京市商汤科技开发有限公司 Structured text detection method and system
CN106326888A (en) * 2016-08-16 2017-01-11 北京旷视科技有限公司 Image recognition method and device
WO2017069385A1 (en) * 2015-10-23 2017-04-27 주식회사 피노텍 Identification recognition device using mobile device
CN106886774A (en) * 2015-12-16 2017-06-23 腾讯科技(深圳)有限公司 The method and apparatus for recognizing ID card information
CN107247950A (en) * 2017-06-06 2017-10-13 电子科技大学 A kind of ID Card Image text recognition method based on machine learning
CN107346427A (en) * 2017-06-23 2017-11-14 浙江大华技术股份有限公司 A kind of ID card No. recognition methods and device
CN108154132A (en) * 2018-01-10 2018-06-12 马上消费金融股份有限公司 Method, system and equipment for extracting characters of identity card and storage medium
CN108229299A (en) * 2017-10-31 2018-06-29 北京市商汤科技开发有限公司 The recognition methods of certificate and device, electronic equipment, computer storage media
CN108304761A (en) * 2017-09-25 2018-07-20 腾讯科技(深圳)有限公司 Method for text detection, device, storage medium and computer equipment
CN108717543A (en) * 2018-05-14 2018-10-30 北京市商汤科技开发有限公司 An invoice identification method and device, and computer storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8995774B1 (en) * 2013-09-19 2015-03-31 IDChecker, Inc. Automated document recognition, identification, and data extraction

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103488984A (en) * 2013-10-11 2014-01-01 从兴技术有限公司 Method and device for identifying second-generation identity cards based on intelligent mobile equipment
WO2017069385A1 (en) * 2015-10-23 2017-04-27 주식회사 피노텍 Identification recognition device using mobile device
CN106886774A (en) * 2015-12-16 2017-06-23 腾讯科技(深圳)有限公司 The method and apparatus for recognizing ID card information
CN106295629A (en) * 2016-07-15 2017-01-04 北京市商汤科技开发有限公司 Structured text detection method and system
CN106326888A (en) * 2016-08-16 2017-01-11 北京旷视科技有限公司 Image recognition method and device
CN107247950A (en) * 2017-06-06 2017-10-13 电子科技大学 A kind of ID Card Image text recognition method based on machine learning
CN107346427A (en) * 2017-06-23 2017-11-14 浙江大华技术股份有限公司 A kind of ID card No. recognition methods and device
CN108304761A (en) * 2017-09-25 2018-07-20 腾讯科技(深圳)有限公司 Method for text detection, device, storage medium and computer equipment
CN108229299A (en) * 2017-10-31 2018-06-29 北京市商汤科技开发有限公司 The recognition methods of certificate and device, electronic equipment, computer storage media
CN108154132A (en) * 2018-01-10 2018-06-12 马上消费金融股份有限公司 Method, system and equipment for extracting characters of identity card and storage medium
CN108717543A (en) * 2018-05-14 2018-10-30 北京市商汤科技开发有限公司 An invoice identification method and device, and computer storage medium

Also Published As

Publication number Publication date
CN111144400A (en) 2020-05-12

Similar Documents

Publication Publication Date Title
CN111144400B (en) Identification method, device, terminal equipment and storage medium for ID card information
CN112016438B (en) Method and system for identifying certificate based on graph neural network
CN107798299B (en) Bill information identification method, electronic device and readable storage medium
CN109726643B (en) Method, device, electronic device and storage medium for identifying table information in images
CN109657673B (en) Image recognition method and terminal
US9418304B2 (en) System and method for recognizing text information in object
CN111639648B (en) Certificate identification method, device, computing equipment and storage medium
CN114005126B (en) Table reconstruction method, device, computer equipment and readable storage medium
WO2021012382A1 (en) Method and apparatus for configuring chat robot, computer device and storage medium
WO2021110174A1 (en) Image recognition method and device, electronic device, and storage medium
CN106326802B (en) Quick Response Code bearing calibration, device and terminal device
CN112597940B (en) Certificate image recognition method and device and storage medium
CN112989768B (en) Method, device, electronic device and storage medium for correcting multiple-line questions
US20180268212A1 (en) Information processing apparatus, information processing system, and non-transitory computer readable medium
CN111767889A (en) Formula recognition method, electronic device and computer readable medium
CN112396047B (en) Training sample generation method and device, computer equipment and storage medium
CN107305682B (en) Method and apparatus for stitching images
CN111241974B (en) Bill information acquisition method, device, computer equipment and storage medium
CN112784494A (en) Training method of false positive recognition model, target recognition method and device
CN111768346A (en) Method, device and equipment for correcting back image of identity card and storage medium
CN115083024A (en) Signature identification method, device, medium and equipment based on region division
CN111582259B (en) Machine-readable code identification method, device, electronic equipment and storage medium
CN111768345A (en) Method, device and equipment for correcting back image of identity card and storage medium
CN114299509B (en) A method, device, equipment and medium for obtaining information
CN116311257A (en) OCR recognition method and system for text with any angle and any shape

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant