ID card information extraction method, device, equipment and medium

Through the combination of deep learning network and text detection model, the tilt angle and rotation correction of the ID card image are accurately determined, which solves the problem of low accuracy and insufficient robustness in ID card information extraction, and improves the accuracy of ID card information extraction.

CN111914836BActive Publication Date: 2024-09-03ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202010653020.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-07-08
Publication Date
2024-09-03
Estimated Expiration
2040-07-08

AI Technical Summary

Technical Problem

Existing ID card information extraction methods have low extraction accuracy and low robustness, especially when the ID card image quality is poor or the background color is close, resulting in inaccurate tilt angle correction and affecting the extraction accuracy of ID card information.

Method used

The pre-trained deep learning network model is used to determine the ID card number area. Through binarization processing and frame line angle correction, the tilt angle of the ID card image is accurately determined and rotation correction is performed. The text detection model is combined to identify the ID card information.

Benefits of technology

It improves the robustness and accuracy of ID card information extraction, can accurately correct the tilt angle when the ID card image background color is close or the image quality is poor, and enhances the accuracy of ID card information extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111914836B
    Figure CN111914836B
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and medium for extracting ID card information. After determining the area where the ID card number is located in the ID card image, the present invention determines the sub-area containing the area where each character is located according to the area where each character is located in the area where the ID card number is located, determines the tilt angle of the ID card image according to the angle between the border line of the sub-area and the horizontal line, and implements tilt correction of the ID card image according to the tilt angle. Therefore, when the background color of the ID card image is close to the identity color or the image quality of the ID card image is not good, accurate tilt correction of the ID card image can be implemented, thereby improving the robustness and extraction accuracy of the ID card information extraction method in the present invention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition technology, and in particular to a method, device, equipment and medium for extracting identity card information. Background Art

[0002] The ID card is the main identification of residents in China. When identifying the ID card, the ID card recognition method can include the ID card recognition method based on magnetic card induction and the ID card recognition method based on image processing.

[0003] In the ID card recognition method based on magnetic card induction, the ID card is mainly recognized by the ID card reader of magnetic card induction. The ID card reader has strong versatility and high accuracy, but is not convenient to carry, and is often used in the service halls of public security, banks, civil affairs and other fields.

[0004] In the ID card recognition method based on image processing, the ID card image is mainly captured by a device with a camera such as a mobile phone or tablet, and then transmitted to the ID card recognition system to output the recognition result of the ID card elements. This recognition method does not require carrying additional equipment and can be used anytime and anywhere. For example, when bank staff go out to open an account, they can use the application on their mobile phone to identify the ID card of a new customer and quickly enter the identified ID card information. However, the disadvantage of this method is that the recognition rate is low in complex scenarios.

[0005] In the ID card recognition method based on image processing, when the ID card image is processed by the deep learning-based method, the position and rotation angle of the face are obtained by the characteristic marks of the face in the input ID card image, and the corresponding left rotation of 90 degrees, -90 degrees, 180 degrees, and 0 degrees is determined according to whether the face is the left face, the right face, the upper face, or the lower face. According to the position information of the face, the ID card area in the ID card image is proportionally stripped from the entire image. Text detection is performed on the remaining area image after the ID 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 area image needs to be corrected again.

[0006] The prior art also discloses that the ID card image is corrected by four correction modules, and the ID card image is roughly determined by the deep learning VGG16 classification network module to be rotated at any angle of 0, 90, 180, and 270 degrees, and then the tilt angle of the ID card image is determined by the sorting filter to accurately correct the ID card image. When the method accurately corrects the ID card image by the sorting filter, the background pixels of the ID card image are extracted, and the background area is subtracted by pixel subtraction. Finally, only the text pixels of the ID card area are left in the image. Each integer degree value in the range of [-15, 15] degrees is taken, and the image is rotated at this angle respectively. The pixel matrix of the rotated ID card area image is averaged with the second dimension as the axis to obtain a one-dimensional mean array, and the variance of the one-dimensional mean array is calculated to obtain the final value, and the variance value corresponding to each angle is determined. The angle with the maximum variance is the tilt angle of the ID card image.

[0007] When the ID card is damaged and the image quality of the ID card image is poor, or when the color of the ID card is close to the color of the background area, it will affect the pixel matrix of the image of the ID card area determined by the sorting filter, making the variance value corresponding to each determined angle inaccurate, ultimately resulting in inaccurate tilt angle of the obtained ID card image. The extraction accuracy when extracting ID card information based on the ID card image after correcting the inaccurate tilt angle will also decrease. Therefore, the robustness of the ID card information extraction method in the prior art is not high. Summary of the invention

[0008] The embodiments of the present invention provide a method, device, equipment and medium for extracting identity card information, so as to solve the problems of low extraction accuracy and low robustness of the identity card information extraction method in the prior art.

[0009] An embodiment of the present invention provides a method for extracting identity card information, the method comprising:

[0010] Based on the pre-trained deep learning network model, determine the information of the area where the ID card number is located in the input ID card image;

[0011] According to the area where each character is located in the area where the ID card number is located, determining a sub-area including the area where each character is located;

[0012] The ID card image is tilt-corrected according to the angle between the border line of the sub-area and the horizontal line, and the ID card image is rotation-corrected according to the position information of each text area in the ID card image after the tilt correction, and the ID card information contained in the ID card image after the rotation correction is identified.

[0013] Furthermore, before determining the sub-region including the region where each character is located according to the region where each character is located in the region where the ID card number is located, the method further includes:

[0014] Binarization is performed on the pixels in the area where the ID card number is located, and each connected domain in the area where the ID card number is located is determined based on the pixel value of each pixel after the binarization process, and each connected domain is determined as the area where each character is located.

[0015] Furthermore, the step of determining each connected domain in the area where the ID card number is located according to the pixel value of each pixel after the binarization process includes:

[0016] According to the pixel value of each pixel point after the binarization process, determine each target pixel point whose pixel value is the set pixel value;

[0017] For each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point;

[0018] For each first point set, if there are other first point sets having the same target pixel as the first point set, the first point set is updated based on the other first point sets having the same target pixel until the other first point sets do not have the same target pixel as the updated first point set;

[0019] For each updated first point set, a target pixel point in the updated first point set is determined as a connected domain within the area where the ID card number is located.

[0020] Further, the determining of the sub-region containing the region where each character is located includes:

[0021] Determine the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate according to the pixel points of the area where each character is located in the area where the ID card number is located;

[0022] The boundary pixel points in the area where the ID card number is located are determined based on the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate, and the sub-area containing the area where each character is located is determined based on the boundary pixel points.

[0023] Furthermore, the rotation correction of the ID card image according to the position information of each text area in the ID card image after the tilt correction includes:

[0024] Determine the relative position of the sub-region in the ID card image and each text region according to the position information of each text region in the ID card image after tilt correction obtained by detection;

[0025] According to the relative position of the sub-region and each text region, the rotation angle of the ID card image is determined, and rotation correction is performed on the ID card image.

[0026] Further, detecting each text area in the tilt-corrected ID card image includes:

[0027] Based on the pre-trained text detection model, information of each text area containing each ID card information in the tilt-corrected ID card image is detected.

[0028] Further, determining the rotation angle of the ID card image according to the relative position of the sub-region and each text region includes:

[0029] According to the sub-region, if it is determined that the ID card image is located in the horizontal direction, determine a first ratio of the number of text regions whose ordinates are greater than the ordinate of the sub-region to the number of all text regions, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-region is located below the text region, if not, determine that the sub-region is located above the text region;

[0030] If it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area;

[0031] According to the determined target relative position of the sub-region in the text region and the correspondence between the relative position and the rotation angle, the rotation angle corresponding to the target relative position is determined as the target rotation angle of the ID card image.

