CN111914836A - Identity card information extraction method, device, equipment and medium - Google Patents

Identity card information extraction method, device, equipment and medium Download PDF

Info

Publication number
CN111914836A
CN111914836A CN202010653020.4A CN202010653020A CN111914836A CN 111914836 A CN111914836 A CN 111914836A CN 202010653020 A CN202010653020 A CN 202010653020A CN 111914836 A CN111914836 A CN 111914836A
Authority
CN
China
Prior art keywords
identity card
region
card image
determining
sub
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.)
Pending
Application number
CN202010653020.4A
Other languages
Chinese (zh)
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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua 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 Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202010653020.4A priority Critical patent/CN111914836A/en
Publication of CN111914836A publication Critical patent/CN111914836A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR 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/148Segmentation of character regions
    • G06V30/153Segmentation of character regions using recognition of characters or words
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V30/00Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
    • G06V30/10Character recognition

Abstract

The invention discloses an identity card information extraction method, an identity card information extraction device, identity card information extraction equipment and an identity card information extraction medium. Therefore, when the background color of the identity card image is close to the identity color or the image quality of the identity card image is poor, accurate inclination correction of the identity card image can be realized, and the robustness and the extraction precision of the identity card information extraction method are improved.

Description

Identity card information extraction method, device, equipment and medium
Technical Field
The invention relates to the technical field of image recognition, in particular to an identity card information extraction method, device, equipment and medium.
Background
The identity card is a main identity mark of residents in China, and can comprise an identity card identification method based on magnetic card induction and an identity card identification method based on image processing when the identity card is identified.
In the identification card identification method based on magnetic card induction, identification cards are mainly identified through an identification card reader with magnetic card induction. The identity card reader has strong universality and high accuracy, is not convenient to carry, and is commonly used in office halls in the fields of public security, banks, civil administration and the like.
In the identification card identification method based on image processing, an identification card image is shot mainly by equipment with a camera, such as a mobile phone, a flat panel and the like, and the identification card image is transmitted to an identification card identification system to output an identification result of an identification card element. The identification method can be used anytime and anywhere without carrying extra equipment, for example, in the process of outgoing account opening of bank workers, the identification method identifies the identity card of a new customer through the application on a mobile phone, and quickly inputs the identified identity card information. But the method has the disadvantage of low recognition rate in complex scenes.
In the identification card recognition method based on image processing, when the identification card image is processed by adopting a method based on deep learning, the position and the rotation angle of a face are obtained through the characteristic marks of the face in the input identification card image, and the corresponding left rotation of 90 degrees, -90 degrees, 180 degrees and 0 degree is determined according to any one of the left face, the right face, the upper face and the lower face. And stripping the identity card area in the identity card image from the whole image according to the position information of the face in proportion. And performing text detection on the image of the residual area after the identity card area is stripped. Since the rotated id card image may still be a tilted image, in order to improve the text recognition accuracy, the tilted text in the remaining region image needs to be corrected again.
The prior art also discloses that the identity card image is corrected through four correction modules, the deep learning VGG16 classification network module roughly determines that the identity card image rotates by any one of 0 degree, 90 degrees, 180 degrees and 270 degrees, the sequencing filter determines the inclination angle of the identity card image, and the identity card image is accurately corrected. When the method accurately corrects the identity card image through a sorting filter, extracting background pixels of the identity card image, subtracting a background area through pixel subtraction, only leaving text pixels of the identity card area in the final image, taking each integer degree value in the range of [ -15,15] degrees, respectively rotating according to the angle, taking a second dimension as an axis to calculate an average value of a pixel matrix of the image of the rotated identity card area to obtain a one-dimensional average value array, calculating a variance of the one-dimensional average value array to obtain a final value, and determining a variance value corresponding to each angle, wherein the angle when the variance is maximum is an inclination angle of the identity card image.
When the image quality of the image of the identity card is poor due to the fact that the identity card is stained, or the color of the identity card is close to the color of the background area, the pixel matrix of the image of the identity card area determined through the sorting filter is affected, so that the variance value corresponding to each determined angle is inaccurate, the inclination angle of the obtained identity card image is finally inaccurate, the extraction precision during identity card information extraction is reduced according to the identity card image corrected by the inaccurate inclination angle, and therefore the robustness of the identity card information extraction method in the prior art is not high.
Disclosure of Invention
The embodiment of the invention provides an identity card information extraction method, an identity card information extraction device, identity card information extraction equipment and an identity card information extraction medium, which are used for solving the problems of low extraction precision and low robustness of the identity card information extraction method in the prior art.
The embodiment of the invention provides an identity card information extraction method, which comprises the following steps:
determining information of an area where an identity card number is located in an input identity card image based on a pre-trained deep learning network model;
determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
and carrying out inclination correction on the identity card image according to an included angle between the frame line of the subregion and the horizontal line, carrying out rotation correction on the identity card image according to the position information of each text region in the identity card image after the inclination correction, and identifying the identity card information contained in the identity card image after the rotation correction.
Further, before determining a sub-area including an area where each character is located according to an area where each character is located in an area where the identification number is located, the method further includes:
and carrying out binarization processing on pixel points in the region where the identification number is located, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, and determining each connected domain as the region where each character is located.
Further, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing comprises:
determining each target pixel point with the pixel value as the set pixel value according to the pixel value of each pixel point after binarization processing;
aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point;
aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points;
and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
Further, the determining a sub-region including a region where each character is located includes:
determining the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate according to the pixel point of the region where each character in the region where the identification number is located;
and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
Further, the performing rotation correction on the identity card image according to the position information of each text region in the identity card image after tilt correction includes:
determining the relative position of the sub-region and each text region in the identity card image according to the detected position information of each text region in the identity card image after the inclination correction;
and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
Further, detecting each text region in the identity card image after tilt rectification, comprising:
and detecting to obtain the information of each text region containing each identity card information in the identity card image after the inclination correction based on the pre-trained text detection model.
Further, the determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region includes:
according to the sub-region, if the identity card image is located in the horizontal direction, determining a first ratio of the number of text regions with vertical coordinates larger than the vertical coordinates of the sub-region to the number of all the text regions, and judging whether the first ratio is larger than a first set threshold value, if so, determining that the sub-region is located below the text regions, and if not, determining that the sub-region is located above the text regions;
if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region;
and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
Further, the identification of the identity card information contained in the identity card image after rotation correction includes:
if the ethnic information in the identity card information is identified in the corrected identity card image, matching a first character string corresponding to the ethnic information with each character string in a stored ethnic character database;
if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information;
and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
Further, identifying the identity card information contained in the identity card image after rotation correction comprises:
judging whether the number of the identified identity card information reaches a set number threshold value or not;
if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
Correspondingly, the embodiment of the invention provides an identity card information extraction device, which comprises:
the determining module is used for determining the information of the region where the identity card number is located in the input identity card image based on the pre-trained deep learning network model; determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
and the identification module is used for performing inclination correction on the identity card image according to an included angle between the frame line of the subregion and the horizontal line, performing rotation correction on the identity card image according to the position information of each text region in the identity card image after the inclination correction, and identifying the identity card information contained in the identity card image after the rotation correction.
Further, the determining module is further configured to, before determining a sub-region including the region where each character is located according to the region where each character is located in the region where the identification number is located, perform binarization processing on pixel points in the region where the identification number is located, determine each connected domain in the region where the identification number is located according to a pixel value of each pixel point after the binarization processing, and determine each connected domain as the region where each character is located.
Further, the determining module is specifically configured to determine, according to the pixel value of each pixel point after binarization processing, a pixel value as each target pixel point of a set pixel value; aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point; aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points; and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
Further, the determining module is specifically configured to determine a maximum value and a minimum value of an abscissa and a maximum value and a minimum value of a ordinate according to a pixel point of a region where each character in a region where the identification number is located; and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
Further, the identification module is specifically configured to determine, according to the detected position information of each text region in the identity card image after the tilt correction, a relative position between the sub-region and each text region in the identity card image; and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
Further, the identification module is specifically configured to detect and obtain information of each text region including each kind of identification card information in the identification card image after the inclination correction based on a text detection model that is trained in advance.
Further, the identification module is specifically configured to determine, according to the sub-region, if it is determined that the identification card image is located in the horizontal direction, a first ratio of the number of text regions whose vertical coordinates are greater than the vertical coordinates of the sub-region to the number of all text regions, and determine whether the first ratio is greater than a first set threshold, if yes, determine that the sub-region is located below the text region, and if not, determine that the sub-region is located above the text region; if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region; and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
Further, the identification module is specifically configured to, if national information in the identification card information is identified in the corrected identification card image, match a first character string corresponding to the national information with each character string in a stored national character database; if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information; and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
Further, the identification module is specifically configured to determine whether the number of the identified identification card information reaches a set number threshold; if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
Accordingly, an embodiment of the present invention provides an electronic device, where the electronic device includes a processor and a memory, where the memory is used to store program instructions, and the processor is used to implement the steps of any one of the above methods for extracting id card information when executing a computer program stored in the memory.
Accordingly, an embodiment of the present invention provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of any one of the above-mentioned identity card information extraction methods.
After the area where the identity card number is located in the identity card image is determined, the sub-area including the area where each character is located is determined according to the area where each character is located in the area where the identity card number is located, the inclination angle of the identity card image is determined according to the included angle between the frame line of the sub-area and the horizontal line, and the inclination correction of the identity card image is achieved according to the inclination angle. Therefore, when the background color of the identity card image is close to the identity color or the image quality of the identity card image is poor, accurate inclination correction of the identity card image can be realized, and the robustness and the extraction precision of the identity card information extraction method are improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic process diagram of an identity card information extraction method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an ID card image in a predetermined orientation according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an ID card image after tilt correction according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an ID card image after tilt correction according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of an ID card image after tilt correction according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of an ID card image after tilt correction according to an embodiment of the present invention;
fig. 7 is a schematic process diagram of an identity card information extraction method according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an identification card information extraction apparatus according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to improve the robustness and the extraction precision of the identity card information extraction method, the embodiment of the invention provides an identity card information extraction method, an identity card information extraction device, identity card information extraction equipment and an identity card information extraction medium.
Example 1:
fig. 1 is a schematic process diagram of an identity card information extraction method provided in an embodiment of the present invention, where the process includes the following steps:
s101: and determining the information of the region where the identity card number is in the input identity card image based on the pre-trained deep learning network model.
The method for extracting the identity card information provided by the embodiment of the invention is applied to the electronic equipment with the image acquisition function, such as image acquisition equipment, or a smart phone, a PC, a server, a tablet computer and the like.
In the embodiment of the present invention, in order to extract the identity card information in the identity card image, the identity card image needs to be obtained first, and the identity card image may be an identity card image including other background areas, or an identity card image only including an identity card area.
After the electronic equipment acquires the identity card image, the electronic equipment processes the identity card image based on the depth learning network model trained in advance, and determines the information of the area where the identity card number is located in the identity card image. The pre-trained deep learning network model is used for identifying the identity card number in the identity card image and determining the area where the identity card number is located.
The deep learning network model may be any one of a target detection algorithm model (Fast-CNN), a Fast target recognition algorithm model (YOLO), and a target detection system (YOLO 9000). Preferably, in the embodiment of the present invention, the deep learning network model is a trimmed version of fast object recognition algorithm model (tiny-yolo 2).
S102: and determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located.
After the information of the area where the identity card number is located in the identity card image is determined, in order to determine the inclination angle of the identity card image, a sub-area of the area where each character is located in the identity card image needs to be determined.
In the embodiment of the invention, a number segmentation method in the prior art can be adopted to determine the area of each character in the area of the ID number. The digital segmentation method comprises a histogram-based segmentation method, a clustering-based segmentation method, a binary image connected domain mark-based segmentation method and the like. The determined area of each character can be a regular-shaped area, such as a rectangular area, or an irregular-shaped area. Specifically, the embodiment of the present invention is not limited to this.
And according to the determined region of each character, the electronic equipment determines a sub-region containing the region of each character. Wherein the sub-region is included in the region where the identification number is located. Since the identification number is generally located in a rectangular area, the sub-area is a rectangular area.
S103: and performing inclination correction on the identity card image according to the included angle between the frame line of the sub-region and the horizontal line.
In order to determine the inclination angle of the identity card image, in the embodiment of the present invention, the inclination angle between the sub-region where the identity card number is located and the horizontal line is determined, and the inclination angle between the sub-region and the horizontal line is determined as the inclination angle of the identity card image.
Specifically, in order to determine the inclination angle between the sub-region and the horizontal line, any frame line of the sub-region is determined first, and the inclination angle between the sub-region and the horizontal line is determined according to the included angle between any frame line of the sub-region and the horizontal line.
After the inclination angle of the sub-region and the horizontal line is determined, the inclination angle is determined as the inclination angle of the identity card image, and the identity card image is subjected to inclination correction according to the inclination angle of the identity card image. When the inclination correction is performed on the identification card image, the inclination correction may be performed by clockwise rotation or counterclockwise rotation.
S104: and performing rotation correction on the identity card image according to the position information of each text region in the identity card image after inclination correction, and identifying the identity card information contained in the identity card image after rotation correction.
After the inclination correction of the identity card image is completed, the identity card image after the inclination correction may be in the horizontal direction or in the vertical direction. When the identification card information included in the identification card image is identified, the identification card image needs to be located in a preset direction. It is also necessary to determine whether to rotationally correct the identification card image before identifying the identification card information contained in the identification card image. The preset direction means that the identity card image is located in the horizontal direction, and the face area image in the identity card image is located on the right side of the identity card image. Fig. 2 is a schematic diagram of an identity card image in a preset direction according to an embodiment of the present invention.
After the inclination correction of the identity card image is completed, detecting the identity card image after the inclination correction to determine each text region in the identity card image, and determining whether to perform rotation correction on the identity card image according to the relative positions of the sub-regions in the identity card image after the inclination correction and each text region obtained through detection.
And if the identity card image is positioned in the preset direction, determining not to perform rotation correction on the identity card image. Namely, the selection angle of the identity card image is 0 degree. And if the identity card image is not positioned in the preset direction, determining the rotation angle of the corrected identity card image according to the relative positions of the sub-regions and each text region in the identity card image. Wherein the rotation angle is generally 90 degrees or 180 degrees.
The text area refers to an area where information such as name, gender, ethnicity, birth, address, and the like is located in the identification card image. For example, in an identification card image, nationality: the Chinese is a text region.
And after the rotation angle of the identity card image is determined, performing rotation correction on the identity card image, wherein when the rotation correction is performed, the rotation correction is performed on the identity card image according to the determined rotation angle, wherein the rotation direction when the rotation correction is performed is determined, and the rotation direction is the rotation direction when the rotation angle is determined. And identifying the identity card image after rotation correction, and identifying identity card information contained in the identity card image.
Specifically, when the identification card information included in the identification card image is identified, an identifier in the prior art may be used for the identification, or other methods in the prior art may be used for the identification, which is not limited in this embodiment of the present invention.
According to the invention, after the area of the identity card number in the identity card image is determined, the sub-area containing the area of each character is determined according to the area of each character in the area of the identity card number, and the inclination angle of the identity card image is determined according to the included angle between the frame line and the horizontal line of the sub-area, so that when the background color of the identity card image is close to the identity color or the image quality of the identity card image is poor, the accurate inclination correction of the identity card image can be realized, and the robustness and the extraction precision of the identity card information extraction method are improved.
Example 2:
in order to determine the area where each character of the area where the identification number is located, on the basis of the above embodiment, in an embodiment of the present invention, before determining the sub-area including the area where each character is located according to the area where each character of the area where the identification number is located, the method further includes:
and carrying out binarization processing on pixel points in the region where the identification number is located, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, and determining each connected domain as the region where each character is located.
After the information of the area where the identity card number is located in the identity card image is determined, the area where each character containing the identity card number is located is determined. In the embodiment of the invention, the binarization processing is carried out on the pixel points in the area where the identity card number is located. Namely, the pixel value of the pixel point in the area where the identification number is located is set to be 0 or 255, so that the image of the area where the identification number is located presents an obvious black and white effect. Specifically, the method for performing binarization processing on the pixel points is the prior art, and the embodiments of the present invention are not described herein again.
And determining each connected domain in the region of the identity card number according to the pixel value of each pixel point after binarization processing. After the binarization processing is performed on the pixel points in the area where the identification number is located, the pixel value of the pixel point in the area where each character in the identification number is located is set to be 255 or 0, and the pixel values of the pixel points in other areas except the identification number are set to be 0 or 255, so that each connected domain in the area where the identification number is located can be determined according to the pixel value of each pixel point after the binarization processing.
And determining each determined connected domain as the region of each character in the region of the identity number. Wherein the region of each character includes each pixel point in the corresponding connected domain. Wherein the connected domain is an irregularly shaped region.
Example 3:
in order to determine each connected domain in the area where the identification number is located, on the basis of the above embodiments, in an embodiment of the present invention, the determining each connected domain in the area where the identification number is located according to the pixel value of each pixel after binarization processing includes:
determining each target pixel point with the pixel value as the set pixel value according to the pixel value of each pixel point after binarization processing;
aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point;
aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points;
and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
In the embodiment of the invention, the binarization processing is carried out on the pixel points in the area where the identification number is located, and after the binarization processing is carried out on the pixel points, the pixel values of the pixel points are set to be two different pixel values. Specifically, the pixel value of the pixel point is set to 0 or 255.
In order to determine each connected domain in the region where the identification number is located, in the embodiment of the invention, after the binarization processing is performed on the pixel points, the pixel points on each character in the region where the identification number is located are set as the set pixel values. Therefore, firstly, according to the pixel value of each pixel point after binarization processing, each target pixel point with the pixel value as the set pixel value is determined. In order to more accurately determine the connected component, the set pixel value is 255 or 0, and different pixel values are selected as the set pixel value according to the specific processing mode adopted in the binarization.
After each target pixel point is determined, in order to determine each connected domain, a target pixel point located in each connected domain needs to be determined. Specifically, for each target pixel point, whether other target pixel points adjacent to the target pixel point exist is determined. The target pixel point and other target pixel points may be adjacent in four neighborhoods or adjacent in eight neighborhoods. In order to accurately determine each connected domain, the target pixel point is adjacent to other target pixel points in eight neighborhoods.
And aiming at each target pixel point, after other target pixel points adjacent to the target pixel point are determined, the target pixel point and the adjacent other target pixel points form a first point set. When the target pixel point is adjacent to other target pixel points in eight neighborhoods, the first point set has nine target pixel points at most.
In order to determine each connected domain in the region where the identity card number is located, after each first point set of each target pixel point is determined, whether the same target pixel point as the first point set exists in other first point sets or not is judged for each first point set, if the same target pixel point as the first point set exists in other first point sets, the first point set is updated based on the other first point sets with the same target pixel point, and other target pixel points except the same target pixel point in the other first point sets with the same target pixel point are added into the first point set.
For example, for a first point set of a target pixel point a including target pixel points a, b, c, and d and other first point sets including target pixel points c, e, and f, it is determined that the first point set of the target pixel point a includes a common target pixel point c, so that the first point set of the target pixel point a is updated according to the other first point sets, and the updated first point set of the target pixel point a includes the target pixel points a, b, c, d, e, and f.
And circularly judging whether the other first point sets have the same target pixel points as the updated first point set or not aiming at the updated first point set, and continuously updating the updated first point set based on the other first point sets having the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points.
Because the target pixel point in the updated first point set is located in a connected domain, the connected domain of the area where the identity card number is located is determined according to the target pixel point in the updated first point set, and the target pixel point in the updated first point set is determined as the pixel point in the connected domain.
Example 4:
in order to determine the sub-region including the region where each character is located, on the basis of the foregoing embodiments, in an embodiment of the present invention, the determining the sub-region including each connected domain includes:
determining the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate according to the pixel point of the region where each character in the region where the identification number is located;
and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
In order to determine the sub-region including the region where each character is located, the sub-region is preset to be a rectangular region, and therefore the sub-region including the region where each character is located can be determined by determining boundary pixel points of four corners of the sub-region.
Since the sub-region includes each target pixel point in the region where each character is located, the abscissa and the ordinate of the boundary pixel point of the sub-region are necessarily the maximum value and the minimum value of the abscissa and the ordinate of all the target pixel points in the region where the character is located.
Therefore, in order to determine the sub-area containing the area where each character is located, the abscissa and the ordinate of each pixel point are determined according to each pixel point in the area where each character is located in the area where the identification number is located, and the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate are determined according to the abscissa and the ordinate of each pixel point.
And determining coordinate values of the four boundary pixel points according to the determined maximum value and minimum value of the abscissa and the determined maximum value and minimum value of the ordinate. Specifically, a first boundary pixel point is determined according to the maximum value of the abscissa and the maximum value of the ordinate; determining a second boundary pixel point according to the maximum value of the horizontal coordinate and the minimum value of the vertical coordinate; determining a third boundary pixel point according to the minimum value of the abscissa and the maximum value of the ordinate; and determining a fourth boundary pixel point according to the minimum value of the abscissa and the minimum value of the ordinate.
And determining a sub-region containing the region of each character according to the determined four boundary pixel points. Specifically, a rectangular region formed by connecting lines of four boundary pixel points is determined as a sub-region including a region in which each character is located.
Example 5:
in order to implement rotation correction of an identification card image, on the basis of the foregoing embodiments, in an embodiment of the present invention, the performing rotation correction on the identification card image according to position information of each text region in the identification card image after tilt correction includes:
determining the relative position of the sub-region and each text region in the identity card image according to the detected position information of each text region in the identity card image after the inclination correction;
and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
In the embodiment of the invention, in order to realize rotation correction on the identity card image, the position information of each text region in the identity card image after inclination correction is further required to be determined. Specifically, in the embodiment of the present invention, the text region location algorithm based on color features, the text region location algorithm based on connected regions, the text region location algorithm based on edges, and the text region location algorithm based on texture features in the prior art may be used to determine the location information of the text region.
In order to detect each text region in the identification card image, on the basis of the above embodiment, in an embodiment of the present invention, detecting each text region in the identification card image after tilt correction includes:
and detecting to obtain the information of each text region containing each identity card information in the identity card image after the inclination correction based on the pre-trained text detection model.
In the embodiment of the invention, in order to detect each text region in the identification card image, a text detection model is trained in advance, and the text detection model can realize the identification of each text region in the identification card image. The model outputs information of the region where each text region is located.
Inputting the identity card image after the inclination correction into the trained text detection model, and processing the identity card image after the inclination correction by the text detection model to determine the information of each text region containing each kind of identity card information in the identity card image. Specifically, the position information of each text region is determined.
In the embodiment of the present invention, the text detection model may be an existing text detection model, or may be a text detection model obtained by training an existing neural network model through a large number of identification card sample images, and specifically, the embodiment of the present invention is not limited to this.
Fig. 2 is a schematic diagram of each text region in an identification card image according to an embodiment of the present invention, and as shown in fig. 2, the other rectangular regions except the rectangular region of the identification card number in the diagram are the text regions in the identification card image.
After the position information of each text region in the identity card image after the inclination correction is determined, the electronic equipment can also determine the relative position of the sub region and each text region according to the known position information of the text region and the position information of the sub region containing the identity card number.
In an embodiment of the present invention, the relative position of the sub-region and the text region includes: the sub-region is located below the text region, the sub-region is located above the text region, the sub-region is located to the left of the text region, and the sub-region is located to the right of the text region.
In order to realize the rotation correction of the identity card image, the electronic device also stores a corresponding relation between the relative position and the rotation angle in advance, and according to the determined target relative position of the sub-region in the text region, the electronic device can determine the rotation angle corresponding to the target relative position, determine the rotation angle as the rotation angle of the identity card image, and perform the rotation correction on the identity card image.
In order to determine the rotation angle of the identity card image after the tilt correction, on the basis of the foregoing embodiments, in an embodiment of the present invention, the determining the rotation angle of the identity card image according to the relative positions of the sub-regions in the identity card image after the tilt correction and each text region obtained by detection includes:
according to the sub-region, if the identity card image is located in the horizontal direction, determining a first ratio of the number of text regions with vertical coordinates larger than the vertical coordinates of the sub-region to the number of all the text regions, and judging whether the first ratio is larger than a first set threshold value, if so, determining that the sub-region is located below the text regions, and if not, determining that the sub-region is located above the text regions;
if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region;
and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
After the identification card image is subjected to tilt correction, the tilt-corrected identification card image may be in a horizontal direction or a vertical direction. In order to accurately determine the rotation angle of the identity card image, the direction in which the identity card image is located is determined according to the sub-region of the identity card image.
Generally, the identification card number is longer, the sub-region containing the identification card number is a rectangular region, and the horizontal direction or the vertical direction of the identification card image can be determined according to the aspect ratio of the sub-region in the identification card image after the inclination correction. Specifically, when the aspect ratio of the sub-region is greater than 1, it is determined that the identification card image is located in the horizontal direction, and when the aspect ratio is less than 1, it is determined that the identification card image is located in the vertical direction.
Fig. 3 is a schematic diagram of an identity card image after tilt correction according to an embodiment of the present invention, where the identity card image in fig. 3 is located in a horizontal direction, a face image in the identity card image is located on the right side of the identity card image, a text is located on the left side of the identity card image, and an area where an identity card number in the identity card image is located below each text area.
Fig. 4 is a schematic diagram of an identity card image after tilt correction according to an embodiment of the present invention, where the identity card image in fig. 4 is located in a horizontal direction, a face image in the identity card image is located on the left side of the identity card image, a text is located on the right side of the identity card image, and an area where an identity card number in the identity card image is located above each text area.
Fig. 5 is a schematic diagram of an identity card image after tilt correction according to an embodiment of the present invention, where the identity card image in fig. 5 is located in a vertical direction, a region where an identity card number in the identity card image is located on the left side of the identity card image, and a region where the identity card number in the identity card image is located on the left side of each text region.
Fig. 6 is a schematic diagram of an identity card image after tilt correction according to an embodiment of the present invention. The identification card image in fig. 6 is located in the vertical direction, the area where the identification card number in the identification card image is located on the right side of the identification card image, and the area where the identification card number in the identification card image is located on the right side of each text area.
In the embodiment of the present invention, the direction of the tilt-corrected identification card image may be any one of the directions of the identification card images shown in fig. 3, fig. 4, fig. 5, and fig. 6, and as can be seen from the schematic diagrams of the identification card images shown in fig. 3, fig. 4, fig. 5, and fig. 6, in order to make the rotation-corrected identification card image be located in the preset direction shown in fig. 2, in the embodiment of the present invention, the rotation angle of the identification card image may be determined according to the relative position of the area where the identification card number is located in the identification card image and each text area.
For example, when the identification card image is located in the horizontal direction, in order to determine the rotation angle of the identification card direction, the relative positions of the sub-regions and the text region in the identification card image are first determined. Specifically, when the identification card image is located in the horizontal direction, the vertical coordinate of the center point of the sub-region and the vertical coordinate of the center point of the text region are determined, the number of the text regions with the vertical coordinates larger than the vertical coordinate of the sub-region is determined according to the vertical coordinate of the sub-region and the vertical coordinate of the text region, and a first ratio of the number to the number of all the text regions is determined.
According to the size of the first ratio, it can be determined that the sub-region is located at the relative position of the region where the identification card number is located when the identification card image is located in the horizontal direction. Specifically, whether the first ratio is larger than a first set threshold value or not is judged, if yes, the sub-region is determined to be located below the text region, and if not, the sub-region is determined to be located above the text region. The schematic diagram shown in fig. 3 is a schematic diagram of the identification card image when the sub region is located below the text region, and the schematic diagram shown in fig. 4 is a schematic diagram of the identification card image when the sub region is located above the text region.
Wherein the first set threshold is for setting in advance, and may be set larger if the user wishes to improve the accuracy of determining the relative position. For example, the first set threshold may be 5. If the user wishes to improve the robustness in determining the relative position, i.e. to determine the relative position of the sub-region in the text region even when there is a large deviation in the detected center points of some text regions, the first set threshold may be set smaller, for example, the first set threshold may be 3.
When the identification card image is located in the vertical direction, in order to determine the rotation angle of the identification card direction, it is first determined that the sub-region in the identification card image is located at the target relative position of the text region. Specifically, when the identification card image is located in the vertical direction, the abscissa of the center point of the sub-region and the abscissa of the center point of the text region are determined, the number of the text regions with the abscissa larger than the abscissa of the sub-region is determined according to the abscissa of the sub-region and the abscissa of the text region, and a second ratio of the number to the number of all the text regions is determined.
According to the second ratio, the relative position of the sub-region in the region where the identification card number is located can be determined when the identification card image is located in the vertical direction. Specifically, whether the second ratio is larger than a second set threshold is judged, if yes, the sub-region is determined to be located on the left side of the text region, and if not, the sub-region is determined to be located on the right side of the text region.
Fig. 5 is a schematic diagram of the identification card image when the sub region is located on the left side of the text region, and fig. 6 is a schematic diagram of the identification card image when the sub region is located on the right side of the text region.
After the target relative position of the sub-region in the identity card image in the text region is determined, determining the rotation angle corresponding to the target relative position as the target rotation angle of the identity card image according to the determined target relative position and the corresponding relationship between the relative position and the rotation angle.
Specifically, when the sub-region is determined to be located below the text region, as shown in the schematic diagram shown in fig. 3, the rotation angle corresponding to the sub-region located below the text region is 0 degree, so that the rotation angle of the id card image is determined to be 0 degree, that is, the id card image is not rotated; when the sub-region is located above the text region, as shown in the schematic diagram of fig. 4, the rotation angle corresponding to the sub-region being located above the text region is 180 degrees clockwise, so that it is determined that the rotation angle of the id card image is 180 degrees clockwise; when the sub-region is located on the left side of the text region, as shown in the schematic diagram of fig. 5, the rotation angle of the sub-region located on the left side of the text region is 90 degrees counterclockwise, so that the rotation angle of the id card image is determined to be 90 degrees counterclockwise; when the sub-region is located on the right side of the text region, as shown in the schematic diagram of fig. 6, the rotation angle of the sub-region located on the right side of the text region is 90 degrees counterclockwise, and thus the rotation angle of the id card image is determined to be 90 degrees clockwise.
Example 6:
in order to correct the identified ethnic information, on the basis of the foregoing embodiments, in an embodiment of the present invention, the identification card information included in the identification card image after the identification rotation correction includes:
if the ethnic information in the identity card information is identified in the corrected identity card image, matching a first character string corresponding to the ethnic information with each character string in a stored ethnic character database;
if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information;
and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
In the embodiment of the present invention, when the identification card information included in the rotation-corrected identification card image is identified, a recognition method in the prior art may be adopted to identify a character string in the text region, and the identified character string is determined as the identification card information included in the identification card image.
Specifically, when identifying the national information in the identification card information, identifying a character string including 'national' in a character string of a specific text region, determining the remaining character strings except two national characters in the character string as a first character string corresponding to the national information, and determining the first character string as the national information in the identification card information.
After the national information in the identification card information is recognized, because the national characters are complex, when the characters in the text region where the national information is located are recognized, the character string may be recognized incorrectly, so after the first character string corresponding to the national information is recognized, the first character string also needs to be corrected.
In order to correct the error of the first character string, in the embodiment of the present invention, a national character database is stored in advance, and correct character strings corresponding to each nation are stored in the character database.
And matching the first character string corresponding to the ethnic information with each character string in a stored ethnic character database to determine the similarity between the first character string and each character string. Specifically, the method for determining the similarity between the first character string and each character string is the prior art, and may be, for example, the edit distance method determination.
In order to determine whether the first character string is successfully matched with the character string in the character database, in the embodiment of the present invention, a third set threshold is preset, and the third set threshold is preset according to requirements.
And if a second character string with the similarity larger than a third set threshold value is matched in the character database, the first character string is successfully matched with a correct character string corresponding to the national information in the character database, and the first character string is used as the national information in the identity card information.
And if the second character string with the similarity larger than a third set threshold value is not matched in the character database, the first character string is not successfully matched with the correct character string corresponding to the national information in the character database, and the first character string is not the correct character string corresponding to the national information. And determining a third character string with the highest similarity according to the similarity between the first character string and each character string in the character database, and taking the third character string as the national information in the ID card information.
In order to identify all the identification card information, on the basis of the above embodiments, in an embodiment of the present invention, the identifying the identification card information included in the rotation-corrected identification card image includes:
judging whether the number of the identified identity card information reaches a set number threshold value or not;
if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
The number of the identity card information contained in the identity card image is determined, and after the identity card information contained in the identity card image after the rotation correction is recognized, in order to determine whether all the identity card information is recognized, the number of the recognized identity card information is determined at first, and whether the number reaches a set number threshold value is judged. In the embodiment of the present invention, the set number threshold refers to the identification card information that the identification card should have, and the identification card information includes six types of identification card information, including name information, gender information, ethnic information, birth information, address information, and identification card number information, so the set number threshold is 6.
And if the quantity of the identified identity card information does not reach the set quantity threshold value, determining the unrecognized target character string in the identity card image according to each character string contained in the stored identity card information. Each character string included in the stored identification card information is 'name', 'gender' ethnicity 'birth', 'address' and 'national identification number', respectively.
In order to improve the possibility of identifying the identification card information, in the embodiment of the present invention, the target character string is split into a plurality of characters, for each character, a character string including the character is identified in the corrected identification card image, and the identified character string is used as the identification card information including the target character string. In the embodiment of the invention, when each character is identified, one character string may be identified, or a plurality of character strings may be identified, and if a plurality of character strings are identified, the identity card information of other unrecognized target character strings is identified first, and the rest of the character strings are taken as the identity card information of the target character string.
For example, when the target character string is "name", the "name" is divided into "last name" and "first name", a character string including the character "last name" is recognized in the rotation-corrected identification card image for the "last name", and the recognized character string is used as identification card information including the target character string "name".
In the embodiment of the present invention, in order to identify the address information in the id card information, since there is more than one text area containing the address information, as shown in fig. 2, there are two text areas containing the address information.
In order to identify complete address information, in the embodiment of the present invention, when identifying address information in the identification card information, in a character string of a determined text region, a character string in the text region containing two address characters is identified, and a remaining character string of the character string except for two address characters is determined as a character string corresponding to the address information.
After the text region of the character string containing the address two-character is determined, the text region with the vertical coordinate between the center point of the text region and the vertical coordinate of the center point of the sub-region is determined, the character string of the text region is also determined as the character string corresponding to the address information, the two character strings are combined into one character string, and specifically, the character string of the text region is connected behind the character string of the text region containing the address two-character.
In the embodiment of the invention, after the character string corresponding to the address information is determined, the 'address' of the character string is used as the key of the main key, the character string corresponding to the address information is used as the value of the main key, the label is added to the character string corresponding to the address information, and the character string added with the label is not identified when other identification card information is identified, so that the extraction efficiency of the identification card information can be improved.
Example 7:
fig. 7 is a schematic process diagram of an identity card information extraction method according to an embodiment of the present invention, as shown in fig. 7.
S701: and inputting an identity card image.
S702: and (3) inclination correction: determining the information of the region where the identification card number containing the identification card number is located in the input identification card image based on a pre-trained deep learning network model; performing binarization processing on pixel points in the region where the identification number is located, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, and determining a sub-region containing each connected domain; and determining the inclination angle of the identity card image according to the included angle between any frame line of the subarea and the horizontal line, and performing inclination correction on the identity card image.
S703: text detection: and detecting to obtain the information of each text region containing each identity card information in the identity card image after the inclination correction based on the pre-trained text detection model.
S704: text direction detection: according to the sub-region, if the identity card image is located in the horizontal direction, determining a first ratio of the number of text regions with the vertical coordinates larger than the vertical coordinates of the sub-region to the number of all the text regions, and judging whether the first ratio is larger than a first set threshold value, if so, determining that the sub-region is located below the text region, and if not, determining that the sub-region is located above the text region; if the identity card image is determined to be positioned in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is positioned on the left side of the text region, and if not, determining that the sub-region is positioned on the right side of the text region; and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the target relative position of the determined sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
S705: text recognition: and identifying the identity card information contained in the identity card image after the rotation correction, and determining the character string of each identified text region as identity card information.
S706: structural analysis: according to each character string contained in the pre-stored identity card information, for each character string, identifying the character string of the text area containing the character string in the character string of each text area, and determining the character string of the text area as the identity card information of the character string.
S707: and (3) correcting the national information: if the ethnic information in the identity card information is identified in the identity card image after the rotation correction, matching a first character string corresponding to the ethnic information with each character string in a stored ethnic character database; if a second character string with the similarity larger than a third set threshold value is matched in the character database, the identified first character string is used as the ethnic information in the identity card information; and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the ethnic information in the ID card information.
S708: and outputting the identified identity card information.
Example 8:
on the basis of the foregoing embodiments, fig. 8 is a schematic structural diagram of an identification card information extraction apparatus according to an embodiment of the present invention, where the apparatus includes:
a determining module 801, configured to determine, based on a deep learning network model that is trained in advance, information of an area where an identity card number is located in an input identity card image; determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
the identification module 802 is configured to perform tilt correction on the identity card image according to an included angle between a frame line of the sub-region and a horizontal line, and perform rotation correction on the identity card image according to position information of each text region in the identity card image after the tilt correction, so as to identify identity card information included in the identity card image after the rotation correction.
The determining module 801 is further configured to, before determining a sub-region including the region where each character is located in the region where the identification number is located according to the region where each character is located in the region where the identification number is located, perform binarization processing on pixel points in the region where the identification number is located, determine each connected domain in the region where the identification number is located according to a pixel value of each pixel point after the binarization processing, and determine each connected domain as the region where each character is located.
The determining module 801 is specifically configured to determine, according to the pixel value of each pixel after binarization processing, that the pixel value is each target pixel of the set pixel value; aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point; aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points; and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
The determining module 801 is further configured to determine a maximum value and a minimum value of a horizontal coordinate and a maximum value and a minimum value of a vertical coordinate according to a pixel point of a region where each character in a region where the identification number is located; and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
The identification module 802 is specifically configured to determine, according to the detected position information of each text region in the identity card image after the tilt correction, a relative position between the sub-region and each text region in the identity card image; and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
The recognition module 802 is specifically configured to, based on a text detection model that is trained in advance, detect and obtain information of each text region that includes each kind of identification card information in the identification card image after the inclination correction.
The identification module 802 is specifically configured to, according to the sub-region, if it is determined that the identification card image is located in the horizontal direction, determine a first ratio of the number of text regions whose vertical coordinates are greater than the vertical coordinates of the sub-region to the number of all text regions, determine whether the first ratio is greater than a first set threshold, if yes, determine that the sub-region is located below the text region, and if not, determine that the sub-region is located above the text region; if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region; and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
The identification module 802 is further configured to, if national information in the identification card information is identified in the corrected identification card image, match a first character string corresponding to the national information with each character string in a stored national character database; if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information; and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
The identification module 802 is specifically configured to determine whether the number of the identified identification card information reaches a set number threshold; if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
Example 9:
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and on the basis of the foregoing embodiments, an electronic device according to an embodiment of the present invention is further provided, where the electronic device includes a processor 901, a communication interface 902, a memory 903, and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 complete communication with each other through the communication bus 904;
the memory 903 has stored therein a computer program which, when executed by the processor 901, causes the processor 901 to perform the steps of:
determining information of an area where an identity card number is located in an input identity card image based on a pre-trained deep learning network model;
determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
and carrying out inclination correction on the identity card image according to an included angle between the frame line of the subregion and the horizontal line, carrying out rotation correction on the identity card image according to the position information of each text region in the identity card image after the inclination correction, and identifying the identity card information contained in the identity card image after the rotation correction.
Further, the processor 901 is specifically configured to determine, before determining a sub-area including an area where each character is located according to an area where each character is located in an area where the identification number is located, the method further includes:
and carrying out binarization processing on pixel points in the region where the identification number is located, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, and determining each connected domain as the region where each character is located.
Further, the processor 901 is specifically configured to determine each connected domain in the region where the identification number is located according to the pixel value of each pixel point after the binarization processing, and includes:
determining each target pixel point with the pixel value as the set pixel value according to the pixel value of each pixel point after binarization processing;
aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point;
aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points;
and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
Further, the processor 901 is specifically configured to determine a sub-area including an area where each character is located, including:
determining the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate according to the pixel point of the region where each character in the region where the identification number is located;
and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
Further, the performing rotation correction on the identity card image according to the position information of each text region in the identity card image after tilt correction includes:
determining the relative position of the sub-region and each text region in the identity card image according to the detected position information of each text region in the identity card image after the inclination correction;
and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
Further, the processor 901 is specifically configured to detect each text region in the id card image after the tilt correction, including:
and detecting to obtain the information of each text region containing each identity card information in the identity card image after the inclination correction based on the pre-trained text detection model.
Further, the processor 901 is specifically configured to determine the rotation angle of the identity card image according to the relative position of the sub-region and each text region, and includes:
according to the sub-region, if the identity card image is located in the horizontal direction, determining a first ratio of the number of text regions with vertical coordinates larger than the vertical coordinates of the sub-region to the number of all the text regions, and judging whether the first ratio is larger than a first set threshold value, if so, determining that the sub-region is located below the text regions, and if not, determining that the sub-region is located above the text regions;
if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region;
and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
Further, the processor 901 is specifically configured to identify the identity card information included in the identity card image after rotation correction, including:
if the ethnic information in the identity card information is identified in the corrected identity card image, matching a first character string corresponding to the ethnic information with each character string in a stored ethnic character database;
if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information;
and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
Further, the processor 901 is specifically configured to identify the identity card information included in the identity card image after rotation correction, and includes:
judging whether the number of the identified identity card information reaches a set number threshold value or not;
if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface 902 is used for communication between the electronic apparatus and other apparatuses.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a central processing unit, a Network Processor (NP), and the like; but may also be a Digital instruction processor (DSP), an application specific integrated circuit, a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like.
Example 10:
on the basis of the foregoing embodiments, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program, where the computer program is executed by a processor to perform the following steps:
determining information of an area where an identity card number is located in an input identity card image based on a pre-trained deep learning network model;
determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
and carrying out inclination correction on the identity card image according to an included angle between the frame line of the subregion and the horizontal line, carrying out rotation correction on the identity card image according to the position information of each text region in the identity card image after the inclination correction, and identifying the identity card information contained in the identity card image after the rotation correction.
Further, before determining a sub-area including an area where each character is located according to an area where each character is located in an area where the identification number is located, the method further includes:
and carrying out binarization processing on pixel points in the region where the identification number is located, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, and determining each connected domain as the region where each character is located.
Determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, wherein the method comprises the following steps:
determining each target pixel point with the pixel value as the set pixel value according to the pixel value of each pixel point after binarization processing;
aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point;
aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points;
and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
The determining a sub-region containing a region where each character is located includes:
determining the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate according to the pixel point of the region where each character in the region where the identification number is located;
and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
Further, the performing rotation correction on the identity card image according to the position information of each text region in the identity card image after tilt correction includes:
determining the relative position of the sub-region and each text region in the identity card image according to the detected position information of each text region in the identity card image after the inclination correction;
and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
Detecting each text region in the identity card image after tilt rectification, including:
and detecting to obtain the information of each text region containing each identity card information in the identity card image after the inclination correction based on the pre-trained text detection model.
The determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region comprises:
according to the sub-region, if the identity card image is located in the horizontal direction, determining a first ratio of the number of text regions with vertical coordinates larger than the vertical coordinates of the sub-region to the number of all the text regions, and judging whether the first ratio is larger than a first set threshold value, if so, determining that the sub-region is located below the text regions, and if not, determining that the sub-region is located above the text regions;
if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region;
and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
The identification card information contained in the identification card image after the identification rotation correction comprises:
if the ethnic information in the identity card information is identified in the corrected identity card image, matching a first character string corresponding to the ethnic information with each character string in a stored ethnic character database;
if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information;
and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
The identification of the identity card information contained in the identity card image after the rotation correction comprises:
judging whether the number of the identified identity card information reaches a set number threshold value or not;
if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (12)

