A classification method for pre-positioned character recognition
By using a text classification model and intersection-union ratio (IUU) calculation, the problem of low accuracy in identifying similar voucher types in existing technologies has been solved, achieving higher recognition accuracy and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HUNAN SANXIANG BANK CO LTD
- Filing Date
- 2022-11-29
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies have low accuracy and difficulty in effectively distinguishing similar document types.
The converted text of the image to be identified is analyzed by a text classification model. The image category is finally determined by combining the test probability value of the recognition template and the intersection-union ratio. The final probability value is calculated using the formula final_score=α*text_score+β*box_score. The candidate recognition template with the highest probability value is selected as the category of the target image.
It improves the accuracy of identifying similar voucher types, reduces the risk of incorrect classification, and enhances the accuracy and reliability of calculation results.
Smart Images

Figure CN115862034B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image information recognition technology, specifically, it relates to a classification method for pre-recognition text. Background Technology
[0002] Optical character recognition technology is currently being widely used in various industries. In financial scenarios, a large number of invoices require manual review, such as verifying the consistency between invoice information and reimbursement applications. Therefore, automated invoice recognition can greatly reduce the workload of financial personnel and can even digitize the entire process, greatly improving the efficiency of the entire process.
[0003] Whether it's cards or invoices, there are many different types in actual business scenarios. When applying them in business, the type of document or invoice may not be known in advance. A typical scenario is the identification of mixed invoices in a financial setting. When identifying mixed invoices, the corresponding area can be captured as an image, and then the image can be identified. The backend recognition algorithm must be able to determine the type of the invoice before selecting the appropriate algorithm.
[0004] Existing technologies generally extract image or text features from the cropped sub-image and then apply a classification task to determine the type of the ticket. Image or text feature-based classification methods are effective in distinguishing general cards or tickets, but they are often difficult and have low accuracy for similar ticket types. To solve the above problems, this invention provides the following technical solution. Summary of the Invention
[0005] The purpose of this invention is to provide a classification method for pre-recognition text recognition, which solves the problem that the existing technology often has great difficulty and low accuracy in determining similar voucher types.
[0006] The objective of this invention can be achieved through the following technical solutions:
[0007] A classification method for pre-recognition text includes the following steps:
[0008] S1. Obtain the image to be recognized;
[0009] S2. Mark an image to be recognized as the target image to be recognized, read the text in the target image to be recognized, and obtain the corresponding converted text;
[0010] S3. For the converted text of the target image to be recognized, the converted text is analyzed by the text classification model to obtain the test probability value text_score of the target image to be recognized belonging to each recognition template, and i recognition templates are selected as candidate recognition templates.
[0011] S4. Match the converted text with i candidate recognition templates. Specifically, for a candidate recognition template, correct and locate the candidate recognition template with the image to be recognized.
[0012] Retrieve the recognition fields from the image to be recognized;
[0013] According to the formula The matching probability value box_score of the target image to be identified belongs to a candidate recognition template is calculated;
[0014] Where n is the number of recognition fields in the corresponding candidate recognition template, iou k Let IoU be the intersection-union ratio of the k-th recognition field in the candidate recognition template and the target image to be recognized. If no corresponding k-th recognition field is found in the target image to be recognized, then IoU is used. k The value is 0;
[0015] Where 1≤k≤n;
[0016] S5. Calculate the final probability value final_score of the target image corresponding to each candidate recognition template according to the formula final_score=α*text_score+β*box_score. Select the candidate recognition template with the largest final_score as the recognition template of the target image, mark the category to which the recognition template belongs as the category of the target image and classify it.
[0017] Where α and β are both preset coefficients, and satisfy α+β=1;
[0018] In one embodiment of the present invention, the value of α is 0.4, and the value of β is 0.6;
[0019] As a further aspect of the present invention, the method for obtaining the image to be identified is as follows:
[0020] Acquire an image containing one or more images to be identified;
[0021] After obtaining the edge region of the image to be recognized, it is cropped to obtain one or more corresponding images to be recognized.
[0022] As a further embodiment of the present invention, the text classification model includes TF-IDF, TextCNN, and BERT.
[0023] As a further aspect of the present invention, when selecting recognition templates as candidate recognition templates, i recognition templates with a test probability value text_score greater than a preset value ty are selected as candidate recognition templates or
[0024] Select the i recognition templates with the largest test probability value (text_score) as candidate recognition templates or
[0025] Select the i recognition templates whose test probability value text_score is greater than the preset value ty and has the largest value as candidate recognition templates;
[0026] i is the default value.
[0027] As a further embodiment of the present invention, the value of i is 5.
[0028] As a further aspect of the present invention, the method for correcting and locating the candidate recognition template and the target image to be recognized is as follows:
[0029] Obtain the location field of the candidate recognition template, and mark the location field sequentially as z11, z12, ..., z1r;
[0030] Obtain the corresponding location field in the target image to be identified, and label the location field sequentially as z21, z22, ..., z2r;
[0031] Each positioning field is defined by a rectangular positioning box, and only one positioning field is set within each positioning box.
[0032] After initially matching the target image to be identified with the candidate recognition templates, z1j and z2j are matched, and the intersection-union ratio Bj of the localization boxes corresponding to z1j and z2j is calculated.
[0033] The average intersection-union ratio (Bp) of the current position is calculated using the formula Bp=(B1+B2+、…、+Br) / r.
[0034] The relative positions of the target image to be identified and the candidate recognition templates are adjusted to obtain the corresponding average intersection-union ratio (IU / Bp). The positional relationship corresponding to the largest average IU / Bp is selected as the final relative position of the target image to be identified and the candidate recognition templates.
[0035] As a further aspect of the present invention, the method for obtaining the positioning field of the candidate identification template is as follows:
[0036] Obtain the recognition fields from each candidate recognition template, merge them, and then obtain the recognition fields that exist in all i candidate recognition templates, and mark them as candidate fields.
[0037] For a candidate recognition template, the candidate recognition template is divided into four polygons by connecting the geometric center of the candidate recognition template with the four corners;
[0038] Choose 1 to 2 candidate fields from each of the four polygons. When two polygons share a side, mark the two polygons as adjacent polygons.
[0039] Obtain the connection length L between the centers of each candidate field. The connection rule between the centers of each candidate field is that the center of a candidate field within a polygon is only connected to the centers of other candidate fields within the same polygon and the closest candidate field center within the adjacent polygon. The center of a candidate field is connected only twice.
[0040] The obtained line lengths L are sequentially labeled as L1, L2, ..., Lx, according to the formula...
[0041] The dispersion value U of this set of data was calculated;
[0042] Where 1≤h≤x, Lp=(L1+L2+,…+Lx) / x;
[0043] Select the candidate field distribution pattern with the largest Lp from several groups with the smallest dispersion value U, and use the corresponding candidate field as the positioning field.
[0044] The beneficial effects of this invention are:
[0045] (1) By considering both the content and position of each field, this invention can more clearly and accurately analyze and determine the category of the image to be identified. Especially when there is a large similarity between two certificates, this method can significantly reduce the risk of category classification error.
[0046] (2) During the process of acquiring the target image to be identified, the object itself may be bent or deformed, which may cause the target image to be identified to fail to form a good positional correspondence with the candidate identification template, thereby affecting the accuracy of subsequent probability value calculation. This invention uses the fields on the template and the image to be identified as positioning points, and calculates the positional correspondence scheme that is most favorable to the overall matching effect between the target image to be identified and the candidate identification template through the import of the intersection-union ratio. This can minimize the impact of the low quality of the target image to be identified and improve the accuracy and reliability of the calculation results.
[0047] (3) The present invention can automatically select the positioning field, and the selected positioning field has a uniform distribution effect. The positioning field is as close to the edge as possible, which is beneficial to the position matching and correction of the candidate recognition template and the target image to be recognized. Attached Figure Description
[0048] The invention will now be further described with reference to the accompanying drawings.
[0049] Figure 1 This is a schematic diagram of the flowchart framework of the classification method for pre-character recognition in this invention. Detailed Implementation
[0050] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0051] A classification method for pre-recognition text includes the following steps:
[0052] S1. Obtain the image to be recognized. The coverage area of an image to be recognized is all images within the edge of the corresponding voucher.
[0053] The method for obtaining the image to be recognized is as follows:
[0054] Images are acquired by means of taking photos, scanning, etc., and include one or more images to be identified.
[0055] After obtaining the edge region of the image to be recognized, it is cropped to obtain one or more corresponding images to be recognized;
[0056] It is important to note that when acquiring the image to be identified, the target should be as flat as possible.
[0057] S2. Mark an image to be recognized as the target image to be recognized, read the text in the target image to be recognized, and obtain the corresponding converted text;
[0058] S3. For the converted text of the target image to be recognized, the converted text is analyzed by the text classification model to obtain the test probability value text_score of the target image to be recognized belonging to each recognition template, and i recognition templates are selected as candidate recognition templates.
[0059] The text classification models include TF-IDF, TextCNN, and BERT;
[0060] When selecting recognition templates as candidate recognition templates, based on the actual situation, you can choose i recognition templates whose test probability value text_score is greater than the preset value ty as candidate recognition templates or...
[0061] Select the i recognition templates with the largest test probability value (text_score) as candidate recognition templates or
[0062] Select the i recognition templates whose test probability value text_score is greater than the preset value ty and has the largest value as candidate recognition templates;
[0063] In one embodiment of the present invention, i is taken as 5;
[0064] The identification template is a template for cards, certificates, tickets and other vouchers that need to be classified and processed. The position and content of the identification fields in the voucher corresponding to the identification template are completely the same.
[0065] S4. Match the converted text with i candidate recognition templates. Specifically, for a candidate recognition template, correct and locate the candidate recognition template with the image to be recognized.
[0066] Retrieve the recognition fields from the image to be recognized;
[0067] According to the formula The matching probability value box_score of the target image to be identified belongs to a candidate recognition template is calculated;
[0068] Where n is the number of recognition fields in the corresponding candidate recognition template, iou k Let IoU be the intersection-union ratio of the k-th recognition field in the candidate recognition template and the target image to be recognized. If no corresponding k-th recognition field is found in the target image to be recognized, then IoU is used. k The value is 0;
[0069] Where 1≤k≤n;
[0070] S5. Calculate the final probability value final_score of the target image corresponding to each candidate recognition template according to the formula final_score=α*text_score+β*box_score. Select the candidate recognition template with the largest final_score as the recognition template of the target image, mark the category to which the recognition template belongs as the category of the target image and classify it.
[0071] Where α and β are both preset coefficients, and satisfy α+β=1;
[0072] In one embodiment of the present invention, the value of α is 0.4, and the value of β is 0.6;
[0073] This invention, by simultaneously considering the content and position of each field, can more clearly and accurately analyze and determine the category of the image to be identified. Especially when two documents are highly similar, this method can significantly reduce the risk of category classification errors.
[0074] The method for correcting and locating the candidate recognition template and the target image to be recognized is as follows:
[0075] Obtain the location field of the candidate recognition template, and mark the location field sequentially as z11, z12, ..., z1r;
[0076] Obtain the corresponding location field in the target image to be identified, and label the location field sequentially as z21, z22, ..., z2r;
[0077] Each positioning field is defined by a rectangular positioning box. One positioning field is set within each positioning box, and the positioning box is kept as close to the positioning field as possible without touching it.
[0078] After initially matching the target image to be identified with the candidate recognition templates, z1j and z2j are matched, and the intersection-union ratio Bj of the localization boxes corresponding to z1j and z2j is calculated.
[0079] The average intersection-union ratio (Bp) of the current position is calculated using the formula Bp=(B1+B2+、…、+Br) / r.
[0080] The relative positions of the target image to be identified and the candidate recognition template are adjusted to obtain the corresponding average intersection-union ratio Bp. The positional relationship corresponding to the largest average intersection-union ratio Bp is selected as the final relative position of the target image to be identified and the candidate recognition template, thereby completing the correction and positioning of the candidate recognition template and the target image to be identified.
[0081] During the acquisition of the target image to be identified, factors such as bending and deformation of the voucher itself may prevent the target image from forming a good positional correspondence with the candidate recognition template, thus affecting the accuracy of subsequent probability value calculation. In this step, the present invention uses the field as the positioning point and calculates the positional correspondence scheme that is most conducive to the overall matching effect between the target image to be identified and the candidate recognition template through the import of the intersection-union ratio. This can minimize the impact of low quality of the target image to be identified and improve the accuracy and reliability of the calculation results.
[0082] When selecting the alternative identification templates, the positioning fields should be distributed as evenly as possible on the corresponding voucher, so as to facilitate the position and angle correction.
[0083] The method for obtaining the location field of the candidate identification template is as follows:
[0084] Obtain the recognition fields from each candidate recognition template, merge them, and then obtain the recognition fields that exist in all i candidate recognition templates, and mark them as candidate fields.
[0085] For a candidate recognition template, the candidate recognition template is divided into four polygons by connecting the geometric center of the candidate recognition template with the four corners;
[0086] Choose 1 to 2 candidate fields from each of the four polygons. When two polygons share a side, mark the two polygons as adjacent polygons.
[0087] Obtain the connection length L between the centers of each candidate field. The connection rule between the centers of each candidate field is that the center of a candidate field within a polygon is only connected to the centers of other candidate fields within the same polygon and the closest candidate field center within the adjacent polygon. The center of a candidate field is connected only twice.
[0088] The obtained line lengths L are sequentially labeled as L1, L2, ..., Lx, according to the formula...
[0089] The dispersion value U of this set of data was calculated;
[0090] Where 1≤h≤x, Lp=(L1+L2+,…+Lx) / x;
[0091] Select the candidate field distribution pattern with the largest Lp from several groups with the smallest dispersion value U, and use the corresponding candidate field as the positioning field;
[0092] This method can make the selected positioning fields evenly distributed, and the positioning fields are as close to the edge as possible, which is beneficial for the position matching and correction of the candidate recognition template and the target image to be recognized.
[0093] In the description of this specification, the references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0094] The above description is merely an example and illustration of the present invention. Those skilled in the art can make various modifications or additions to the specific embodiments described, or use similar methods to replace them, as long as they do not deviate from the invention or exceed the scope defined in the claims, all of which should fall within the protection scope of the present invention.
Claims
1. A classification method for pre-recognition text, characterized in that, Includes the following steps: S1. Obtain the image to be recognized; S2. Mark an image to be recognized as the target image to be recognized, read the text in the target image to be recognized, and obtain the corresponding converted text; S3. For the converted text of the target image to be recognized, analyze the converted text using a text classification model to obtain the test probability values of the target image belonging to each recognition template. Select i recognition templates as candidate recognition templates; S4. Match the converted text with i candidate recognition templates. Specifically, for a candidate recognition template, correct and locate the candidate recognition template with the image to be recognized. Retrieve the recognition fields from the image to be recognized; According to the formula The probability value of the target image to be identified matching a candidate recognition template is calculated. ; Where n is the number of recognition fields in the corresponding candidate recognition template. Let be the intersection-union ratio (IoU) of the k-th recognition field in the candidate recognition template and the target image to be recognized. If no matching k-th recognition field is found in the target image to be recognized, then... The value is 0; Where 1≤k≤n; S5. According to the formula The final probability value of the target image corresponding to each candidate recognition template is calculated. Select The largest candidate recognition template is used as the recognition template for the target image to be recognized. The category to which the recognition template belongs is marked as the category of the target image to be recognized and then classified. Where α and β are both preset coefficients, and satisfy α+β=1; The value of α is 0.4, and the value of β is 0.6; The method for correcting and locating the candidate recognition template and the target image to be recognized is as follows: Obtain the location field of the candidate recognition template, and mark the location field sequentially as z11, z12, ..., z1r; Obtain the corresponding location field in the target image to be identified, and label the location field sequentially as z21, z22, ..., z2r; Each positioning field is defined by a rectangular positioning box, and only one positioning field is set within each positioning box. After initially matching the target image to be identified with the candidate recognition templates, z1j and z2j are matched, and the intersection-union ratio Bj of the localization boxes corresponding to z1j and z2j is calculated. The average intersection-union ratio (Bp) of the current position is calculated using the formula Bp=(B1+B2+、…、+Br) / r. The relative positions of the target image to be identified and the candidate recognition templates are adjusted to obtain the corresponding average intersection-union ratio (IU / Bp). The positional relationship corresponding to the largest average IU / Bp is selected as the final relative position of the target image to be identified and the candidate recognition templates.
2. The classification method for pre-recognition text recognition according to claim 1, characterized in that, The method for obtaining the image to be recognized is as follows: Acquire an image containing one or more images to be identified; After obtaining the edge region of the image to be recognized, it is cropped to obtain one or more corresponding images to be recognized.
3. The classification method for pre-recognition text recognition according to claim 1, characterized in that, The text classification models include TF-IDF, TextCNN, and BERT.
4. The classification method for pre-recognition text recognition according to claim 3, characterized in that, When selecting a recognition template as a candidate recognition template, choose the test probability value. i recognition templates that are greater than the preset value ty are used as candidate recognition templates or Select test probability value The largest i-th recognition template is used as the alternative recognition template or Select test probability value The i largest recognition templates that are greater than the preset value ty are selected as candidate recognition templates; i is the default value.
5. The classification method for pre-recognition text recognition according to claim 3, characterized in that, The value of i is 5.
6. The classification method for pre-recognition text recognition according to claim 1, characterized in that, The method for obtaining the location field of the candidate identification template is as follows: Obtain the recognition fields from each candidate recognition template, merge them, and then obtain the recognition fields that exist in all i candidate recognition templates, and mark them as candidate fields. For a candidate recognition template, the candidate recognition template is divided into four polygons by connecting the geometric center of the candidate recognition template with the four corners; Choose 1 to 2 candidate fields from each of the four polygons. When two polygons share a side, mark the two polygons as adjacent polygons. Obtain the connection length L between the centers of each candidate field. The connection rule between the centers of each candidate field is that the center of a candidate field within a polygon is only connected to the centers of other candidate fields within the same polygon and the nearest candidate field center within the adjacent polygon. The center of a candidate field is connected only twice. The obtained line lengths L are sequentially labeled as L1, L2, ..., Lx, according to the formula... The dispersion value U of this set of data was calculated; Where 1≤h≤x, Lp=(L1+L2+,…+Lx) / x; Select the candidate field distribution pattern with the largest Lp from several groups with the smallest dispersion value U, and use the corresponding candidate field as the positioning field.