[0032] Furthermore, the identification information of the ID card contained in the ID card image after the identification rotation correction includes:

[0033] If ethnic information in the ID card information is recognized in the corrected ID card image, matching the first character string corresponding to the ethnic information with each character string in the stored ethnic character database;

[0034] If a second character string with a similarity greater than a third set threshold is matched in the character database, the identified first character string is used as the ethnicity information in the identity card information;

[0035] If a second character string with a similarity greater than a third set threshold value is not matched in the character database, a third character string with the highest similarity to the first character string in the character database is used as the ethnicity information in the identity card information.

[0036] Further, identifying the ID card information contained in the ID card image after rotation correction includes:

[0037] Determine whether the number of recognized ID card information reaches a set number threshold;

[0038] If not, determine the target string that is not recognized in the ID card image based on each string contained in the pre-saved ID card information, split the target string into multiple characters, and for each character, identify the string containing the character in the corrected ID card image, and use the identified string as the ID card information containing the target string.

[0039] Accordingly, an embodiment of the present invention provides a device for extracting identity card information, the device comprising:

[0040] A determination module is used to determine information of the area where the ID card number is located in the input ID card image based on a pre-trained deep learning network model; and determine 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 ID card number is located;

[0041] The identification module is used to perform tilt correction on the ID card image according to the angle between the border line of the sub-area and the horizontal line, and to perform rotation correction on the ID card image according to the position information of each text area in the ID card image after the tilt correction, and to identify the ID card information contained in the ID card image after the rotation correction.

[0042] Furthermore, the determination module is also used to binarize the pixels in the area where the ID card number is located before determining the sub-area containing the area where each character is located based on the area where each character is located in the area where the ID card number is located, and determine each connected domain in the area where the ID card number is located based on the pixel value of each pixel after the binarization process, and determine each connected domain as the area where each character is located.

[0043] Furthermore, the determination module is specifically used to determine each target pixel point whose pixel value is a set pixel value based on the pixel value of each pixel point after binarization processing; for each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point; for each first point set, if there are other first point sets that have the same target pixel points as the first point set, then update the first point set based on the other first point sets that have the same target pixel points until there are no same target pixel points in the other first point sets and the updated first point set; for each updated first point set, determine the connected domain within the area where the ID number is located based on the target pixel points in the updated first point set.

[0044] Furthermore, the determination module is specifically used to determine the maximum and minimum values ​​of the horizontal coordinate, and the maximum and minimum values ​​of the vertical coordinate based on the pixel points of the area where each character is located in the area where the ID card number is located; determine the boundary pixel points in the area where the ID card number is located based on the maximum and minimum values ​​of the horizontal coordinate, and the maximum and minimum values ​​of the vertical coordinate, and determine the sub-area containing the area where each character is located based on the boundary pixel points.

[0045] Furthermore, the recognition module is specifically used to determine the relative position of the sub-region in the ID card image and each text region based on the position information of each text region in the ID card image after tilt correction detected; determine the rotation angle of the ID card image based on the relative position of the sub-region and each text region, and perform rotation correction on the ID card image.

[0046] Furthermore, the recognition module is specifically used to detect information of each text area containing each type of ID card information in the ID card image after tilt correction based on a pre-trained text detection model.

[0047] Further, the recognition module is specifically used to determine, based on the sub-area, if it is determined that the ID card image is located in the horizontal direction, a first ratio of the number of text areas whose vertical coordinates are greater than the vertical coordinate of the sub-area to the number of all text areas, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-area is located below the text area, if not, determine that the sub-area is located above the text area; if it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold value, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area; based on the determined target relative position of the sub-area in the text area, and the corresponding relationship between the relative position and the rotation angle, determine the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image.

[0048] Furthermore, the recognition module is specifically used to match the first character string corresponding to the ethnic information with each character string in the stored ethnic text database if the ethnic information in the ID card information is recognized in the corrected ID card image; if a second character string with a similarity greater than a third set threshold is matched in the text database, the recognized first character string is used as the ethnic information in the ID card information; if a second character string with a similarity greater than the third set threshold is not matched in the text database, the third character string in the text database with the highest similarity to the first character string is used as the ethnic information in the ID card information.

[0049] Furthermore, the recognition module is specifically used to determine whether the number of recognized ID card information reaches a set quantity threshold; if not, based on each character string contained in the pre-saved ID card information, determine the target character string that is not recognized in the ID card image, split the target character string into multiple characters, and for each character, identify the character string in the corrected ID card image, and use the identified character string as the ID card information containing the target character string.

[0050] Accordingly, an embodiment of the present invention provides an electronic device, which includes a processor and a memory, wherein the memory is used to store program instructions, and the processor is used to implement the steps of any of the above-mentioned ID card information extraction methods when executing the computer program stored in the memory.

[0051] Accordingly, an embodiment of the present invention provides a computer-readable storage medium storing a computer program, which implements the steps of any of the above-mentioned methods for extracting identity card information when executed by a processor.

[0052] After determining the area where the ID card number is located in the ID card image, the embodiment of the present invention determines the sub-area containing the area where each character is located according to the area where each character is located in the area where the ID card number is located, determines the tilt angle of the ID card image according to the angle between the border line of the sub-area and the horizontal line, and implements tilt correction of the ID card image according to the tilt angle. Therefore, when the background color of the ID card image is close to the identity color or the image quality of the ID card image is not good, accurate tilt correction of the ID card image can be implemented, thereby improving the robustness and extraction accuracy of the ID card information extraction method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0054] Figure 1 A schematic diagram of a process of extracting identity card information provided by an embodiment of the present invention;

[0055] Figure 2 A schematic diagram of an ID card image in a preset direction provided by an embodiment of the present invention;

[0056] Figure 3 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention;

[0057] Figure 4 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention;

[0058] Figure 5 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention;

[0059] Figure 6 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention;

[0060] Figure 7 A schematic diagram of a process of extracting identity card information provided by an embodiment of the present invention;

[0061] Figure 8 A schematic diagram of the structure of an ID card information extraction device provided by an embodiment of the present invention;

[0062] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0064] In order to improve the robustness and extraction accuracy of the ID card information extraction method, the embodiments of the present invention provide an ID card information extraction method, device, equipment and medium.

[0065] Embodiment 1:

[0066] Figure 1 A schematic diagram of a method for extracting identity card information provided by an embodiment of the present invention, the process includes the following steps:

[0067] S101: Based on a pre-trained deep learning network model, determine the information of the area where the ID card number is located in the input ID card image.

[0068] The ID card information extraction method provided in the embodiment of the present invention is applied to an electronic device with an image acquisition function, such as an image acquisition device, or a smart phone, PC, server, tablet computer, etc.

[0069] In the embodiment of the present invention, in order to extract the ID card information in the ID card image, it is first necessary to obtain the ID card image, which may be an ID card image including other background areas or an ID card image only including the ID card area.

[0070] After the electronic device obtains the ID card image, it processes the ID card image based on the pre-trained deep learning network model to determine the information of the area where the ID card number is located in the ID card image. The pre-trained deep learning network model is used to recognize the ID card number in the ID card image and determine the area where the ID card number is located.

[0071] The deep learning network model can be any one of the target detection algorithm model (Fast-CNN), the fast target detection algorithm model (Faster-CNN), the fast target recognition algorithm model (YOLO), and the target detection system (YOLO 9000). Preferably, in an embodiment of the present invention, the deep learning network model is a trimmed version of the fast target recognition algorithm model (tiny-yolo2).

[0072] S102: Determine, based on the region where each character is located in the region where the ID card number is located, a sub-region including the region where each character is located.