1. An identity card information extraction method is characterized by comprising the following steps:
determining information of an area where an identity card number is located in an input identity card image based on a pre-trained deep learning network model;
determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
and carrying out inclination correction on the identity card image according to an included angle between the frame line of the subregion and the horizontal line, carrying out rotation correction on the identity card image according to the position information of each text region in the identity card image after the inclination correction, and identifying the identity card information contained in the identity card image after the rotation correction.
2. The method of claim 1, wherein before determining the sub-region containing the region in which each character is located according to the region in which each character is located in the region in which the identification number is located, the method further comprises:
and carrying out binarization processing on pixel points in the region where the identification number is located, determining each connected domain in the region where the identification number is located according to the pixel value of each pixel point after binarization processing, and determining each connected domain as the region where each character is located.
3. The method according to claim 2, wherein the determining each connected domain in the region of the identification number according to the pixel value of each pixel point after binarization processing comprises:
determining each target pixel point with the pixel value as the set pixel value according to the pixel value of each pixel point after binarization processing;
aiming at each target pixel point, determining each first point set formed by the target pixel point and other target pixel points adjacent to the target pixel point;
aiming at each first point set, if other first point sets with the same target pixel points as the first point set exist, updating the first point set based on the other first point sets with the same target pixel points until the other first point sets and the updated first point set do not have the same target pixel points;
and aiming at each updated first point set, determining a connected domain in the region where the identity card number is located according to a target pixel point in the updated first point set.
4. The method of claim 1 or 2, wherein the determining the sub-region containing the region in which each character is located comprises:
determining the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate according to the pixel point of the region where each character in the region where the identification number is located;
and determining boundary pixel points in the area where the identification number is located according to the maximum value and the minimum value of the abscissa and the maximum value and the minimum value of the ordinate, and determining a sub-area containing the area where each character is located according to the boundary pixel points.
5. The method according to claim 1, wherein the rotation correction of the identification card image according to the position information of each text region in the identification card image after the tilt correction comprises:
determining the relative position of the sub-region and each text region in the identity card image according to the detected position information of each text region in the identity card image after the inclination correction;
and determining the rotation angle of the identity card image according to the relative positions of the sub-regions and each text region, and performing rotation correction on the identity card image.
6. The method of claim 5, wherein detecting each text region in the identity card image after tilt rectification comprises:
and detecting to obtain the information of each text region containing each identity card information in the identity card image after the inclination correction based on the pre-trained text detection model.
7. The method of claim 5, wherein determining the rotation angle of the ID card image according to the relative positions of the sub-regions and each text region comprises:
according to the sub-region, if the identity card image is located in the horizontal direction, determining a first ratio of the number of text regions with vertical coordinates larger than the vertical coordinates of the sub-region to the number of all the text regions, and judging whether the first ratio is larger than a first set threshold value, if so, determining that the sub-region is located below the text regions, and if not, determining that the sub-region is located above the text regions;
if the identity card image is determined to be located in the vertical direction, determining a second ratio of the number of the text regions with the abscissa larger than the abscissa of the sub-region to the number of all the text regions, and judging whether the second ratio is larger than a second set threshold value, if so, determining that the sub-region is located on the left side of the text region, and if not, determining that the sub-region is located on the right side of the text region;
and determining the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image according to the determined target relative position of the sub-region in the text region and the corresponding relation between the relative position and the rotation angle.
8. The method of claim 1, wherein the identifying the identity card information contained in the identity card image after the rotation correction comprises:
if the ethnic information in the identity card information is identified in the corrected identity card image, matching a first character string corresponding to the ethnic information with each character string in a stored ethnic character database;
if a second character string with the similarity larger than a third set threshold value is matched in the character database, taking the identified first character string as the ethnic information in the identity card information;
and if the second character string with the similarity larger than a third set threshold value is not matched in the character database, taking the third character string with the highest similarity with the first character string in the character database as the national information in the identity card information.
9. The method of claim 1, wherein identifying the identity card information contained in the identity card image after rotational rectification comprises:
judging whether the number of the identified identity card information reaches a set number threshold value or not;
if not, according to each character string contained in the prestored identity card information, determining an unrecognized target character string in the identity card image, splitting the target character string into a plurality of characters, recognizing the character string containing the character in the corrected identity card image aiming at each character, and taking the recognized character string as the identity card information containing the target character string.
10. An identification card information extraction apparatus, characterized in that the apparatus comprises:
the determining module is used for determining the information of the region where the identity card number is located in the input identity card image based on the pre-trained deep learning network model; determining a sub-area containing the area where each character is located according to the area where each character is located in the area where the identification number is located;
and the identification module is used for performing inclination correction on the identity card image according to an included angle between the frame line of the subregion and the horizontal line, performing rotation correction on the identity card image according to the position information of each text region in the identity card image after the inclination correction, and identifying the identity card information contained in the identity card image after the rotation correction.
11. An electronic device, characterized in that the electronic device comprises a processor and a memory, the memory being configured to store program instructions, the processor being configured to carry out the steps of the identification card information extraction method according to any one of claims 1 to 9 when executing a computer program stored in the memory.
12. A computer-readable storage medium, characterized in that it stores a computer program which, when executed by a processor, implements the steps of the identification card information extraction method according to any one of claims 1 to 9.
CN202010653020.4A 2020-07-08 2020-07-08 Identity card information extraction method, device, equipment and medium Pending CN111914836A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010653020.4A CN111914836A (en) 2020-07-08 2020-07-08 Identity card information extraction method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010653020.4A CN111914836A (en) 2020-07-08 2020-07-08 Identity card information extraction method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN111914836A true CN111914836A (en) 2020-11-10

