Method for detecting abnormal fonts in ID numbers
By establishing a single -character image template library and using the connected area analysis method to divide the single character image, the character matching and rules are judged, and the problem of the lack of the authenticity of the certificate of the certificate directly through the certificate number font identification in the existing technology has been solved. Effective identification and forgery judgments have high accuracy and scalability.
Patent Information
- Application Number
- CN202211526626.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-01
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2042-12-01
AI Technical Summary
The existing technology lacks a method to directly identify the authenticity of a document through the font of the document number, and it is difficult to effectively identify whether the document number is abnormal and thus determine whether the document is forged.
Using the certificate number font anomalies, by establishing a single character image template library, using the connected regional analysis method to divide the single character image, perform character matching, calculate the matching probability value, and judge according to the set rules to determine whether the font of the document number is normal Essence
The effective identification of the document number font can be achieved, which can accurately determine whether the document is forgery. It has high versatility and scalability, fast execution speed, and high accuracy.
Smart Images

Figure CN118135579B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for detecting abnormal fonts of certificate numbers. Background Art
[0002] At present, document recognition is required in many fields, where the document can be an ID card, passport, driver's license, etc. For example, when handling business at a bank, a user is required to present an ID card for ID card recognition to verify the user's identity information; when a user takes a high-speed train or airplane and other travel tools, the ID card needs to be recognized.
[0003] The font of the ID number of a certain type of ID card in a certain country (such as ID card, driver's license, etc.) is fixed, consistent, and protected by copyright. When counterfeiting ID numbers, the black industry often uses other font types, which are significantly different from the fonts of the real ID numbers. Therefore, based on the identification of whether the font is consistent, without knowing the specific font type, it is possible to effectively identify whether the ID number is abnormal, thereby judging whether the ID is forged. However, there is currently a lack of methods to directly identify the authenticity of IDs through the ID font. For this purpose, a method for detecting ID number font anomalies is proposed. Summary of the invention
[0004] The purpose of the present invention is to solve the problem that the prior art lacks a method for directly identifying the authenticity of a certificate by the font of the certificate number, and to propose a method for detecting abnormalities in the font of the certificate number.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] The method for detecting abnormal fonts of ID numbers includes establishing a single-character image template library using normal ID numbers, segmenting single-character images on a binary image based on a connected region analysis method, obtaining a matching N*M probability value by character matching, setting rules, and performing rule judgment. The specific steps are as follows:
[0007] S1. Text detection and positioning: For the input image to be detected, all text strip images on the image are located through the pre-trained text detection model, and the document number text strip image is extracted based on the text recognition content or text coordinates;
[0008] S2. Establishing a database: The character set of the ID number is fixed. Using the character segmentation method, the normal ID number text image is segmented into ten single-character images as templates;
[0009] S3, image segmentation: grayscale processing is performed on the document number text strip image, and then binarization is performed to obtain a binary image, connected region analysis is performed on the binary image, the connected regions are converted into bounding boxes, and based on these bounding boxes, the binarized single character images are segmented on the binary image;
[0010] S4, character matching: after character segmentation, multiple single character images are obtained, and each character image is template matched with each character in the template library to obtain N*M matching probability values;
[0011] S5. Rule judgment: For N*M matching probability values, set a threshold t, calculate the maximum matching probability value of N characters respectively, and then calculate the average probability value m of the maximum probability value, where N represents the number of characters in the ID number and M represents the number of templates.
[0012] Preferably, in S5, it is assumed that the number of characters whose maximum probability values are greater than or equal to the threshold value t is n1, and the number of characters whose maximum probability values are less than the threshold value t is n2, wherein n1+n2=N.
[0013] Setting rules:
[0014] (1) If m is greater than or equal to 0.9 or;
[0015] (2) (n1 is greater than n2 or n2-n1 is less than 3) and m>0.7 or;
[0016] (3) n1-n2 is greater than or equal to 2 and m>0.5;
[0017] If the font of the certificate number is normal, otherwise it is abnormal.
[0018] Preferably, in S3, the connected regions are converted into bounding boxes, and bounding boxes with width and height less than 10 pixels are filtered out. For the remaining bounding boxes, if one box is contained in another box, the box is removed, and the bounding boxes left at last are the positions of the characters.
[0019] Preferably, the method for obtaining a binary image by binarizing the image in S3 is to extract and detect the ID number text image, binarize the ID number text image, and then obtain the positions of each single character through connected region analysis and post-processing, and crop the selected single characters at each single character position.
[0020] Preferably, template matching is performed on the single character image in S4. The domestic resident identity card number has 18 digits, that is, N is 18 and M is 10. The Indonesian second-generation identity card number has 16 digits, that is, N is 16 and M is 10. Each character image is template matched with each character in the template library.
[0021] Compared with the prior art, the present invention has the following beneficial effects:
[0022] 1. The present invention has strong versatility and can be used for any type of certificate at home and abroad, which is convenient for migration. It does not rely on training learning models, and has strong scalability for newly added abnormal font types. It has fast execution speed. According to the number of digits in the certificate number, a series of character similarities can be obtained, and the accuracy rate is high through multi-dimensional and multi-level rule design.
[0023] 2. The present invention is based on a multi-character template matching structure, and can construct multi-level judgment rules to enhance robustness. The connected region analysis method is used to obtain the position of a single character in the ID number image. The obtained bounding box is close to the character area, making the cropped characters more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 This is a schematic diagram of the structure of the method for detecting abnormal fonts of ID numbers proposed by the present invention;
[0025] Figure 2 A schematic diagram of a font template library for the ID number font anomaly detection method proposed by the present invention;
[0026] Figure 3 This is a schematic diagram of an example of ID number image binarization and segmentation of the ID number font anomaly detection method proposed in the present invention. DETAILED DESCRIPTION
[0027] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. 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 making creative work are within the scope of protection of the present invention.
[0028] Example
[0029] Reference Figure 1-3 The method for detecting abnormal fonts of ID numbers includes establishing a single-character image template library using normal ID numbers, segmenting single-character images on binary images based on connected region analysis, obtaining matching N*M probability values through character matching, setting rules, and making rule judgments.
[0030] For the input image to be detected, all text strip images on the image are located through a pre-trained text detection model, and the ID number text strip image is extracted based on the text recognition content or text coordinates. The extraction method can be performed through the ID collection terminal device, and the ID image data is pre-recognized to obtain the ID type data, and then the template library of the corresponding type of ID is selected for use according to the type of ID.
[0031] The processing of the document number text strip image is divided into the following steps:
[0032] First, create a normal document number single character image template library. The character set of the document number is fixed, such as the character set of the domestic resident ID card number, which is 0-9. Use the following character segmentation method to segment the normal document number text image into ten single character images as templates.
[0033] like Figure 2 It takes the Indonesian ID card as an example:
[0034] Taking the normal ID number font template library as an example, a is the original image of ten single characters from 0 to 9, and b is the template image corresponding to the single characters from 0 to 9 after binarization processing.
[0035] Secondly, character segmentation: the document number text strip image is grayscale processed and then binarized to obtain a binary image. The binary image is subjected to connected region analysis and the connected regions are converted into bounding boxes. Bounding boxes with width and height less than 10 pixels are filtered out. For the remaining bounding boxes, if a box is contained in another box, the box is removed. The bounding boxes remaining at the end are the positions of each character. Based on these bounding boxes, the single character image that has been binarized is segmented on the binary image.
[0036] Further, the examples of binarization and segmentation of the ID number image to be detected involved in the above description can be referred to Figure 3 , which uses the Indonesian ID card as an example;
[0037] As shown in the figure, a is the image of the ID number to be detected, b is the result after binarization processing, c is the position of each single character obtained by using the connected region analysis method and post-processing, d is the single character cropped on b based on the positioning result of c, and e is the single character cropped on a based on the positioning result of c;
[0038] Again, character matching, after character segmentation, we get multiple single-character images. For example, the domestic resident ID number is 18 digits, that is, N is 18 and M is 10. The Indonesian second-generation ID number is 16 digits, that is, N is 16 and M is 10. Each character image is matched with each character in the template library to get N*M matching probability values, where N is the length of the ID number and M is the number of characters in the template library. If it is a number, it is ten numbers from 0 to 9, and M is 10.
[0039] Finally, rule judgment, for N*M matching probability values, set a threshold t, calculate the maximum matching probability value of N characters respectively, and then calculate the average probability value m of the maximum probability value. Assuming that the number of characters with the maximum probability value greater than or equal to the threshold t is n1, the number of characters less than the threshold t is n2, where n1+n2=N. Set the rule that if m is greater than or equal to 0.9 or (n1 is greater than n2 or n2-n1 is less than 3) and m>0.7 or n1-n2 is greater than or equal to 2 and m>0.5, then the ID number font is normal, otherwise it is judged that the ID number is abnormal, and the judged data is transmitted to the processing terminal;
[0040] Among them, it is worth noting that:
[0041] The present invention can be implemented and deployed using any programming language, taking Python as an example.
[0042] Depends on the opencv image processing algorithm library, the operation steps are as follows:
[0043] First, create a template (if it has been created, there is no need to create it again), first crop single characters from the normal document number image, select a character set, such as the ten characters 0-9 in the ID card, perform binarization processing, and save it as a template library.
[0044] In the detection stage, the template library is loaded first, that is, the ten binary character images created in the first step.
[0045] Secondly, read the image to be detected, convert it into a binary image, and segment the single character image;
[0046] Again, for each segmented single-character image, template matching is performed in the template library to obtain a series of matching probability values. Assuming that the number of character sets in the template library is M and the length of the document number is N, N*M probability values are obtained.
[0047] Finally, the above rules are used to make judgments and output whether it is normal or abnormal.
[0048] The present invention does not need to identify specific font types and does not rely on learning models trained using data, so it is more scalable. Even if the counterfeit font is not found in the early experimental stage, it can be correctly identified in the application stage. The connected region analysis method is used to obtain the location of the single character in the document number image, and the obtained bounding box is close to the character area, making the cropped characters more accurate;
[0049] Based on the multi-character template matching structure, multi-level judgment rules can be constructed to enhance robustness.
[0050] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for detecting abnormal fonts of ID numbers, characterized in that: It includes using normal ID numbers to establish a single-character image template library, separating single-character images on a binary image based on a bounding box, matching characters to obtain N*M probability values, setting rules, and making rule judgments. The specific steps are as follows: S1. Text detection and positioning: For the input image to be detected, all text strip images on the image are located through the pre-trained text detection model, and the document number text strip image is extracted based on the text recognition content or text coordinates; S2. Establishing a database: The character set of the ID number is fixed. Using the character segmentation method, the normal ID number text image is segmented into ten single-character images as templates; S3, image segmentation: grayscale processing is performed on the document number text strip image, and then binarization is performed to obtain a binary image, connected region analysis is performed on the binary image, the connected regions are converted into bounding boxes, and based on these bounding boxes, the binarized single character images are segmented on the binary image; S4, character matching: after character segmentation, multiple single character images are obtained, and each character image is template matched with each character in the template library to obtain N*M matching probability values; S5, rule judgment: for N*M matching probability values, set a threshold t, calculate the maximum matching probability value of N characters respectively, and then calculate the average probability value m of the maximum probability value, where N represents the number of characters in the ID number and M represents the number of templates; In S3, the connected regions are converted into bounding boxes, and bounding boxes with width and height less than 10 pixels are filtered out. For the remaining bounding boxes, if a box is contained in another box, the box is removed, and the bounding boxes left at last are the positions of the characters. The method for obtaining a binary image by binarizing the image in S3 is to extract and detect the ID number text image, binarize the ID number text image, obtain the position of each single character by connected region analysis and post-processing, and cut the selected single character at each single character position; Based on the multi-character template matching structure, multi-level judgment rules can be constructed to enhance robustness. The connected region analysis method is used to obtain the location of single characters in the ID number image. The obtained bounding box is close to the character area, making the cropped characters more accurate.
2. The method for detecting abnormal fonts of ID numbers according to claim 1, characterized in that: In S5, it is assumed that the number of characters whose maximum probability value is greater than or equal to the threshold value t is n1, and the number of characters whose maximum probability value is less than the threshold value t is n2, where n1+n2=N; Setting rules: (1) If m is greater than or equal to 0.9; or, (2) n1 is greater than n2 or n2-n1 is less than 3, and m>0.7; or, (3) n1-n2 is greater than or equal to 2 and m>0.5; If the font of the certificate number is normal, otherwise it is abnormal.
3. The method for detecting abnormal fonts of ID numbers according to claim 1, characterized in that: In S4, template matching is performed on the single character image. The domestic resident ID card number has 18 digits, that is, N is 18 and M is 10. The Indonesian second-generation ID card number has 16 digits, that is, N is 16 and M is 10. Each character image is template matched with each character in the template library.
Citation Information
Patent Citations
Identity card number identification method and device thereof
CN107346427A
Parking lot license plate similarity matching method
CN110348501A
Certificate verification method and device based on image recognition, computer equipment and medium
CN111709413A