[0073] After determining the information of the area where the ID card number is located in the ID card image, in order to determine the tilt angle of the ID card image, it is also necessary to determine the sub-area of ​​the area where each character is located in the ID card image.

[0074] In the embodiment of the present invention, the digital segmentation method in the prior art can be used to determine the area where each character in the area where the ID card number is located. The digital segmentation method includes a segmentation method based on a histogram, a segmentation method based on clustering, a segmentation method based on a binary image connected domain labeling, etc. The determined area where each character is located can be an area of ​​a regular shape, such as a rectangular area, or an area of ​​an irregular shape. Specifically, the embodiment of the present invention does not limit this.

[0075] According to the determined area where each character is located, the electronic device determines a sub-area including the area where each character is located. The sub-area is included in the area where the ID card number is located. Since the ID card number is generally located in a rectangular area, the sub-area is a rectangular area.

[0076] S103: performing tilt correction on the ID card image according to the angle between the border line of the sub-region and the horizontal line.

[0077] In order to determine the tilt angle of the ID card image, in an embodiment of the present invention, the tilt angle of the sub-region where the ID card number is located and the horizontal line is determined, and the tilt angle of the sub-region and the horizontal line is determined as the tilt angle of the ID card image.

[0078] Specifically, in order to determine the inclination angle between the sub-region and the horizontal line, first determine any border line of the sub-region, and determine the inclination angle between the sub-region and the horizontal line according to the angle between any border line of the sub-region and the horizontal line.

[0079] After determining the tilt angle between the sub-area and the horizontal line, the tilt angle is determined as the tilt angle of the ID card image, and the ID card image is tilt-corrected according to the tilt angle of the ID card image. The tilt correction of the ID card image can be performed by rotating it clockwise or counterclockwise.

[0080] S104: performing rotation correction on the ID card image according to the position information of each text area in the ID card image after the tilt correction, and identifying the ID card information contained in the ID card image after the rotation correction.

[0081] After the tilt correction of the ID card image is completed, the ID card image after the tilt correction may be located in the horizontal direction or in the vertical direction. When identifying the ID card information contained in the ID card image, the ID card image needs to be located in a preset direction. Therefore, before identifying the ID card information contained in the ID card image, it is also necessary to determine whether to perform rotation correction on the ID card image. Among them, the preset direction means that the ID card image is located in the horizontal direction, and the face area image in the ID card image is located on the right side of the ID card image. Figure 2 A schematic diagram of an identity card image in a preset direction provided by an embodiment of the present invention.

[0082] After completing the tilt correction of the ID card image, the ID card image after the tilt correction is detected to determine each text area in the ID card image, and based on the relative position of the sub-area in the ID card image after the tilt correction and each text area detected, it is determined whether to perform rotation correction on the ID card image.

[0083] If the ID card image is located in the preset direction, it is determined that the ID card image is not subjected to rotation correction. That is, the selected angle of the ID card image is 0 degrees. If the ID card image is not located in the preset direction, the rotation angle of the corrected ID card image is determined according to the relative positions of the sub-regions and each text region in the ID card image. The rotation angle is generally 90 degrees or 180 degrees.

[0084] The text region refers to the region where the name, gender, ethnicity, birthplace, address, and other information in the ID card image are located. For example, in the ID card image, ethnicity: Han is a text region.

[0085] After the rotation angle of the ID card image is determined, the ID card image is rotationally corrected, wherein the ID card image is rotationally corrected according to the determined rotation angle, wherein the rotation direction during the rotation correction is determined, and the rotation direction is the rotation direction when the rotation angle is determined. The ID card image after the rotation correction is identified to identify the ID card information contained in the ID card image.

[0086] Specifically, when identifying the ID card information contained in the ID card image, the identification may be performed by using an identifier in the prior art, or by using other methods in the prior art, which is not limited in the embodiment of the present invention.

[0087] Since the present invention determines the area where the ID card number is located in the ID card image, a 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 ID card number is located, and the inclination angle of the ID card image is determined according to the angle between the border line of the sub-area and the horizontal line, when the background color of the ID card image is close to the identity color or the image quality of the ID card image is not good, accurate inclination correction of the ID card image can be achieved, thereby improving the robustness and extraction accuracy of the ID card information extraction method in the present invention.

[0088] Embodiment 2:

[0089] In order to determine the area where each character in the area where the ID card number is located, based on the above embodiment, in an embodiment of the present invention, before determining the sub-area containing the area where each character is located according to the area where each character in the area where the ID card number is located, the method further includes:

[0090] Binarization is performed on the pixels in the area where the ID card number is located, and each connected domain in the area where the ID card number is located is determined based on the pixel value of each pixel after the binarization process, and each connected domain is determined as the area where each character is located.

[0091] After determining the information of the area where the ID card number is located in the ID card image, in order to determine the area where each character of the ID card number is located. In an embodiment of the present invention, the pixels in the area where the ID card number is located are binarized. That is, the pixel values ​​of the pixels in the area where the ID card number is located are set to 0 or 255, so that the image in the area where the ID card number is located presents an obvious black and white effect. Specifically, the method of binarizing the pixels is a prior art, and the embodiment of the present invention will not be described in detail here.

[0092] According to the pixel value of each pixel after the binarization process, each connected domain in the area where the ID card number is located is determined. Since after the pixel points in the area where the ID card number is located are binarized, the pixel values ​​of the pixel points in the area where each character in the ID card number is located are set to 255 or 0, and the pixel values ​​of the pixel points in other areas except the ID card number are set to 0 or 255. Therefore, according to the pixel value of each pixel point after the binarization process, each connected domain in the area where the ID card number is located can be determined.

[0093] Each determined connected domain is determined as the region where each character is located in the region where the identity number is located, wherein each character region contains each pixel point in the corresponding connected domain, wherein the connected domain is an irregularly shaped region.

[0094] Embodiment 3:

[0095] In order to determine each connected domain in the area where the ID card number is located, based on the above embodiments, in an embodiment of the present invention, the method of determining each connected domain in the area where the ID card number is located according to the pixel value of each pixel after binarization processing includes:

[0096] According to the pixel value of each pixel point after the binarization process, determine each target pixel point whose pixel value is the set pixel value;

[0097] For each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point;

[0098] For each first point set, if there are other first point sets having the same target pixel as the first point set, the first point set is updated based on the other first point sets having the same target pixel until the other first point sets do not have the same target pixel as the updated first point set;

[0099] For each updated first point set, a target pixel point in the updated first point set is determined as a connected domain within the area where the ID card number is located.

[0100] In the embodiment of the present invention, the pixel points in the area where the ID card number is located are binarized, and after the pixel points are binarized, the pixel values ​​of the pixel points are set to two different pixel values. Specifically, the pixel values ​​of the pixel points are set to 0 or 255.

[0101] In order to determine each connected domain in the area where the ID card number is located, in the embodiment of the present invention, after the pixel points are binarized, the pixel points on each character in the area where the ID card number is located are set to a set pixel value. Therefore, first, according to the pixel value of each pixel point after the binarization process, each target pixel point whose pixel value is the set pixel value is determined. Among them, in order to more accurately determine the connected domain, the set pixel value is 255 or 0, and different pixel values ​​are selected as the set pixel values ​​according to the specific processing method adopted when binarization is performed.

[0102] After each target pixel is determined, in order to determine each connected domain, it is also necessary to determine the target pixel located in each connected domain. Specifically, for each target pixel, determine whether there are other target pixels adjacent to the target pixel. The target pixel and other target pixels may be adjacent within four neighborhoods or within eight neighborhoods. In order to accurately determine each connected domain, the target pixel and other target pixels may be adjacent within eight neighborhoods.

[0103] For each target pixel, after determining other target pixels adjacent to the target pixel, the target pixel and other adjacent target pixels form a first point set. When the target pixel and other target pixels are adjacent within eight neighborhoods, there are at most nine target pixels in the first point set.