Family

ID=73227699

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010653020.4A Pending CN111914836A (en) 2020-07-08 2020-07-08 Identity card information extraction method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN111914836A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112528776A (en) * 2020-11-27 2021-03-19 京东数字科技控股股份有限公司 Text line correction method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040181671A1 (en) * 1998-11-19 2004-09-16 Brundage Trent J. Identification document and related methods
CN102955941A (en) * 2011-08-31 2013-03-06 汉王科技股份有限公司 Identity information recording method and device
CN108268868A (en) * 2017-07-28 2018-07-10 平安科技(深圳)有限公司 Inclination value-acquiring method and device, terminal, the storage medium of ID Card Image
CN109034165A (en) * 2018-07-06 2018-12-18 北京中安未来科技有限公司 A kind of cutting method of certificate image, device, system and storage medium
CN111260569A (en) * 2020-01-10 2020-06-09 百度在线网络技术(北京)有限公司 Method and device for correcting image inclination, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040181671A1 (en) * 1998-11-19 2004-09-16 Brundage Trent J. Identification document and related methods
CN102955941A (en) * 2011-08-31 2013-03-06 汉王科技股份有限公司 Identity information recording method and device
CN108268868A (en) * 2017-07-28 2018-07-10 平安科技(深圳)有限公司 Inclination value-acquiring method and device, terminal, the storage medium of ID Card Image
CN109034165A (en) * 2018-07-06 2018-12-18 北京中安未来科技有限公司 A kind of cutting method of certificate image, device, system and storage medium
CN111260569A (en) * 2020-01-10 2020-06-09 百度在线网络技术(北京)有限公司 Method and device for correcting image inclination, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112528776A (en) * 2020-11-27 2021-03-19 京东数字科技控股股份有限公司 Text line correction method and device
CN112528776B (en) * 2020-11-27 2024-04-09 京东科技控股股份有限公司 Text line correction method and device

