Text recognition model determination method and apparatus, storage medium, and computer device
By acquiring sample images and candidate text recognition models on industrial-grade PDAs and scoring their confidence, the system automatically selects the target text recognition model, solving the problem of the lack of large-scale application of OCR recognition. This achieves more efficient and accurate text recognition and improves the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-26
- Publication Date
- 2026-04-07
AI Technical Summary
In the current technology, OCR recognition has not yet been widely applied on industrial-grade PDAs. The PDAs cannot learn the text content to be recognized on their own, which means that users need to manually select the text recognition model for the relevant scenario when using industrial-grade PDAs for text recognition, resulting in a poor user experience.
By acquiring multiple sample images of the scene to be identified and multiple pre-configured candidate text recognition models, the text block to be identified in the sample image is input into the model for each candidate text recognition model, and a confidence score is performed. The candidate text recognition model with the highest final confidence score is selected as the target model for recognition.
It improves the autonomous learning capability of industrial-grade PDAs, reduces model computation, shortens the configuration time of text recognition models, improves recognition efficiency and accuracy, and enhances user experience.
Smart Images

Figure CN115497096B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text recognition technology, and in particular to a method, apparatus, storage medium and computer equipment for determining a text recognition model. Background Technology
[0002] OCR (Optical Character Recognition) is a technology that can recognize text within an image. Currently, OCR is widely used in logistics, healthcare, finance, insurance, and other fields, and can also be integrated into PDAs to enable applications in even more areas.
[0003] Currently, PDAs include consumer PDAs and industrial-grade PDAs. Consumer PDAs include smartphones, tablets, and handheld game consoles; industrial-grade PDAs are mainly used in factory manufacturing, logistics warehousing, and outdoor material inspection, and commonly include barcode scanners (also known as barcode readers), RFID readers, and POS machines. These can all be called PDAs. Industrial-grade PDAs can be used in many harsh environments and have been optimized for industrial use. They support RFID reading and writing and barcode scanning functions and have an IP54 or higher industrial rating, features not found in consumer handheld terminals.
[0004] However, since OCR recognition has not yet been widely applied on industrial-grade PDAs, and they cannot learn the text content to be recognized on their own, users need to manually select the text recognition model for the relevant scenario when using industrial-grade PDAs for text recognition, resulting in a poor user experience. Summary of the Invention
[0005] The purpose of this application is to at least address one of the aforementioned technical deficiencies, particularly the technical deficiency that existing technologies have not yet achieved large-scale application of OCR recognition on industrial-grade PDAs and cannot autonomously learn the text content to be recognized.
[0006] This application provides a method for determining a text recognition model, the method comprising:
[0007] Acquire multiple sample images of the scene to be identified, as well as multiple pre-configured candidate text recognition models, where each candidate text recognition model corresponds to a different recognition scene;
[0008] For each candidate text recognition model, the text blocks to be recognized in each sample image are input into the candidate text recognition model to obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model.
[0009] Each candidate text recognition model outputs a confidence score for each recognition result, and the final confidence score of each candidate text recognition model is calculated based on the scoring results. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model, and the target text recognition model is used to recognize the image to be recognized in the scene to be recognized.
[0010] Optionally, before inputting the text blocks to be recognized from each sample image into the candidate text recognition model, the method further includes:
[0011] For each sample image:
[0012] Identify the text boxes to be recognized that are located in the same row in the sample image;
[0013] The text boxes to be recognized in the same row in the sample image are merged, and the merged text boxes to be recognized are cropped out from the sample image to obtain the text blocks to be recognized in each sample image.
[0014] Optionally, determining the text boxes to be recognized in the same row in the sample image includes:
[0015] Identify the text box closest to the center point of the sample image, and using the text box as a reference, identify other text boxes in the sample image that are in the same direction as the text box.
[0016] Based on the height difference between the other text boxes and the text box, determine the other text boxes located in the same row as the text box;
[0017] The text box and other text boxes located in the same row as the text box are considered as text boxes to be identified in the same row of the sample image.
[0018] Optionally, determining other text boxes in the sample image that are in the same direction as the text box includes:
[0019] Find text boxes in the sample image whose aspect ratio is within a preset aspect ratio range, wherein the preset aspect ratio range is related to the aspect ratio of the text boxes;
[0020] Text boxes with aspect ratios within a preset range are designated as other text boxes in the same direction as the text box.
[0021] Optionally, determining other text boxes located on the same line as the text box based on the height difference between the text box and other text boxes includes:
[0022] Determine the height difference between the other text boxes and the text box based on the height of the other text boxes and the text box described above;
[0023] The height difference is compared with a preset height difference range. If the height difference does not exceed the preset height difference range, the other text boxes are identified as other text boxes located in the same row as the text box.
[0024] Optionally, the step of assigning confidence scores to each recognition result output by each candidate text recognition model to obtain a score corresponding to each recognition result includes:
[0025] The recognition result of the text block to be recognized in each sample image output by each candidate text recognition model:
[0026] Traverse the characters at each time step in the time sequence corresponding to the recognition result, retain the character with the highest probability value among the same characters at consecutive time steps, and remove placeholders from the retained characters;
[0027] The probability values of each removed character are multiplied, and the product is used as the score corresponding to the recognition result.
[0028] Optionally, the step of calculating the final confidence score of each candidate text recognition model based on the scoring results includes:
[0029] The average score of each candidate text recognition model is calculated by averaging the scores of each candidate text recognition model.
[0030] The average score of each candidate text recognition model is used as the final confidence score of each candidate text recognition model.
[0031] This application also provides a device for determining a text recognition model, comprising:
[0032] The data acquisition module is used to acquire multiple sample images of the scene to be identified, as well as multiple pre-configured candidate text recognition models, where each candidate text recognition model corresponds to a different recognition scene.
[0033] The text recognition module is used to input the text blocks to be recognized in each sample image into the candidate text recognition model for each candidate text recognition model, and obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model.
[0034] The model determination module is used to score the confidence of each recognition result output by each candidate text recognition model, and to calculate the final confidence score of each candidate text recognition model based on the scoring results. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model, and the target text recognition model is used to recognize the image to be recognized in the recognition scene.
[0035] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the text recognition model determination method as described in any of the above embodiments.
[0036] This application also provides a computer device, including: one or more processors, and memory;
[0037] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the text recognition model determination method as described in any of the above embodiments.
[0038] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0039] The text recognition model determination method, apparatus, storage medium, and computer equipment provided in this application, when performing text recognition using an industrial-grade PDA, can acquire multiple sample images of the scene to be recognized, as well as multiple pre-configured candidate text recognition models for different scenes. The text blocks to be recognized from the multiple sample images are then input into the candidate text recognition models for different scenes for text recognition. Compared to directly inputting sample images into the candidate text recognition models, this application uses smaller text blocks to be recognized as input to the candidate text recognition models, which can reduce the computational load of the model to a certain extent, improve the model's recognition efficiency, effectively shorten the configuration time of the text recognition model, save user waiting time, and improve user experience. Furthermore, this application can process each candidate text block... The recognition model assigns confidence scores to the recognition results of the text to be recognized in each sample image, and calculates the final confidence score of each candidate text recognition model based on the scoring results. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model. Since the target text recognition model has more accurate recognition results for the sample images in the recognition scenario, subsequent recognition of the images in the recognition scenario using this target text recognition model can obtain more accurate recognition results. Moreover, the above process does not require manual settings by the user. The industrial-grade PDA can automatically determine the final target text recognition model based on the acquired sample images and candidate text recognition models in different scenarios, thereby effectively improving the autonomous learning capability of the industrial-grade PDA. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 A flowchart illustrating a method for determining a text recognition model provided in an embodiment of this application;
[0042] Figure 2 This is a schematic diagram of a sample image of a bank card type provided in an embodiment of this application;
[0043] Figure 3 This is a schematic diagram of a sample image of a weight type provided in an embodiment of this application;
[0044] Figure 4 This is a schematic diagram of a sample image of a single-line text block type provided in an embodiment of this application;
[0045] Figure 5 A schematic diagram of a sample image of the number type provided in the embodiments of this application;
[0046] Figure 6 This is a diagram illustrating the process of scoring the confidence level of the recognition results, provided in an embodiment of this application.
[0047] Figure 7 A schematic diagram of a text recognition model determination device provided in an embodiment of this application;
[0048] Figure 8 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0049] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0050] Currently, OCR recognition has not yet been widely applied in industrial-grade PDAs, and these devices cannot autonomously learn the text content to be recognized. This forces users to manually select the appropriate text recognition model for their specific scenario when using industrial-grade PDAs for text recognition, resulting in a poor user experience. Therefore, this application proposes the following technical solution, as detailed below:
[0051] In one embodiment, such as Figure 1 As shown, Figure 1 This application provides a flowchart illustrating a method for determining a text recognition model, which may include:
[0052] S110: Acquire multiple sample images of the scene to be identified, as well as multiple pre-configured candidate text recognition models.
[0053] In this step, before recognizing the scene to be recognized, multiple sample images of the scene to be recognized and multiple pre-configured candidate text recognition models can be obtained, and the sample images can be recognized by the candidate text recognition models.
[0054] The scenarios to be identified in this application include, but are not limited to, scenarios for identifying bank card numbers, ID cards, weight information, stamps, and waybills. Each candidate text recognition model pre-configured in this application corresponds to a different recognition scenario, and each is a single-scenario recognition model.
[0055] Understandably, text recognition is required in a variety of everyday situations, such as bank card numbers, ID cards, weight information, and single strings. Existing industrial-grade PDAs cannot use the same recognition model to recognize text in different scenarios. Furthermore, even when using the same recognition model to recognize text in different scenarios, the accuracy is significantly lower compared to using a single-scenario recognition model to recognize text in the same scenario.
[0056] Therefore, this application can pre-configure multiple candidate text recognition models for a single scenario, and select the target text recognition model corresponding to the scenario to be recognized by using multiple sample images collected in the scenario to be recognized. This allows users to choose the target text recognition model independently, improving the user experience, and also to accurately recognize the text in the scenario through the target text recognition model in a single scenario, thereby improving the recognition accuracy.
[0057] It should be noted that, since the candidate text recognition models for a single scene pre-configured in this application are recognition models trained on their respective training samples, this application does not need to acquire a large number of sample images when obtaining sample images of the scene to be recognized. Only a small number of sample images need to be collected, such as 50 sample images, and input into the candidate text recognition models for recognition, ensuring that the number of recognition results is sufficient for scoring using a scoring mechanism. This allows for both autonomous selection of the target text recognition model and reduces the time spent on autonomous selection.
[0058] S120: For each candidate text recognition model, input the text blocks to be recognized in each sample image into the candidate text recognition model to obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model.
[0059] In this step, after obtaining multiple sample images of the scene to be recognized and multiple pre-configured candidate text recognition models through S110, this application can input the text blocks to be recognized in each sample image into the candidate text recognition model for each candidate text recognition model, and obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model.
[0060] It is understandable that the position and design style of the text block to be recognized may differ in different recognition scenarios. When the candidate text recognition model obtained in this application is pre-configured to recognize text in only a single scenario, its recognition accuracy is relatively high for the text block to be recognized corresponding to the scenario recognized by the candidate text recognition model, while its recognition accuracy is relatively low for the text block to be recognized that differs from the scenario recognized by the candidate text recognition model.
[0061] Indicatively, such as Figure 2 , 3 As shown in Figures 4 and 5, Figure 2 This is a schematic diagram of a sample image of a bank card type provided in an embodiment of this application; Figure 3 This is a schematic diagram of a sample image of a weight type provided in an embodiment of this application; Figure 4 This is a schematic diagram of a sample image of a single-line text block type provided in an embodiment of this application; Figure 5 This is a schematic diagram of a sample image of the number type provided in the embodiments of this application; by Figure 2 , 3 As shown in points 4 and 5, the backgrounds in the sample images under different recognition scenarios are significantly different, and the font styles and layouts of the text blocks to be recognized in the sample images also differ to some extent. Therefore, the recognition results obtained by using different candidate text recognition models to recognize sample images under the same recognition scenario will also differ. This application can determine the final target text recognition model based on these differences.
[0062] Furthermore, when using the candidate text recognition model to recognize sample images, this application can first obtain the text block to be recognized in the sample image, such as cropping the text block in a specified area of the sample image to obtain the text block to be recognized, and then input the text block to be recognized into the candidate text recognition model for recognition. This can not only filter out the influence of complex backgrounds in the sample image on the recognition results, but also reduce the computational load of the model to a certain extent, improve the recognition efficiency of the model, effectively shorten the configuration time of the text recognition model, save the user's waiting time, and improve the user experience.
[0063] S130: Calculate the confidence score of each recognition result output by each candidate text recognition model, and calculate the final confidence score of each candidate text recognition model based on the scoring results. Determine the candidate text recognition model with the highest final confidence score as the target text recognition model, and use the target text recognition model to recognize the image to be recognized in the recognition scene.
[0064] In this step, after obtaining the recognition results of the text blocks to be recognized in each sample image output by each candidate text recognition model through S120, the confidence scores of each recognition result output by each candidate text recognition model can be calculated, and the target text recognition model can be selected based on the scoring results. The target text recognition model is then used to recognize the image to be recognized in the recognition scenario.
[0065] Specifically, when assigning confidence scores to the recognition results output by each candidate text recognition model, this application can employ different scoring mechanisms. For example, this application can use a greedy algorithm or a clustering algorithm to score the recognition results. The greedy algorithm primarily takes the maximum probability value of each character in each time sequence of the recognition result and averages the maximum probability values corresponding to non-placeholder characters. The clustering algorithm, on the other hand, is an algorithm that iteratively recursively moves along the time sequence. Once a scoring mechanism is selected, it can be used to assign confidence scores to the recognition results output by each candidate text recognition model, and the target text recognition model can be selected based on the scoring results.
[0066] For example, this application can calculate the final confidence score of each candidate text recognition model based on the confidence score corresponding to each recognition result output by each candidate text recognition model. When calculating the final confidence score, it can be determined based on the average confidence score of each recognition result, or based on the interval with more confidence scores in each recognition result, or based on the highest confidence score in each recognition result. The specific choice can be made according to the actual situation, and no restrictions are imposed here.
[0067] In the above embodiments, when using an industrial-grade PDA for text recognition, multiple sample images of the scene to be recognized and multiple pre-configured candidate text recognition models for different scenes can be acquired. The text blocks to be recognized from the multiple sample images are then input into the candidate text recognition models for different scenes for text recognition. Compared to directly inputting sample images into the candidate text recognition models, this application uses smaller text blocks to be recognized as input to the candidate text recognition models, which can reduce the computational load of the models to a certain extent, improve the recognition efficiency of the models, effectively shorten the configuration time of the text recognition models, save user waiting time, and improve user experience. Then, this application can process each sample image output by each candidate text recognition model... The recognition results of the text to be recognized in the image are scored with confidence. Based on the scoring results, the final confidence score of each candidate text recognition model is calculated. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model. Since the target text recognition model has more accurate recognition results for sample images in the recognition scenario, subsequent recognition of the image to be recognized in the recognition scenario using the target text recognition model can obtain more accurate recognition results. Moreover, the above process does not require manual setting by the user. The industrial-grade PDA can automatically determine the final target text recognition model based on the acquired sample images and candidate text recognition models in different scenarios, thereby effectively improving the autonomous learning capability of the industrial-grade PDA.
[0068] In one embodiment, before inputting the text blocks to be recognized from each sample image into the candidate text recognition model in step S120, the process may further include:
[0069] S121: For each sample image: Identify the text boxes to be recognized in the same row of the sample image.
[0070] S122: Merge the text boxes to be recognized in the same row in the sample image, and crop out the merged text boxes to be recognized from the sample image to obtain the text blocks to be recognized in each sample image.
[0071] In this embodiment, before recognizing the text block to be recognized in the sample image, the text boxes to be recognized in the same row in the sample image can be identified first, and the text boxes to be recognized in the same row can be merged. Then, the merged text boxes to be recognized are cut out from the sample image, so that the text block to be recognized in the sample image can be obtained.
[0072] It is understood that, in this application, the text box to be recognized refers to the text region enclosed in the sample image, while the text block to be recognized refers to the text within the text region. Therefore, when this application merges and crops the text boxes to be recognized located in the same row, it can obtain the text block to be recognized corresponding to the merged text box.
[0073] In one embodiment, determining the text boxes to be recognized in the same row in the sample image in S121 may include:
[0074] S1211: Determine the text box closest to the center point of the sample image, and using the text box as a reference, determine other text boxes in the sample image that are in the same direction as the text box.
[0075] S1212: Determine other text boxes located in the same row as the text box based on the height difference between the other text boxes and the text box.
[0076] S1213: The text box and other text boxes located in the same row as the text box are regarded as text boxes to be identified in the same row in the sample image.
[0077] In this embodiment, when determining the text boxes to be recognized in the same row in the sample image, the text box closest to the center point of the sample image can be determined first. Then, based on the text box, other text boxes in the sample image that are in the same direction as the text box can be determined. Then, based on the height difference between the other text boxes and the text box, other text boxes that are in the same row as the text box can be determined. Finally, the text box and the other text boxes that are in the same row as the text box are taken as the text boxes to be recognized in the same row in the sample image.
[0078] It is understood that this application provides an OCR recognition component that uses a crosshair as a reference point and captures several text blocks appearing in the field of view (FOV) of a sample image. Therefore, this application can select the text box closest to the center point of the sample image and the text box located on the same line as that text box as the text box to be recognized.
[0079] In one embodiment, determining other text boxes in the sample image that are in the same direction as the text box in S1211 may include:
[0080] S210: Find text boxes in the sample image whose aspect ratio is within a preset aspect ratio range, wherein the preset aspect ratio range is related to the aspect ratio of the text boxes.
[0081] S211: Use text boxes with aspect ratios within a preset range as other text boxes in the same direction as the text box.
[0082] In this embodiment, after determining the text box closest to the center point of the sample image, a preset aspect ratio range can be determined based on the aspect ratio of the text box, and text boxes with aspect ratios within the preset aspect ratio range can be found in the sample image. These text boxes are then used as other text boxes in the same direction as the original text box.
[0083] Specifically, after obtaining the text box closest to the center point of the sample image, this application can use this text box as a reference to find text boxes in the sample image with a preset aspect ratio between 0.6 and 1.67 that are in the same direction.
[0084] In one embodiment, determining other text boxes located on the same row as the text box in step S1212 based on the height difference between the other text boxes and the text box includes:
[0085] S220: Determine the height difference between the other text boxes and the text box based on the height of the other text boxes and the text box.
[0086] S221: Compare the height difference with a preset height difference range. If the height difference does not exceed the preset height difference range, then identify other text boxes as other text boxes located in the same row as the text box.
[0087] In this embodiment, after obtaining the text box closest to the center point of the sample image and other text boxes in the same direction as the text box, the height difference between the other text boxes and the text box can be determined based on the height of the other text boxes and the text box. Text boxes with height differences exceeding a preset height difference range are removed, and the remaining text boxes with height differences not exceeding the preset height difference range are regarded as other text boxes in the same row as the text box.
[0088] For example, if there is only one or more other text boxes in the sample image, but they are all in the same line and the height difference is less than 0.2, then it is considered to be a single-line text block type. If there are multiple text boxes and the height difference is greater than 0.2, then the text boxes with a height difference greater than 0.2 are filtered out, and only the text boxes in the same line with a height difference of less than 0.2 are kept.
[0089] In one embodiment, in S130, a confidence score is assigned to each recognition result output by each candidate text recognition model to obtain a score result corresponding to each recognition result, which may include:
[0090] S131: For the recognition result of the text block to be recognized in each sample image output by each candidate text recognition model: traverse the characters at each time step in the time sequence corresponding to the recognition result, retain the character with the highest probability value among the same characters at consecutive time steps, and remove the placeholders in the retained characters.
[0091] S132: Multiply the probability values of each removed character and use the product as the scoring result corresponding to the recognition result.
[0092] In this embodiment, when scoring the confidence of each recognition result output by each candidate text recognition model, one recognition result can be selected, and the characters at each time step in the time sequence corresponding to the recognition result can be traversed. The character with the highest probability value among the same characters at consecutive time steps is retained, and the placeholders in the retained characters are extracted. Then, the probability values of each character after removing the placeholders are multiplied, and the product result is used as the scoring result corresponding to the recognition result.
[0093] Indicatively, such as Figure 6 As shown, Figure 6 This is a diagram illustrating the process of scoring the confidence level of the recognition results, provided in an embodiment of this application. Figure 6 The specific process of assigning confidence scores to the recognition results, as shown in the image, is as follows:
[0094] The first step is to set the initial probability value to 1;
[0095] The second step is to iterate through the temporal sequence of the recognition results to determine whether the largest one is a placeholder.
[0096] The third step, if it is not a placeholder, is to determine whether it is the same as the maximum value at the previous time step;
[0097] The fourth step is to multiply the maximum probability value by the initial probability to obtain a new probability value, and then update the initial probability value based on the new probability value.
[0098] Fifth step: If the character is the same as the character corresponding to the maximum probability value at the previous moment, then take the larger probability value until the maximum probability value at the current moment is not the same character. Multiply the maximum probability value by the initial probability value to get the new probability value, and update the initial probability value according to the new probability value.
[0099] Step 6: Calculate the root of the number of probabilities included in the calculation, for example, Figure 6 The calculated score is 0.9*0.98*0.9*0.8*0.9=0.89.
[0100] The scoring method described above has the same computational cost as the greedy algorithm, but it also takes into account the correlation between different time points, making it more robust to error-prone characters.
[0101] In one embodiment, S130 calculates the final confidence score for each candidate text recognition model based on the scoring results, including:
[0102] S310: Calculate the average score of each candidate text recognition model by averaging the scores of each candidate text recognition model.
[0103] S311: The average score of each candidate text recognition model is used as the final confidence score of each candidate text recognition model.
[0104] In this embodiment, after obtaining the scores corresponding to each recognition result in each candidate text recognition model, the average score of each score result can be calculated. After obtaining the average score of each candidate text recognition model, the average score of each candidate text recognition model can be used as the final confidence score of each candidate text recognition model. In this way, the final confidence score of each candidate text recognition model can be obtained.
[0105] The following describes the apparatus for determining a text recognition model provided in the embodiments of this application. The apparatus for determining a text recognition model described below can be referred to in correspondence with the method for determining a text recognition model described above.
[0106] In one embodiment, such as Figure 7 As shown, Figure 7 This application provides a schematic diagram of a text recognition model determination device according to an embodiment of the present application. The present application also provides a text recognition model determination device, which may include a data acquisition module 210, a text recognition module 220, and a model determination module 230, specifically including the following:
[0107] The data acquisition module 210 is used to acquire multiple sample images of the scene to be identified, as well as multiple pre-configured candidate text recognition models, wherein each candidate text recognition model corresponds to a different recognition scene;
[0108] The text recognition module 220 is used to input the text blocks to be recognized in each sample image into the candidate text recognition model for each candidate text recognition model, so as to obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model.
[0109] The model determination module 230 is used to score the confidence of each recognition result output by each candidate text recognition model, and to calculate the final confidence score of each candidate text recognition model based on the scoring results. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model, and the target text recognition model is used to recognize the image to be recognized in the recognition scene.
[0110] In the above embodiments, when using an industrial-grade PDA for text recognition, multiple sample images of the scene to be recognized and multiple pre-configured candidate text recognition models for different scenes can be acquired. The text blocks to be recognized from the multiple sample images are then input into the candidate text recognition models for different scenes for text recognition. Compared to directly inputting sample images into the candidate text recognition models, this application uses smaller text blocks to be recognized as input to the candidate text recognition models, which can reduce the computational load of the models to a certain extent, improve the recognition efficiency of the models, effectively shorten the configuration time of the text recognition models, save user waiting time, and improve user experience. Then, this application can process each sample image output by each candidate text recognition model... The recognition results of the text to be recognized in the image are scored with confidence. Based on the scoring results, the final confidence score of each candidate text recognition model is calculated. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model. Since the target text recognition model has more accurate recognition results for sample images in the recognition scenario, subsequent recognition of the image to be recognized in the recognition scenario using the target text recognition model can obtain more accurate recognition results. Moreover, the above process does not require manual setting by the user. The industrial-grade PDA can automatically determine the final target text recognition model based on the acquired sample images and candidate text recognition models in different scenarios, thereby effectively improving the autonomous learning capability of the industrial-grade PDA.
[0111] In one embodiment, the apparatus may further include:
[0112] The text box determination module is used to determine, for each sample image, the text boxes to be identified that are located in the same row in the sample image.
[0113] The text box merging module is used to merge the text boxes to be recognized that are located in the same row in the sample image, and to crop out the merged text boxes to be recognized from the sample image to obtain the text blocks to be recognized in each sample image.
[0114] In one embodiment, the text box determination module may include:
[0115] The first determining module is used to determine the text box closest to the center point of the sample image, and using the text box as a reference, determine other text boxes in the sample image that are in the same direction as the text box.
[0116] The second determining module is used to determine other text boxes located in the same row as the text box based on the height difference between the other text boxes and the text box.
[0117] The final confirmation module is used to identify the text box and other text boxes located in the same row as the text box as text boxes to be identified in the same row of the sample image.
[0118] In one embodiment, the first determining module may include:
[0119] The text box search module is used to search for text boxes in the sample image whose aspect ratio is within a preset aspect ratio range, wherein the preset aspect ratio range is related to the aspect ratio of the text box.
[0120] The text box selection module is used to select text boxes with an aspect ratio within a preset range as other text boxes in the same direction as the text box.
[0121] In one embodiment, the second determining module may include:
[0122] The height difference determination module is used to determine the height difference between other text boxes and the text box based on the height of the other text boxes and the text box.
[0123] The height difference comparison module is used to compare the height difference with a preset height difference range. If the height difference does not exceed the preset height difference range, other text boxes are identified as other text boxes located on the same line as the text box.
[0124] In one embodiment, the model determination module 230 may include:
[0125] The probability value selection module is used to identify the text block to be identified in each sample image output by each candidate text recognition model: iterate through the characters at each time step in the time sequence corresponding to the recognition result, retain the character with the highest probability value among the same characters at consecutive time steps, and remove the placeholders in the retained characters.
[0126] The scoring module is used to multiply the probability values of each removed character and use the product result as the scoring result corresponding to the recognition result.
[0127] In one embodiment, the model determination module 230 may include:
[0128] The mean calculation module is used to calculate the average of the scores in each candidate text recognition model to obtain the mean score of each candidate text recognition model.
[0129] The scoring determination module is used to take the average score of each candidate text recognition model as the final confidence score of each candidate text recognition model.
[0130] In one embodiment, this application also provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the method for determining a text recognition model as described in any of the above embodiments.
[0131] In one embodiment, this application also provides a computer device, including: one or more processors, and memory.
[0132] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the text recognition model determination method as described in any of the above embodiments.
[0133] Indicatively, such as Figure 8 As shown, Figure 8 This is a schematic diagram of the internal structure of a computer device 300 provided in an embodiment of this application. The computer device 300 can be provided as a server. (Refer to...) Figure 8 The computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions, such as application programs, that can be executed by the processing component 302. The application programs stored in memory 301 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 302 is configured to execute instructions to perform the text recognition model determination method of any of the above embodiments.
[0134] The computer device 300 may also include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate on an operating system stored in memory 301, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or similar.
[0135] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0136] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0137] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0138] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for determining a text recognition model, characterized in that, The method includes: Acquire multiple sample images of the scene to be identified, as well as multiple pre-configured candidate text recognition models, where each candidate text recognition model corresponds to a different recognition scene; For each candidate text recognition model, the text blocks to be recognized in each sample image are input into the candidate text recognition model to obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model. The confidence score of each recognition result output by each candidate text recognition model is calculated, and the final confidence score of each candidate text recognition model is calculated based on the scoring results. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model, and the target text recognition model is used to recognize the image to be recognized in the recognition scene. The process of assigning confidence scores to each recognition result output by each candidate text recognition model and calculating the final confidence score of each candidate text recognition model based on the scoring results includes: The recognition result of the text block to be recognized in each sample image output by each candidate text recognition model: Traverse the characters at each time step in the time sequence corresponding to the recognition result, retain the character with the highest probability value among the same characters at consecutive time steps, and remove placeholders from the retained characters; The probability values of each removed character are multiplied, and the product is used as the score corresponding to the recognition result. The average score of each candidate text recognition model is calculated by averaging the scores of each candidate text recognition model. The average score of each candidate text recognition model is used as the final confidence score of each candidate text recognition model.
2. The method according to claim 1, characterized in that, Before inputting the text blocks to be recognized from each sample image into the candidate text recognition model, the method further includes: For each sample image: Identify the text boxes to be recognized that are located in the same row in the sample image; The text boxes to be recognized in the same row in the sample image are merged, and the merged text boxes to be recognized are cropped out from the sample image to obtain the text blocks to be recognized in each sample image.
3. The method according to claim 2, characterized in that, The step of determining the text boxes to be recognized in the same row in the sample image includes: Identify the text box closest to the center point of the sample image, and using the text box as a reference, identify other text boxes in the sample image that are in the same direction as the text box. Based on the height difference between the other text boxes and the text box, determine the other text boxes located in the same row as the text box; The text box and other text boxes located in the same row as the text box are considered as text boxes to be identified in the same row of the sample image.
4. The method according to claim 3, characterized in that, The step of determining other text boxes in the sample image that are in the same direction as the text box includes: Find text boxes in the sample image whose aspect ratio is within a preset aspect ratio range, wherein the preset aspect ratio range is related to the aspect ratio of the text boxes; Text boxes with aspect ratios within a preset range are designated as other text boxes in the same direction as the text box.
5. The method according to claim 3, characterized in that, The step of determining other text boxes located on the same line as the text box based on the height difference between the text box and other text boxes includes: Determine the height difference between the other text boxes and the text box based on the height of the other text boxes and the text box described above; The height difference is compared with a preset height difference range. If the height difference does not exceed the preset height difference range, the other text boxes are identified as other text boxes located on the same line as the text box.
6. A device for determining a text recognition model, characterized in that, include: The data acquisition module is used to acquire multiple sample images of the scene to be identified, as well as multiple pre-configured candidate text recognition models, where each candidate text recognition model corresponds to a different recognition scene. The text recognition module is used to input the text blocks to be recognized in each sample image into the candidate text recognition model for each candidate text recognition model, and obtain the recognition results of the text blocks to be recognized in each sample image output by the candidate text recognition model. The model determination module is used to score the confidence of each recognition result output by each candidate text recognition model, and to calculate the final confidence score of each candidate text recognition model based on the scoring results. The candidate text recognition model with the highest final confidence score is determined as the target text recognition model, and the target text recognition model is used to recognize the image to be recognized in the recognition scene. The model determination module assigns a confidence score to each recognition result output by each candidate text recognition model, and calculates the final confidence score for each candidate text recognition model based on the scoring results, including: The recognition result of the text block to be recognized in each sample image output by each candidate text recognition model: Traverse the characters at each time step in the time sequence corresponding to the recognition result, retain the character with the highest probability value among the same characters at consecutive time steps, and remove placeholders from the retained characters; The probability values of each removed character are multiplied, and the product is used as the score corresponding to the recognition result. The average score of each candidate text recognition model is calculated by averaging the scores of each candidate text recognition model. The average score of each candidate text recognition model is used as the final confidence score of each candidate text recognition model.
7. A storage medium, characterized in that: The storage medium stores computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the method for determining a text recognition model as described in any one of claims 1 to 5.
8. A computer device, characterized in that, include: One or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the method for determining a text recognition model as described in any one of claims 1 to 5.