[0104] In order to determine each connected domain in the area where the ID card number is located, after determining each first point set of each target pixel point, for each first point set, determine whether there are other first point sets with the same target pixel point as that in the first point set. If there are other first point sets with the same target pixel point as that in the first point set, the first point set is updated based on the other first point sets with the same target pixel point, and the other target pixel points in the other first point sets with the same target pixel point except the same target pixel point are added to the first point set.

[0105] For example, the first point set of target pixel point a includes target pixel points a, b, c and d, and the other first point sets include target pixel points c, e and f. It is determined that the first point set of target pixel point a and the other first point sets include a common target pixel point c. Therefore, the first point set of target pixel point a is updated according to the other first point sets, and the updated first point set of target pixel point a includes target pixel points a, b, c, d, e and f.

[0106] For the updated first point set, it is cyclically determined whether there are target pixels identical to those in the updated first point set in other first point sets, and the updated first point set is continuously updated based on other first point sets having the same target pixels, until there are no target pixels identical to those in the updated first point set in other first point sets.

[0107] Since the target pixel point in the updated first point set is located in a connected domain, the connected domain within the area where the ID card number is located is determined based on the target pixel point in the updated first point set, and the target pixel point in the updated first point set is determined as a pixel point in a connected domain.

[0108] Embodiment 4:

[0109] In order to determine the sub-region containing the region where each character is located, based on the above embodiments, in an embodiment of the present invention, the determining of the sub-region containing each connected domain includes:

[0110] Determine the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate according to the pixel points of the area where each character is located in the area where the ID card number is located;

[0111] The boundary pixel points in the area where the ID card number is located are determined based on the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate, and the sub-area containing the area where each character is located is determined based on the boundary pixel points.

[0112] In order to determine the sub-region including the region where each character is located, the sub-region is preset as a rectangular region, so the sub-region including the region where each character is located can be determined by determining the boundary pixel points of the four corners of the sub-region.

[0113] Since the sub-region contains each target pixel in the region where each character is located, the horizontal and vertical coordinates of the boundary pixels of the sub-region must be the maximum and minimum values ​​of the horizontal and vertical coordinates of all the target pixels in the region where the character is located.

[0114] Therefore, in order to determine the sub-area containing the area where each character is located, the horizontal and vertical coordinates of each pixel are determined according to each pixel in the area where each character is located in the area where the ID number is located, and the maximum and minimum values ​​of the horizontal coordinate, as well as the maximum and minimum values ​​of the vertical coordinate, are determined based on the horizontal and vertical coordinates of each pixel.

[0115] According to the determined maximum and minimum values ​​of the horizontal coordinate, and the maximum and minimum values ​​of the vertical coordinate, the coordinate values ​​of the four boundary pixel points can be determined. Specifically, according to the maximum value of the horizontal coordinate and the maximum value of the vertical coordinate, the first boundary pixel point is determined; according to the maximum value of the horizontal coordinate and the minimum value of the vertical coordinate, the second boundary pixel point is determined; according to the minimum value of the horizontal coordinate and the maximum value of the vertical coordinate, the third boundary pixel point is determined; according to the minimum value of the horizontal coordinate and the minimum value of the vertical coordinate, the fourth boundary pixel point is determined.

[0116] According to the determined four boundary pixel points, a sub-region including the region where each character is located is determined. Specifically, a rectangular region formed by the lines connecting the four boundary pixel points is determined as a sub-region including the region where each character is located.

[0117] Embodiment 5:

[0118] In order to realize the rotation correction of the ID card image, on the basis of the above embodiments, in an embodiment of the present invention, the rotation correction of the ID card image is performed according to the position information of each text area in the ID card image after the tilt correction, including:

[0119] Determine the relative position of the sub-region in the ID card image and each text region according to the position information of each text region in the ID card image after tilt correction obtained by detection;

[0120] According to the relative position of the sub-region and each text region, the rotation angle of the ID card image is determined, and rotation correction is performed on the ID card image.

[0121] In the embodiment of the present invention, in order to realize the rotation correction of the ID card image, it is also necessary to determine the position information of each text area in the ID card image after the tilt correction. Specifically, in the embodiment of the present invention, the position information of the text area can be determined by using the text area positioning algorithm based on color features, the text area positioning algorithm based on connected areas, the text area positioning algorithm based on edges, and the text area positioning algorithm based on texture features in the prior art.

[0122] In order to detect each text area in the ID card image, based on the above embodiment, in an embodiment of the present invention, detecting each text area in the ID card image after tilt correction includes:

[0123] Based on the pre-trained text detection model, information of each text area containing each ID card information in the tilt-corrected ID card image is detected.

[0124] In the embodiment of the present invention, in order to detect each text region in the ID card image, a text detection model is pre-trained, and the text detection model can recognize each text region in the ID card image. The model outputs information about the region where each text region is located.

[0125] The tilt-corrected ID card image is input into the trained text detection model, and the text detection model processes the tilt-corrected ID card image to determine the information of each text area in the ID card image that contains each ID card information. Specifically, the location information of each text area is determined.

[0126] In an embodiment of the present invention, the text detection model may be an existing text detection model, or a text detection model obtained by training an existing neural network model with a large number of ID card sample images. Specifically, the embodiment of the present invention does not impose any limitation on this.

[0127] Figure 2 A schematic diagram of each text area in an ID card image provided by an embodiment of the present invention, such as Figure 2 As shown in the figure, the other rectangular areas except the rectangular area of ​​the ID card number are the text areas in the ID card image.

[0128] After determining the position information of each text area in the ID card image after tilt correction, the electronic device can also determine the relative position of the sub-area and each text area based on the known position information of the text area and the position information of the sub-area containing the ID card number.

[0129] In the 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 on the left side of the text region, and the sub-region is located on the right side of the text region.

[0130] In order to achieve rotation correction of the ID card image, the electronic device also pre-saves the corresponding relationship between the relative position and the rotation angle. According to the determined target relative position of the sub-area in the text area, the electronic device can determine the rotation angle corresponding to the target relative position, determine the rotation angle as the rotation angle of the ID card image, and perform rotation correction on the ID card image.

[0131] In order to determine the rotation angle of the ID card image after tilt correction, based on the above embodiments, in an embodiment of the present invention, the rotation angle of the ID card image is determined according to the relative position of the sub-region in the ID card image after tilt correction and each text region detected, including:

[0132] According to the sub-region, if it is determined that the ID card image is located in the horizontal direction, determine a first ratio of the number of text regions whose ordinates are greater than the ordinate of the sub-region to the number of all text regions, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-region is located below the text region, if not, determine that the sub-region is located above the text region;

[0133] If it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area;

[0134] According to the determined target relative position of the sub-region in the text region and the correspondence between the relative position and the rotation angle, the rotation angle corresponding to the target relative position is determined as the target rotation angle of the ID card image.

[0135] After the ID card image is tilt-corrected, the tilt-corrected ID card image may be in a horizontal direction or in a vertical direction. In order to accurately determine the rotation angle of the ID card image, firstly, the direction in which the ID card image is located is determined according to the sub-region of the ID card image.

[0136] Generally speaking, the ID card number is relatively long, and the sub-region containing the ID card number is a rectangular region. According to the aspect ratio of the sub-region in the tilt-corrected ID card image, it can be determined whether the ID card image is in the horizontal direction or the vertical direction. Specifically, when the aspect ratio of the sub-region is greater than 1, it is determined that the ID card image is in the horizontal direction, and when the aspect ratio is less than 1, it is determined that the ID card image is in the vertical direction.