Similar Documents

Publication Publication Date Title
US10635946B2 (en) Eyeglass positioning method, apparatus and storage medium
CN109658584B (en) Bill information identification method and device
CN109740606B (en) Image identification method and device
CN110675940A (en) Pathological image labeling method and device, computer equipment and storage medium
US20200125830A1 (en) Object recognition
CN111783757A (en) OCR technology-based identification card recognition method in complex scene
CN109670440B (en) Identification method and device for big bear cat face
US9418446B2 (en) Method and apparatus for determining a building location based on a building image
CN112613506A (en) Method and device for recognizing text in image, computer equipment and storage medium
US11144752B1 (en) Physical document verification in uncontrolled environments
CN108830275B (en) Method and device for identifying dot matrix characters and dot matrix numbers
CN110503682B (en) Rectangular control identification method and device, terminal and storage medium
CN109389115B (en) Text recognition method, device, storage medium and computer equipment
CN110197179B (en) Method and device for identifying card number, storage medium and electronic equipment
CN111325104A (en) Text recognition method, device and storage medium
CN111639653A (en) False detection image determining method, device, equipment and medium
CN112396050B (en) Image processing method, device and storage medium
CN111046881A (en) Pointer type instrument reading identification method based on computer vision and deep learning
CN113903024A (en) Handwritten bill numerical value information identification method, system, medium and device
CN111340023A (en) Text recognition method and device, electronic equipment and storage medium
CN111783770A (en) Image rectification method, device and computer readable storage medium
CN111222452A (en) Face matching method and device, electronic equipment and readable storage medium
CN105184294B (en) It is a kind of based on pixel tracking inclination text judge recognition methods
CN113111880A (en) Certificate image correction method and device, electronic equipment and storage medium
CN111914836A (en) Identity card information extraction method, device, equipment and medium

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