[0137] Figure 3 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention, Figure 3 The ID card image is located in the horizontal direction, and the face image in the ID card image is located on the right side of the ID card image, the text is located on the left side of the ID card image, and the area where the ID card number is located in the ID card image is located below each text area.

[0138] Figure 4 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention, Figure 4 The ID card image is located in the horizontal direction, and the face image in the ID card image is located on the left side of the ID card image, the text is located on the right side of the ID card image, and the area where the ID card number is located in the ID card image is located above each text area.

[0139] Figure 5 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention, Figure 5 The ID card image is located in the vertical direction, and the area where the ID card number is located in the ID card image is located on the left side of the ID card image, and the area where the ID card number is located in the ID card image is located on the left side of each text area.

[0140] Figure 6 A schematic diagram of an ID card image after tilt correction provided by an embodiment of the present invention. Figure 6 The ID card image is located in the vertical direction, and the area where the ID card number is located in the ID card image is located on the right side of the ID card image, and the area where the ID card number is located in the ID card image is located on the right side of each text area.

[0141] In the embodiment of the present invention, the direction of the ID card image after tilt correction can be as follows: Figure 3 , Figure 4 , Figure 5 and Figure 6 Any of the directions of the ID card image in Figure 3 , Figure 4 , Figure 5 and Figure 6As shown in the schematic diagram of the ID card image, in order to make the ID card image after rotation correction be located at Figure 2 The preset direction shown, in the embodiment of the present invention, the rotation angle of the ID card image can be determined according to the relative position of the area where the ID card number is located and each text area in the ID card image.

[0142] For example, when the ID card image is in the horizontal direction, in order to determine the rotation angle of the ID card direction, the relative position of the sub-region and the text region in the ID card image is first determined. Specifically, when the ID card image is in the horizontal direction, the ordinate of the center point of the sub-region and the ordinate of the center point of the text region are determined, and based on the ordinate of the sub-region and the ordinate of the text region, the number of text regions whose ordinates are greater than the ordinate of the sub-region is determined, and a first ratio of the number to the number of all text regions is determined.

[0143] According to the size of the first ratio, it can be determined that when the ID card image is in the horizontal direction, the sub-region is located in the relative position of the ID card number area. Specifically, it is determined whether the first ratio is greater than a first set threshold. If so, it is determined that the sub-region is located below the text area. If not, it is determined that the sub-region is located above the text area. Figure 3 The schematic diagram shown is a schematic diagram of an ID card image when the sub-area is located below the text area. Figure 4 The schematic diagram shown is a schematic diagram of an ID card image when the sub-area is located above the text area.

[0144] The first set threshold is used for presetting. If the user wants to improve the accuracy of determining the relative position, the first set threshold can be set to a larger value. For example, the first set threshold can be 5. If the user wants to improve the robustness of determining the relative position, that is, when there is a large deviation in the center point of some text areas detected, the relative position of the sub-area in the text area can be determined, the first set threshold can be set to a smaller value, for example, the first set threshold can be 3.

[0145] When the ID card image is in the vertical direction, in order to determine the rotation angle of the ID card direction, first determine the target relative position of the sub-region in the ID card image in the text region. Specifically, when the ID card image is in the vertical direction, determine the horizontal coordinate of the center point of the sub-region and the horizontal coordinate of the center point of the text region, and determine the number of text regions whose horizontal coordinates are greater than the horizontal coordinate of the sub-region based on the horizontal coordinate of the sub-region and the horizontal coordinate of the text region, and determine the second ratio of the number to the number of all text regions.

[0146] According to the size of the second ratio, it can be determined that when the ID card image is in the vertical direction, the sub-region is located in a relative position to the area where the ID card number is located. Specifically, it is determined whether the second ratio is greater than a second set threshold value. If so, it is determined that the sub-region is located on the left side of the text area. If not, it is determined that the sub-region is located on the right side of the text area.

[0147] like Figure 5 The schematic diagram shown is a schematic diagram of an ID card image when the sub-area is located on the left side of the text area. Figure 6 The schematic diagram shown is a schematic diagram of an ID card image when the sub-area is located on the right side of the text area.

[0148] After determining that the sub-region in the ID card image is located at the target relative position of the text region, the rotation angle corresponding to the target relative position is determined as the target rotation angle of the ID card image based on the determined target relative position and the correspondence between the relative position and the rotation angle.

[0149] Specifically, when it is determined that the sub-region is located below the text region, such as Figure 3 As shown in the schematic diagram, the rotation angle corresponding to the sub-region being located below the text region is 0 degrees, so the rotation angle of the ID card image is determined to be 0 degrees, that is, the ID card image is not rotated; when the sub-region is located above the text region, Figure 4 As shown in the schematic diagram, the sub-region is located above the text region and the corresponding rotation angle is 180 degrees clockwise, so the rotation angle of the ID card image is determined to be 180 degrees clockwise; when the sub-region is located on the left side of the text region, such as Figure 5 As shown in the schematic diagram, the rotation angle of the sub-region located on the left side of the text region is 90 degrees counterclockwise, so 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, Figure 6 As shown in the schematic diagram, the rotation angle of the sub-region located on the right side of the text region is 90 degrees counterclockwise, so the rotation angle of the ID card image is determined to be 90 degrees clockwise.

[0150] Embodiment 6:

[0151] In order to correct the identified ethnic information, based on the above embodiments, in an embodiment of the present invention, the ID card information contained in the ID card image after the identification rotation correction includes:

[0152] If ethnic information in the ID card information is recognized in the corrected ID card image, matching the first character string corresponding to the ethnic information with each character string in the stored ethnic character database;

[0153] If a second character string with a similarity greater than a third set threshold is matched in the character database, the identified first character string is used as the ethnicity information in the identity card information;

[0154] If a second character string with a similarity greater than a third set threshold value is not matched in the character database, a third character string with the highest similarity to the first character string in the character database is used as the ethnicity information in the identity card information.

[0155] In an embodiment of the present invention, when identifying the ID card information contained in the rotation-corrected ID card image, the recognition method in the prior art can be used to recognize the character string in the text area, and the recognized character string can be determined as the ID card information contained in the ID card image.

[0156] Specifically, when identifying the ethnic information in the ID card information, the character string containing 'ethnicity' is identified in the character string in the determined text area, and the remaining character string except the two characters of ethnicity in the character string is determined as the first character string corresponding to the ethnic information, and the first character string is determined as the ethnic information in the ID card information.

[0157] After identifying the ethnic information in the ID card information, since the ethnic characters are relatively complex, the character string may be recognized incorrectly when identifying the characters in the text area where the ethnic information is located. Therefore, after identifying the first character string corresponding to the ethnic information, the first character string needs to be corrected.

[0158] In order to correct the error of the first character string, in the embodiment of the present invention, a character database of ethnic groups is stored in advance, and the character database stores the correct character strings corresponding to each ethnic group.

[0159] The first character string corresponding to the ethnic information is matched with each character string in the 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 an existing technology, for example, it can be determined by the edit distance method.

[0160] In order to determine whether the first character string matches the character string in the character database successfully, in the embodiment of the present invention, a third set threshold is preset, and the third set threshold is preset according to demand.

[0161] If a second character string with a similarity greater than the third set threshold is matched in the character database, it means that the first character string successfully matches the correct character string corresponding to the ethnic information in the character database, and the first character string is used as the ethnic information in the identity card information.

[0162] If the second character string with a similarity greater than the third set threshold value is not matched in the character database, it means that the first character string is not matched successfully with the correct character string corresponding to the ethnic information in the character database, and the first character string is not the correct character string corresponding to the ethnic information. According to the similarity between the first character string and each character string in the character database, a third character string with the highest similarity is determined, and the third character string is used as the ethnic information in the ID card information.

[0163] In order to identify all the ID card information, based on the above embodiments, in an embodiment of the present invention, identifying the ID card information contained in the rotation-corrected ID card image includes:

[0164] Determine whether the number of recognized ID card information reaches a set number threshold;

[0165] If not, determine the target string that is not recognized in the ID card image based on each string contained in the pre-saved ID card information, split the target string into multiple characters, and for each character, identify the string containing the character in the corrected ID card image, and use the identified string as the ID card information containing the target string.

[0166] The amount of ID card information contained in the ID card image is determined. After the ID card information contained in the rotation-corrected ID card image is identified, in order to determine whether all the ID card information is identified, the amount of the identified ID card information is first determined to determine whether the amount reaches a set threshold. The set threshold refers to the ID card information that the ID card should have. In the embodiment of the present invention, the ID card information includes six types of ID card information, namely name information, gender information, ethnicity information, birth information, address information, and ID card number information. Therefore, the set threshold is 6.

[0167] If the number of the identified ID card information does not reach the set number threshold, the target character string that is not identified in the ID card image is determined based on each character string contained in the stored ID card information. Each character string contained in the stored ID card information is 'name', 'gender', 'ethnicity', 'birth', 'address' and 'citizen identification number'.

[0168] In order to increase the possibility of identifying the ID card information, in the embodiment of the present invention, the target string is split into multiple characters, and for each character, the string containing the character is identified in the corrected ID card image, and the identified string is used as the ID card information containing the target string. In the embodiment of the present invention, when identifying each character, one string or multiple strings may be identified. If multiple strings are identified, the ID card information of other unrecognized target strings is first identified, and the remaining strings are used as the ID card information of the target string.

[0169] For example, when the target character string is 'name', the 'name' is split into 'surname' and 'given name', and for 'surname', a character string containing the character 'surname' is identified in the rotationally corrected ID card image, and the identified character string is used as the ID card information containing the target character string 'name'.

[0170] 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, such as Figure 2 As shown, there are two text areas containing address information.

[0171] In order to identify the complete address information, in an embodiment of the present invention, when identifying the address information in the ID card information, the character string in the text area containing the two characters of address is identified in the character string in the determined text area, and the remaining character string in the character string except the two characters of address is determined as the character string corresponding to the address information.

[0172] After determining the text area of ​​the character string containing the two words "address", determine the text area whose vertical coordinate is between the vertical coordinate of the center point of the text area and the vertical coordinate of the center point of the sub-area, and also determine the character string of the text area as the character string corresponding to the address information, and merge the two character strings into one character string, specifically, connect the character string of the text area to the character string of the text area containing the two words "address".

[0173] In an embodiment of the present invention, after determining the character string corresponding to the address information, the character string 'address' is used as the primary key, the character string corresponding to the address information is used as the value of the primary key, and a label is added to the character string corresponding to the address information. When identifying other identity card information, the character string with the label is no longer identified, thereby improving the efficiency of identity card information extraction.

[0174] Embodiment 7:

[0175] Figure 7 A schematic diagram of a process of extracting identity card information provided by an embodiment of the present invention, such as Figure 7 shown.

[0176] S701: Input ID card image.

[0177] S702: Tilt correction: Based on a pre-trained deep learning network model, determine the information of the area where the ID card number is located in the input ID card image; binarize the pixels in the area where the ID card number is located, and determine each connected domain in the area where the ID card number is located based on the pixel value of each pixel after the binarization process, and determine the sub-area containing each connected domain; determine the tilt angle of the ID card image based on the angle between any border line of the sub-area and the horizontal line, and perform tilt correction on the ID card image.

[0178] S703: Text detection: Based on the pre-trained text detection model, the information of each text area containing each ID card information in the tilt-corrected ID card image is detected.

[0179] S704: Text direction detection: Based on the sub-area, if it is determined that the ID card image is located in the horizontal direction, determine a first ratio of the number of text areas whose vertical coordinates are greater than the vertical coordinate of the sub-area to the number of all text areas, and judge whether the first ratio is greater than a first set threshold value. If so, determine that the sub-area is located below the text area; if not, determine that the sub-area is located above the text area; if it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold value. If so, determine that the sub-area is located on the left side of the text area; if not, determine that the sub-area is located on the right side of the text area; based on the determined target relative position of the sub-area in the text area, and the corresponding relationship between the relative position and the rotation angle, determine the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image.

[0180] S705: Text recognition: identifying the ID card information contained in the rotation-corrected ID card image, and determining the character string of each identified text area as a type of ID card information.

[0181] S706: Structural analysis: for each character string contained in the pre-saved ID card information, for each character string, identify the character string of the text area containing the character string in the character string of each text area, and determine the character string of the text area as the ID card information of the character string.

[0182] S707: Ethnic information correction: If the ethnic information in the ID card information is identified in the rotationally corrected ID card image, the first character string corresponding to the ethnic information is matched with each character string in the stored ethnic text database; if a second character string with a similarity greater than a third set threshold is matched in the text database, the identified first character string is used as the ethnic information in the ID card information; if a second character string with a similarity greater than the third set threshold is not matched in the text database, the third character string in the text database with the highest similarity to the first character string is used as the ethnic information in the ID card information.

[0183] S708: Output the recognized ID card information.

[0184] Embodiment 8:

[0185] Based on the above embodiments, Figure 8 A schematic diagram of the structure of an ID card information extraction device provided by an embodiment of the present invention, the device comprising:

[0186] The determination module 801 is used to determine information of the area where the ID card number is located in the input ID card image based on the pre-trained deep learning network model; according to the area where each character is located in the area where the ID card number is located, determine a sub-area containing the area where each character is located;

[0187] The identification module 802 is used to perform tilt correction on the ID card image according to the angle between the border line of the sub-area and the horizontal line, and to perform rotation correction on the ID card image according to the position information of each text area in the ID card image after the tilt correction, and to identify the ID card information contained in the ID card image after the rotation correction.

[0188] The determination module 801 is also used to binarize the pixels in the area where the ID card number is located before determining the sub-area containing the area where each character is located based on the area where each character is located in the area where the ID card number is located, and determine each connected domain in the area where the ID card number is located based on the pixel value of each pixel after the binarization, and determine each connected domain as the area where each character is located.

[0189] The determination module 801 is specifically used to determine each target pixel point whose pixel value is a set pixel value based on the pixel value of each pixel point after binarization processing; for each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point; for each first point set, if there are other first point sets that have the same target pixel points as the first point set, then update the first point set based on the other first point sets that have the same target pixel points until there are no same target pixel points in the other first point sets and the updated first point set; for each updated first point set, determine the connected domain within the area where the ID number is located based on the target pixel points in the updated first point set.

[0190] The determination module 801 is further specifically used to determine the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate based on the pixel points of the area where each character is located in the area where the ID card number is located; determine the boundary pixel points in the area where the ID card number is located based on the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate, and determine the sub-area containing the area where each character is located based on the boundary pixel points.

[0191] The recognition module 802 is specifically used to determine the relative position of the sub-region in the ID card image and each text region based on the position information of each text region in the ID card image after tilt correction detected; determine the rotation angle of the ID card image based on the relative position of the sub-region and each text region, and perform rotation correction on the ID card image.

[0192] The recognition module 802 is specifically configured to detect information of each text region containing each ID card information in the ID card image after tilt correction based on a pre-trained text detection model.

[0193] The identification module 802 is specifically used to determine, based on the sub-area, if it is determined that the ID card image is located in the horizontal direction, a first ratio of the number of text areas whose vertical coordinates are greater than the vertical coordinate of the sub-area to the number of all text areas, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-area is located below the text area, if not, determine that the sub-area is located above the text area; if it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold value, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area; based on the determined target relative position of the sub-area in the text area, and the corresponding relationship between the relative position and the rotation angle, determine the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image.

[0194] The recognition module 802 is specifically used to match the first character string corresponding to the ethnic information with each character string in the stored ethnic text database if the ethnic information in the ID card information is recognized in the corrected ID card image; if a second character string with a similarity greater than a third set threshold is matched in the text database, the recognized first character string is used as the ethnic information in the ID card information; if a second character string with a similarity greater than the third set threshold is not matched in the text database, the third character string in the text database with the highest similarity to the first character string is used as the ethnic information in the ID card information.

[0195] The recognition module 802 is also specifically used to determine whether the number of recognized ID card information reaches a set threshold number; if not, based on each character string contained in the pre-saved ID card information, determine the target character string that is not recognized in the ID card image, split the target character string into multiple characters, and for each character, identify the character string in the corrected ID card image, and use the identified character string as the ID card information containing the target character string.

[0196] Embodiment 9:

[0197] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Based on the above embodiments, an electronic device is further provided in an embodiment of the present invention, including a processor 901, a communication interface 902, a memory 903 and a communication bus 904, wherein the processor 901, the communication interface 902, and the memory 903 communicate with each other through the communication bus 904;

[0198] The memory 903 stores a computer program. When the program is executed by the processor 901, the processor 901 performs the following steps:

[0199] Based on the pre-trained deep learning network model, determine the information of the area where the ID card number is located in the input ID card image;

[0200] According to the area where each character is located in the area where the ID card number is located, determining a sub-area including the area where each character is located;

[0201] The ID card image is tilt-corrected according to the angle between the border line of the sub-area and the horizontal line, and the ID card image is rotation-corrected according to the position information of each text area in the ID card image after the tilt correction, and the ID card information contained in the ID card image after the rotation correction is identified.

[0202] Further, the processor 901 is specifically used for determining, according to the area where each character is located in the area where the ID card number is located, before the sub-area containing the area where each character is located, the method also includes:

[0203] Binarization is performed on the pixels in the area where the ID card number is located, and each connected domain in the area where the ID card number is located is determined based on the pixel value of each pixel after the binarization process, and each connected domain is determined as the area where each character is located.

[0204] Further, the processor 901 is specifically used to determine each connected domain in the area where the ID card number is located according to the pixel value of each pixel after the binarization process, including:

[0205] According to the pixel value of each pixel point after the binarization process, determine each target pixel point whose pixel value is the set pixel value;

[0206] For each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point;

[0207] For each first point set, if there are other first point sets having the same target pixel as the first point set, the first point set is updated based on the other first point sets having the same target pixel until the other first point sets do not have the same target pixel as the updated first point set;

[0208] For each updated first point set, a target pixel point in the updated first point set is determined as a connected domain within the area where the ID card number is located.

[0209] Further, the processor 901 is specifically configured to determine the sub-region including the region where each character is located, including:

[0210] Determine the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate according to the pixel points of the area where each character is located in the area where the ID card number is located;

[0211] The boundary pixel points in the area where the ID card number is located are determined based on the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate, and the sub-area containing the area where each character is located is determined based on the boundary pixel points.

[0212] Furthermore, the rotation correction of the ID card image according to the position information of each text area in the ID card image after the tilt correction includes:

[0213] Determine the relative position of the sub-region in the ID card image and each text region according to the position information of each text region in the ID card image after tilt correction obtained by detection;

[0214] According to the relative position of the sub-region and each text region, the rotation angle of the ID card image is determined, and rotation correction is performed on the ID card image.

[0215] Furthermore, the processor 901 is specifically configured to detect each text area in the ID card image after tilt correction, including:

[0216] Based on the pre-trained text detection model, information of each text area containing each ID card information in the tilt-corrected ID card image is detected.

[0217] Further, the processor 901 is specifically used to determine the rotation angle of the ID card image according to the relative position of the sub-region and each text region, including:

[0218] According to the sub-region, if it is determined that the ID card image is located in the horizontal direction, determine a first ratio of the number of text regions whose ordinates are greater than the ordinate of the sub-region to the number of all text regions, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-region is located below the text region, if not, determine that the sub-region is located above the text region;

[0219] If it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area;

[0220] According to the determined target relative position of the sub-region in the text region and the correspondence between the relative position and the rotation angle, the rotation angle corresponding to the target relative position is determined as the target rotation angle of the ID card image.

[0221] Furthermore, the processor 901 is specifically used for identifying the ID card information contained in the ID card image after rotation correction, including:

[0222] If ethnic information in the ID card information is recognized in the corrected ID card image, matching the first character string corresponding to the ethnic information with each character string in the stored ethnic character database;

[0223] If a second character string with a similarity greater than a third set threshold is matched in the character database, the identified first character string is used as the ethnicity information in the identity card information;

[0224] If a second character string with a similarity greater than a third set threshold value is not matched in the character database, a third character string with the highest similarity to the first character string in the character database is used as the ethnicity information in the identity card information.

[0225] Furthermore, the processor 901 is specifically used to identify the ID card information contained in the ID card image after rotation correction, including:

[0226] Determine whether the number of recognized ID card information reaches a set number threshold;

[0227] If not, determine the target string that is not recognized in the ID card image based on each string contained in the pre-saved ID card information, split the target string into multiple characters, and for each character, identify the string containing the character in the corrected ID card image, and use the identified string as the ID card information containing the target string.

[0228] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0229] The communication interface 902 is used for communication between the electronic device and other devices.

[0230] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0231] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0232] Embodiment 10:

[0233] On the basis of the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to perform the following steps:

[0234] Based on the pre-trained deep learning network model, determine the information of the area where the ID card number is located in the input ID card image;

[0235] According to the area where each character is located in the area where the ID card number is located, determining a sub-area including the area where each character is located;

[0236] The ID card image is tilt-corrected according to the angle between the border line of the sub-area and the horizontal line, and the ID card image is rotation-corrected according to the position information of each text area in the ID card image after the tilt correction, and the ID card information contained in the ID card image after the rotation correction is identified.

[0237] Furthermore, before determining the sub-region including the region where each character is located according to the region where each character is located in the region where the ID card number is located, the method further includes:

[0238] Binarization is performed on the pixels in the area where the ID card number is located, and each connected domain in the area where the ID card number is located is determined based on the pixel value of each pixel after the binarization process, and each connected domain is determined as the area where each character is located.

[0239] Determining each connected domain in the area where the ID card number is located according to the pixel value of each pixel after the binarization process includes:

[0240] According to the pixel value of each pixel point after the binarization process, determine each target pixel point whose pixel value is the set pixel value;

[0241] For each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point;

[0242] For each first point set, if there are other first point sets having the same target pixel as the first point set, the first point set is updated based on the other first point sets having the same target pixel until the other first point sets do not have the same target pixel as the updated first point set;

[0243] For each updated first point set, a target pixel point in the updated first point set is determined as a connected domain within the area where the ID card number is located.

[0244] Determining the sub-region containing the region where each character is located includes:

[0245] Determine the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate according to the pixel points of the area where each character is located in the area where the ID card number is located;

[0246] The boundary pixel points in the area where the ID card number is located are determined based on the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate, and the sub-area containing the area where each character is located is determined based on the boundary pixel points.

[0247] Furthermore, the rotation correction of the ID card image according to the position information of each text area in the ID card image after the tilt correction includes:

[0248] Determine the relative position of the sub-region in the ID card image and each text region according to the position information of each text region in the ID card image after tilt correction obtained by detection;

[0249] According to the relative position of the sub-region and each text region, the rotation angle of the ID card image is determined, and rotation correction is performed on the ID card image.

[0250] Detecting each text area in the tilt-corrected ID card image, including:

[0251] Based on the pre-trained text detection model, information of each text area containing each ID card information in the tilt-corrected ID card image is detected.

[0252] Determining the rotation angle of the ID card image according to the relative position of the sub-region and each text region includes:

[0253] According to the sub-region, if it is determined that the ID card image is located in the horizontal direction, determine a first ratio of the number of text regions whose ordinates are greater than the ordinate of the sub-region to the number of all text regions, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-region is located below the text region, if not, determine that the sub-region is located above the text region;

[0254] If it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than the second set threshold, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area;

[0255] According to the determined target relative position of the sub-region in the text region and the correspondence between the relative position and the rotation angle, the rotation angle corresponding to the target relative position is determined as the target rotation angle of the ID card image.

[0256] The ID card information contained in the ID card image after the identification rotation correction includes:

[0257] If ethnic information in the ID card information is recognized in the corrected ID card image, matching the first character string corresponding to the ethnic information with each character string in the stored ethnic character database;

[0258] If a second character string with a similarity greater than a third set threshold is matched in the character database, the identified first character string is used as the ethnicity information in the identity card information;

[0259] If a second character string with a similarity greater than a third set threshold value is not matched in the character database, a third character string with the highest similarity to the first character string in the character database is used as the ethnicity information in the identity card information.

[0260] The identification card information contained in the identification card image after the rotation correction includes:

[0261] Determine whether the number of recognized ID card information reaches a set number threshold;

[0262] If not, determine the target string that is not recognized in the ID card image based on each string contained in the pre-saved ID card information, split the target string into multiple characters, and for each character, identify the string containing the character in the corrected ID card image, and use the identified string as the ID card information containing the target string.

[0263] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0264] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0265] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0266] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0267] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these 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 also intended to include these modifications and variations.

Claims

1. A method for extracting identity card information, characterized in that: The method comprises: Based on the pre-trained deep learning network model, determine the information of the area where the ID card number is located in the input ID card image; According to the area where each character is located in the area where the ID card number is located, determining a sub-area including the area where each character is located; According to the angle between the border line of the sub-region and the horizontal line, the ID card image is tilt-corrected, and according to the position information of each text area in the ID card image after the tilt correction, the ID card image is rotation-corrected, and the ID card information contained in the ID card image after the rotation correction is identified; The step of performing rotation correction on the ID card image according to the position information of each text area in the ID card image after tilt correction includes: Determine the relative position of the sub-region in the ID card image and each text region according to the position information of each text region in the ID card image after tilt correction obtained by detection; Determining the rotation angle of the ID card image according to the relative position of the sub-region and each text region, and performing rotation correction on the ID card image; Wherein, determining the rotation angle of the ID card image according to the relative position of the sub-region and each text region includes: According to the sub-region, if it is determined that the ID card image is located in the horizontal direction, determine a first ratio of the number of text regions whose ordinates are greater than the ordinate of the sub-region to the number of all text regions, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-region is located below the text region, if not, determine that the sub-region is located above the text region; If it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than a second set threshold, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area; According to the determined target relative position of the sub-region in the text region and the correspondence between the relative position and the rotation angle, the rotation angle corresponding to the target relative position is determined as the target rotation angle of the ID card image.

2. The method according to claim 1, characterized in that Before determining the sub-region including the region where each character is located according to the region where each character is located in the region where the ID card number is located, the method further includes: Binarization is performed on the pixels in the area where the ID card number is located, and each connected domain in the area where the ID card number is located is determined based on the pixel value of each pixel after the binarization process, and each connected domain is determined as the area where each character is located.

3. The method according to claim 2, characterized in that Determining each connected domain in the area where the ID card number is located according to the pixel value of each pixel after the binarization process includes: According to the pixel value of each pixel point after the binarization process, determine each target pixel point whose pixel value is the set pixel value; For each target pixel point, determine each first point set consisting of the target pixel point and other target pixel points adjacent to the target pixel point; For each first point set, if there are other first point sets having the same target pixel as the first point set, the first point set is updated based on the other first point sets having the same target pixel until the other first point sets do not have the same target pixel as the updated first point set; For each updated first point set, a target pixel point in the updated first point set is determined as a connected domain within the area where the ID card number is located.

4. The method according to claim 1 or 2, characterized in that: Determining the sub-region containing the region where each character is located includes: Determine the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate according to the pixel points of the area where each character is located in the area where the ID card number is located; The boundary pixel points in the area where the ID card number is located are determined based on the maximum and minimum values ​​of the horizontal coordinate and the maximum and minimum values ​​of the vertical coordinate, and the sub-area containing the area where each character is located is determined based on the boundary pixel points.

5. The method according to claim 1, characterized in that Detecting each text area in the tilt-corrected ID card image, including: Based on the pre-trained text detection model, information of each text area containing each ID card information in the tilt-corrected ID card image is detected.

6. The method according to claim 1, characterized in that The ID card information contained in the ID card image after the identification rotation correction includes: If ethnic information in the ID card information is recognized in the corrected ID card image, matching the first character string corresponding to the ethnic information with each character string in the stored ethnic character database; If a second character string with a similarity greater than a third set threshold is matched in the character database, the identified first character string is used as the ethnicity information in the identity card information; If a second character string with a similarity greater than a third set threshold value is not matched in the character database, a third character string with the highest similarity to the first character string in the character database is used as the ethnicity information in the identity card information.

7. The method according to claim 1, characterized in that The identification card information contained in the identification card image after the rotation correction includes: Determine whether the number of recognized ID card information reaches a set number threshold; If not, determine the target string that is not recognized in the ID card image based on each string contained in the pre-saved ID card information, split the target string into multiple characters, and for each character, identify the string containing the character in the corrected ID card image, and use the identified string as the ID card information containing the target string.

8. An ID card information extraction device, characterized in that: The device comprises: A determination module is used to determine information of the area where the ID card number is located in the input ID card image based on a pre-trained deep learning network model; and determine 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 ID card number is located; A recognition module, configured to perform tilt correction on the ID card image according to the angle between the border line of the sub-region and the horizontal line, and to perform rotation correction on the ID card image according to the position information of each text area in the ID card image after the tilt correction, and to recognize the ID card information contained in the ID card image after the rotation correction; The recognition module is specifically used to determine the relative position of the sub-region in the ID card image and each text region according to the position information of each text region in the ID card image after tilt correction detected; determine the rotation angle of the ID card image according to the relative position of the sub-region and each text region, and perform rotation correction on the ID card image; The recognition module is specifically used to determine, based on the sub-area, if it is determined that the ID card image is located in the horizontal direction, a first ratio of the number of text areas whose vertical coordinates are greater than the vertical coordinate of the sub-area to the number of all text areas, and judge whether the first ratio is greater than a first set threshold value, if so, determine that the sub-area is located below the text area, if not, determine that the sub-area is located above the text area; if it is determined that the ID card image is located in the vertical direction, determine a second ratio of the number of text areas whose horizontal coordinates are greater than the horizontal coordinate of the sub-area to the number of all text areas, and judge whether the second ratio is greater than a second set threshold value, if so, determine that the sub-area is located on the left side of the text area, if not, determine that the sub-area is located on the right side of the text area; based on the determined target relative position of the sub-area in the text area, and the corresponding relationship between the relative position and the rotation angle, determine the rotation angle corresponding to the target relative position as the target rotation angle of the ID card image.

9. An electronic device, characterized in that: The electronic device includes a processor and a memory, the memory is used to store program instructions, and the processor is used to implement the steps of the identity card information extraction method as described in any one of claims 1-7 when executing the computer program stored in the memory.

10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the steps of the method for extracting identity card information as described in any one of claims 1-7.

Citation Information

Cited By

  • Image information extraction method and device and medium

    CN114119349A