A template registration method and device, an electronic device, and a storage medium
By generating and registering recognition templates that match the images to be recognized, the problem that existing image character recognition algorithms cannot adapt to changing scenarios is solved, thus improving the adaptability and accuracy of recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
- Filing Date
- 2022-09-23
- Publication Date
- 2026-07-14
AI Technical Summary
In existing technologies, image character recognition algorithms cannot adapt to changes in the position, quantity, and meaning of characters in the image to be recognized, leading to recognition failure.
By acquiring the location information and character category in the image to be recognized, a recognition template is generated and compared with historically registered templates. If the template does not exist, it is registered. The template is corrected to adapt to changing scenarios, and a clustering algorithm is used to optimize the matching process.
It improves the adaptability and accuracy of image character recognition, ensuring that characters can still be effectively recognized in changing scenarios.
Smart Images

Figure CN115497098B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image character recognition technology, and in particular to a template registration method, apparatus, electronic device and storage medium. Background Technology
[0002] Character recognition in images is used in many everyday scenarios, such as recognizing ticket information at train station entrances and exits, and recognizing waybill information in express delivery services. Current technologies typically involve obtaining a registered template that matches the image, and then extracting and recognizing the characters based on that template.
[0003] However, the position, number, and meaning of characters in the image to be recognized often change with different application scenarios, causing the registered templates to fail to meet the new scenarios, thus making it impossible for existing character recognition algorithms to recognize the characters in the image to be recognized.
[0004] Therefore, there is a need to provide a template registration method, apparatus, electronic device, and storage medium to solve the problem that existing templates cannot adapt to changing scenarios during the character recognition process in the above-mentioned prior art. Summary of the Invention
[0005] This application provides a template registration method, apparatus, electronic device, and storage medium, which can solve the problem in the prior art that existing templates cannot adapt to changing scenarios during the character recognition process.
[0006] To achieve the above technical objectives, this application adopts the following technical solution:
[0007] In a first aspect, embodiments of this application provide a template registration method, comprising: responding to a user's confirmation operation on location information on an image to be recognized, obtaining the position and information category of a string to be recognized in the image from the location information; generating a recognition template corresponding to the image to be recognized based on the position and information category of the string to be recognized, the recognition template including the position and information category of the string to be recognized; comparing the recognition template with historically registered templates, and registering the template based on the recognition template if no recognition template exists in the historically registered templates, the historically registered templates being the registered templates.
[0008] In the template registration method provided in this application embodiment, the user can confirm the position and information category of the string to be recognized in the image to be recognized, and generate a recognition template for the image to be recognized based on the position and information category of the character to be recognized. Through this process, a recognition template adapted to the image to be recognized can be obtained. Furthermore, when the aforementioned recognition template does not exist in the historical registered templates, a template adapted to the image to be recognized can be registered based on the recognition template. This solves the problem that when templates change, there are no existing templates matching the image to be recognized, thus failing to adapt to changing scenarios.
[0009] In one possible implementation, when the recognition template corresponding to the image to be recognized contains multiple strings to be recognized, the recognition template also includes the relative positional relationship between the multiple strings to be recognized.
[0010] In this possible approach, when there are multiple strings to be recognized in the recognition template corresponding to the image to be recognized, the relative positional relationship between the multiple strings to be recognized can be added to the template, and the strings to be recognized in the image to be recognized can be recognized based on this feature to improve the recognition accuracy.
[0011] In one possible implementation, the above-mentioned template registration based on the recognition template includes: erasing each string to be recognized from the image to be recognized; generating a sample string according to the information category and superimposing the sample string onto the position of the corresponding string to be recognized to obtain a sample image; using the sample image as training data and the sample string as a label to correct the recognition template to obtain the corrected recognition template, and registering the corrected recognition template.
[0012] In this possible approach, embodiments of this application propose a method for re-registering a modified recognition template. By modifying the recognition template using multiple sample images and sample strings, the applicability and accuracy of the recognition template can be improved. For example, the modified recognition template is still applicable to images where the position of the string to be recognized has slight deviations due to factors such as errors, thus improving the feasibility and adaptability of the solution.
[0013] In one possible implementation, the comparison between the identification template and the historical registration template includes: converting the identification template and each historical registration template into corresponding matrix information; using a clustering algorithm to determine the distance between the matrix information of the identification template and the matrix information of each historical registration template; when there is a distance less than a preset threshold among the obtained distances, it is determined that there is an identification template in the historical registration template; when all the obtained distances are greater than the preset threshold, it is determined that there is no identification template in the historical registration template.
[0014] In this possible approach, embodiments of this application propose a method for comparing identification templates and historical registration templates using a clustering algorithm, thereby improving the feasibility of the solution.
[0015] In one possible implementation, before responding to the user's confirmation operation on the image to be identified, the method further includes: receiving the image to be identified and obtaining feature information of the image to be identified; determining, based on the feature information, whether there is a template in the historical registration templates that matches the image to be identified; if there is, using the matching template as the identification template; if there is, displaying an interface including the image to be identified, which is used to request the user to confirm the location information.
[0016] In this possible approach, the embodiments of this application propose that before the user confirms the location information of the image to be identified, it is first determined whether there is already a template in the historical registration templates that matches the image to be identified. If a matching template already exists, there is no need to generate and register the identification template. If no matching template exists, the identification template is generated and registered, which improves the feasibility of the solution and makes the solution more complete.
[0017] In one possible implementation, the above method further includes: obtaining the position of the string to be identified in the image to be identified and / or the relative positional relationship between multiple strings to be identified based on the recognition template; extracting and identifying the corresponding string to be identified at the position of each string to be identified; and correcting the recognition result of the string to be identified based on the character category of each character in the string to be identified.
[0018] Among this possible approach, a method for character recognition based on recognition templates is proposed, improving the feasibility of the solution. Furthermore, correcting the recognition results of the string to be recognized by character category can further improve the recognition accuracy. For example, when there are similar characters such as O and 0, S and 5, or 0 and D among the characters to be recognized, the recognition results can be corrected according to the character category, thereby improving the recognition accuracy.
[0019] In one possible implementation, the method further includes: in response to the user's confirmation operation on the character category, determining the character category of each character in the string to be identified.
[0020] In this possible implementation, the embodiments of this application propose a method for determining the character category of each character in the string to be identified, which improves the feasibility of the solution.
[0021] Secondly, this application provides a template registration apparatus. The template registration apparatus includes modules for performing the method described in the first aspect or any possible design of the first aspect.
[0022] Thirdly, this application provides an electronic device including a memory and a processor. The memory and processor are coupled. The memory stores computer program code, including computer instructions. When the processor executes the computer instructions, it causes the electronic device to perform the template registration method as described in the first aspect and any possible design of the present invention.
[0023] Fourthly, this application provides a chip system applied to the template registration apparatus of the second aspect; the chip system includes one or more interface circuits and one or more processors. The interface circuits and processors are interconnected via lines; the interface circuits are used to receive signals from the memory of the template registration apparatus and send signals to the processors, the signals including computer instructions stored in the memory. When the processor executes the computer instructions, it causes the electronic device to perform the template registration method as described in the first aspect and any possible design of the first aspect.
[0024] Fifthly, this application provides a computer-readable storage medium storing computer instructions that, when executed on an electronic device, cause the electronic device to perform the template registration method as described in the first aspect and any possible design thereof.
[0025] Sixthly, this application provides a computer program product including computer instructions that, when executed on an electronic device, cause the electronic device to perform the template registration method as described in the first aspect and any possible design thereof.
[0026] For a detailed description of aspects two through six and their various implementations in this application, please refer to the detailed description of aspects one and its various implementations; and for a detailed analysis of the beneficial effects of aspects two through six and their various implementations in aspects one and its various implementations, please refer to the beneficial effect analysis of aspects one and its various implementations, which will not be repeated here.
[0027] These or other aspects of this application will become more readily apparent in the following description. Attached Figure Description
[0028] Figure 1 A schematic diagram illustrating an application scenario involving a template registration method provided in this application embodiment;
[0029] Figure 2 A flowchart illustrating a template registration method provided in this application embodiment;
[0030] Figure 3 This is a schematic diagram illustrating the scenario where the image to be identified is a train ticket, as provided in this embodiment of the application.
[0031] Figure 4 This is a schematic diagram of the structure of a template registration device provided in an embodiment of this application;
[0032] Figure 5 This is another possible structural schematic diagram of the template registration device provided in the embodiments of this application;
[0033] Figure 6 This is a schematic diagram of the chip structure provided in an embodiment of this application. Detailed Implementation
[0034] 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.
[0035] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0036] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0037] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or apparatus.
[0038] It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0039] Character recognition in images is used in many aspects of daily life. For example, recognizing text in images such as ID cards, tickets, and express delivery slips plays a vital role in ensuring the orderly functioning of daily life. However, current technologies may encounter problems such as the lack of a corresponding template for the image to be recognized, making existing algorithms unsuitable. Furthermore, low character recognition rates may result from factors like similar-looking characters.
[0040] To address the aforementioned issues, this application provides a template registration method. The method involves obtaining the location information of a string to be recognized in an image and the character category of each character in the string. The location information includes the position of the character to be recognized in the image and the information category it represents. Based on the location information and character category of the string to be recognized, a target template corresponding to the image is determined. The target template is compared with historically registered templates, and the target template is registered based on the comparison result. Through this process, this application can register a target template into the system even when no matching target template exists in the current system. This ensures that character recognition of the image is performed using a completely matching template, thus solving the problem of existing algorithms being unsuitable due to template additions or changes, and improving the character recognition rate.
[0041] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0042] Please refer to Figure 1 This illustration shows a schematic diagram of an application scenario involving a template registration method provided in an embodiment of this application. For example... Figure 1 As shown, this application scenario may include server 100 and terminal device 110.
[0043] The template registration method provided in this application embodiment can be applied to the server 100, the terminal device 110, or jointly executed by the server 100 and the terminal device 110. This application embodiment does not impose any special limitations on this.
[0044] For example, taking the template registration method described above as being implemented on a terminal device, a user can confirm the location information in the image to be recognized through the terminal device. For instance, the user can select the location of the string to be recognized on the terminal device's interface and input the information category represented by each string at the corresponding location. After receiving the user's operation, the terminal device can obtain the location and information category of the string to be recognized in the image from the location information. After obtaining the location and information category of the string to be recognized, the terminal device can generate a recognition template corresponding to the image to be recognized based on the location and information category of the string to be recognized. This recognition template contains the location and information category of the string to be recognized. Then, the terminal device can compare the recognition template with historically registered templates. If the recognition template does not exist in the historically registered templates, the terminal device can register the template based on the recognition template. The historically registered templates are the already registered templates.
[0045] For example, the terminal device 110 in the embodiments of this application can be a smartphone, tablet computer, or handheld multi-functional terminal, etc. The embodiments of this application do not impose special restrictions on this. Furthermore, by applying the template registration method provided in the embodiments of this application to a handheld device, when there is no template matching the image to be recognized in the historical registered templates, a recognition template for the image to be recognized is generated and registered, thereby enabling the handheld device to upgrade its image character recognition function.
[0046] It should be noted that the execution subject of the template registration method provided in this application embodiment can also be a template registration device. This device can be an electronic device; or, the device can be an application (APP) installed on the electronic device that provides template registration functionality; or, the device can be a central processing unit (CPU) in the electronic device; or, the device can be a control module in the electronic device used to execute the template registration method.
[0047] The following is combined with Figure 2 The flowchart shown illustrates in detail a template registration method provided in this application embodiment. Figure 2 As shown, the method may include S201-S203:
[0048] S201. In response to the user's confirmation operation on the image to be recognized, obtain the location and information category of the string to be recognized in the image from the location information.
[0049] In this example implementation, the image to be recognized is an image that requires character recognition. For example, the image to be recognized can be an image of an ID card, a train ticket, or an invoice. The string to be recognized is a string that needs to be recognized in a specific area of the image. For example, at the entrance and exit of a station, an automatic ticket gate recognizes character information such as train number, origin, and destination in the corresponding area of the ticket. The location information includes the position of the string to be recognized in the image and the information category. Taking the train ticket as an example, where the string to be recognized is the ticket purchaser's ID number, the position of the string to be recognized in the image is the position of the ID number on the ticket, and the information category indicates that the string to be recognized represents an ID number.
[0050] In this example embodiment, the location and information category of the string to be recognized in the image to be recognized can be obtained from the location information by receiving the user's confirmation operation on the image to be recognized. The confirmation operation can be an input operation, a click operation, a selection operation, or a block diagram operation, etc. For example, the above process can be implemented as follows: in response to the user's block diagram operation in the image to be recognized, the location of the string to be recognized is selected in the image to be recognized; in response to the user's input operation or the selection operation for multiple information categories, the information category represented by the string to be recognized at each location is determined.
[0051] Specifically, taking the image to be recognized as a train ticket as an example, such as Figure 3 As shown, the above process can be as follows: In response to the bounding box operation on region A, region A is selected in the ticket; in response to the user's input of the train number, the information category of the string to be identified in region A is determined to be the train number; the operation for other regions is the same as that for region A, and will not be repeated here. It should be noted that this scenario is only an exemplary illustration, and the scope of protection of this example implementation is not limited thereto.
[0052] S202. Generate a recognition template corresponding to the image to be recognized based on the position and information category of the string to be recognized. The recognition template includes the position and information category of the string to be recognized.
[0053] In this example embodiment, the recognition template is an image containing the aforementioned location information, used as a template for character recognition of the string to be recognized in the image to be recognized. In this step, a recognition template corresponding to the image to be recognized is generated based on the position and information category of the string to be recognized in the aforementioned location information. The image to be recognized is used as... Figure 3Taking the ticket shown as an example, the recognition template image identifies the locations of regions A to D, and the template contains information categories corresponding to these regions. For example, region A corresponds to the departure station, region B corresponds to the train number, region C corresponds to the destination station, and region D corresponds to the ID number. It should be noted that this scenario is only an illustrative example, and the scope of protection of this example implementation is not limited thereto.
[0054] S203. Compare the identification template with the historical registration templates. If the identification template is not found in the historical registration templates, register the template based on the identification template. The aforementioned historical registration templates are the registered templates.
[0055] In this example implementation, after generating the identification template, it can be determined whether the identification template has been registered by comparing it with historical registration templates. When the comparison result shows that an identification template exists in the historical registration templates, the template that matches the identification template in the historical registration templates is used as the identification template; when the comparison result shows that no identification template exists in the historical registration templates, the template is registered based on the identification template.
[0056] Optionally, the aforementioned identification template or historical registration template includes the position and information category of the strings in the template. Furthermore, in the case of multiple strings, the aforementioned identification template or historical registration template also includes the relative positional relationships between the multiple strings to be identified.
[0057] For example, the above comparison and identification template with historical registration templates can be implemented based on a clustering algorithm as follows: The image information of the identification template and each historical registration template is converted into corresponding matrix information. The image information of each historical registration template may include the position and information category of the string in the template. Furthermore, it may include the relative positional relationship between multiple strings to be identified. The distance between the matrix information of the identification template and each historical registration template is determined using a clustering algorithm. When there is a historical registration template whose matrix information distance to the identification template is less than a preset threshold, it is considered that the template matches the identification template, and this template is used as the identification template. If there are multiple historical registration templates whose matrix information distance to the identification template is less than the preset threshold, the historical registration template with the smallest distance is selected as the identification template. When the distance between the matrix information of all historical registration templates and the identification template is greater than the preset threshold, it proves that there is no identification template among the historical registration templates. In this case, template registration is performed based on the identification template. The clustering algorithm can be any algorithm that can achieve the above-mentioned technical effects, such as K-means clustering. The preset threshold can be limited according to the actual situation. For example, when the accuracy requirement of the recognition template is high, the preset threshold is also set to a smaller value. This example implementation does not make any special limitation on this.
[0058] In this example implementation, when there is no recognition template in the historical registration templates, the above-mentioned template registration based on the recognition template can either directly register the recognition template or modify the recognition template before registration. For example, the modification process can be implemented as follows: erasing each string to be recognized from the image to be recognized; generating sample strings according to the information category and superimposing the sample strings onto the positions of the corresponding strings to be recognized to obtain a sample image; using the sample image as training data and the sample strings as labels to modify the recognition template.
[0059] For example, taking a train ticket as an example, the above correction process can be implemented as follows: Erasing the identified origin station, destination station, and train number characters to obtain a background image without the string to be identified; generating corresponding strings based on the information categories represented by each region, such as generating new origin station, destination station, and other string information, as sample strings; and superimposing the generated new strings onto the corresponding regions in the background image to generate multiple sample images as training data; using the sample strings in the sample images as labels to correct the recognition template. It should be noted that the above scenario is merely an illustrative example, and the scope of protection of this example implementation is not limited thereto.
[0060] The character categories mentioned above are used to indicate the type of characters. For example, in the scenario of recognizing an ID card, taking the ID card number as an example, the character category of each character in this string is a number. It should be noted that the above scenario is only an illustrative example, and the scope of protection of this example implementation is not limited thereto.
[0061] In another embodiment, before the user confirms the location information of the image to be identified, the method may also perform the following steps: receiving the image to be identified and acquiring its feature information, which may include color features, texture features, shape features, and spatial relationship features; determining whether a template matching the image to be identified exists in the historical registration templates based on the feature information; if it exists, using the matching template as the identification template; if it does not exist, displaying an interface including the image to be identified, which requests the user to confirm the location information. This display interface includes an indicator for receiving a selection by the user, and after the user selects a region, a drop-down menu can be displayed on the interface for the user to select category information.
[0062] In another embodiment, the above method can also implement the following process: obtain the position of the string to be recognized in the image to be recognized according to the recognition template, extract and recognize the corresponding string to be recognized at the position of the string to be recognized; correct the recognition result of the string to be recognized according to the character category of each character in the string to be recognized.
[0063] The image to be recognized is a train ticket, and the recognition template for this ticket is... Figure 3 Taking the template shown as an example, the positions of regions A, B, C and D in the image to be recognized can be obtained according to the recognition template, and the string to be recognized can be extracted and recognized from regions A to D. The above character recognition can be achieved by any technology that can realize character recognition, such as OCR (Optical Character Recognition). This example implementation does not make any special limitation on this.
[0064] Optionally, the above method can also implement the following process: obtain the positional relationship between multiple strings to be recognized in the image to be recognized based on the recognition template, extract and recognize each string to be recognized; correct the recognition result of the string to be recognized based on the character category of each character in the string to be recognized.
[0065] Similarly Figure 3 For example, the positional relationship between the multiple strings to be identified can be the positional relationship between region A and region B. This relative positional relationship can be, for example, region A being to the lower left of region B or the relative distance between region A and region B.
[0066] Of course, the above method can also achieve the following process: obtain the positional relationship between multiple strings to be recognized in the image to be recognized and the position of the string to be recognized in the image to be recognized based on the recognition template; extract and recognize the corresponding string to be recognized at the position of the string to be recognized; correct the recognition result of the string to be recognized based on the character category of each character in the string to be recognized.
[0067] Thus, when there are multiple strings to be recognized in the recognition template corresponding to the image to be recognized, the feature of relative positional relationship between multiple strings to be recognized can be added to the template, and the strings to be recognized in the image to be recognized can be recognized based on this feature to improve recognition accuracy.
[0068] Furthermore, exemplarily, the above-mentioned correction of the recognition result of the string to be recognized based on the character category of each character in the string to be recognized can be achieved as follows: Assuming the train number is extracted and recognized from region B, and the recognition result is 05130, the character categories of each character in the string to be recognized are obtained from the recognition template as letters, numbers, numbers, numbers, and numbers in sequence. Based on the character category, the first character can be corrected to D, thereby improving the accuracy of the recognition rate. It should be noted that this scenario is only an exemplary illustration, and the scope of protection of this example implementation is not limited thereto.
[0069] In another embodiment, the character category of each character in the string to be recognized can be obtained by the user's confirmation operation on the image to be recognized. Exemplarily, this process can be: receiving the user's operation on the input character category of each character, and determining the character category of each character; or, it can be determined by receiving the user's selection operation on the character category of each character. This example implementation does not impose any special limitations on this.
[0070] The foregoing primarily describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the aforementioned functions, it includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0071] Corresponding to the above-described template registration method, this application also provides a template registration device. For example... Figure 4 The diagram shown is a structural schematic of a template registration device 400 provided in an embodiment of this application. The device may include: a response module 401, a template generation module 402, and a template registration module 403. Wherein:
[0072] The response module 401 can be used to respond to the user's confirmation operation on the image to be recognized, and to obtain the position and information category of the string to be recognized in the image from the position information.
[0073] The template generation module 402 can be used to generate a recognition template corresponding to the image to be recognized based on the position and information category of the string to be recognized. The recognition template includes the position and information category of the string to be recognized.
[0074] The template registration module 403 can be used to compare the identified template with historical registered templates. If the identified template is not found in the historical registered templates, the template is registered based on the identified template. The historical registered templates are the already registered templates.
[0075] In this example implementation, when the recognition template corresponding to the image to be recognized contains multiple strings to be recognized, the recognition template also includes the relative positional relationship between the multiple strings to be recognized.
[0076] In this example embodiment, the response module includes a receiving unit and a determining unit. The receiving unit is used to receive a user's confirmation operation on the image to be recognized regarding location information. This confirmation operation can be an input operation, a click operation, a selection operation, or a bounding box operation, etc. For example, the receiving unit can perform the following operations: in response to the user's bounding box operation on the image to be recognized, it selects the location of the string to be recognized in the image; in response to the user's input operation or selection operation for multiple information categories, it determines the information category represented by the string to be recognized at each location.
[0077] Furthermore, the aforementioned response module is also used to: determine the character category of each character in the string to be recognized in response to the user's confirmation operation on the character category. For example, the response module may perform the following operations: receive the user's operation on the character category of each input character and determine the character category of each character; or, determine the character category of the corresponding character by receiving the user's selection operation on the character category of each character.
[0078] In this example embodiment, the template registration module further includes a training unit, which is used to: erase each string to be recognized in the image to be recognized; generate a sample string according to the information category, and superimpose the sample string onto the position of the corresponding string to be recognized to obtain a sample image; use the sample image as training data, use the sample string as a label to correct the recognition template, obtain the corrected recognition template, and register the corrected recognition template.
[0079] In this example embodiment, the template registration device further includes a template matching module. This module is used to: receive the image to be recognized and obtain its feature information before the user confirms the location information of the image to be recognized. This feature information may include color features, texture features, shape features, and spatial relationship features of the image to be recognized. Based on the feature information, the module determines whether a template matching the image to be recognized exists in the historically registered templates. If it does, the matching template is used as the recognition template. If it does not, an interface including the image to be recognized is displayed, requesting the user to confirm the location information. This display interface includes an indicator for receiving a selection gesture from the user. After the user selects a region, a drop-down menu can be displayed on the interface, allowing the user to select category information from the drop-down menu.
[0080] In this example embodiment, the template registration module further includes a comparison unit, which is used to: convert the image information of the identification template and each historical registration template into corresponding matrix information; and determine the distance between the matrix information of the identification template and each historical registration template through a clustering algorithm. When there is a template in the historical registration template whose matrix information distance from the identification template is less than a preset threshold, it is considered that the template matches the identification template and is used as the identification template. If there are multiple historical registration templates whose matrix information distance from the identification template is less than the preset threshold, the historical registration template with the smallest distance is selected as the identification template. When the distance between the matrix information of the historical registration template and the identification template is greater than the preset threshold, it is proven that there is no identification template in the historical registration template. In this case, template registration is performed based on the identification template. The clustering algorithm can be any algorithm that can achieve the above technical effect, such as K-means clustering. The preset threshold can be limited according to the actual situation. For example, when the accuracy requirement of the identification template is high, the preset threshold is also set to a smaller value. This example embodiment does not make any special limitation in this regard.
[0081] The template registration device described above also includes a character recognition unit, which is used to: obtain the position of the string to be recognized in the image to be recognized and / or the relative positional relationship between multiple strings to be recognized based on the recognition template; extract and recognize the corresponding string to be recognized at the position of each string to be recognized; and correct the recognition result of the string to be recognized based on the character category of each character in the string to be recognized.
[0082] Of course, the template registration device 400 provided in this application embodiment includes, but is not limited to, the modules described above.
[0083] Figure 5 A schematic diagram of another possible structure of the template registration device involved in the above embodiments is shown. The device includes a processor 502 and a communication interface 503. The processor 502 is used to control and manage the operation of the template registration device and / or to execute other processes of the technology described herein. The communication interface 503 is used to support communication between the template registration device and other network entities. The template registration device may also include a memory 501 and a bus 504, the memory 501 being used to store the program code and data of the template registration device.
[0084] The memory 501 may be a memory in a template registration device, and the memory may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include a combination of the above types of memory.
[0085] The processor 502 described above can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0086] Bus 504 can be an Extended Industry Standard Architecture (EISA) bus, etc. Bus 504 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0087] Figure 6 This is a schematic diagram of the structure of chip 600 provided in an embodiment of this application. Chip 600 includes one or more (including two) processors 610 and communication interfaces 630.
[0088] Optionally, the chip 600 also includes a memory 640, which may include read-only memory and random access memory, and provides operation instructions and data to the processor 610. A portion of the memory 640 may also include non-volatile random access memory (NVRAM).
[0089] In some implementations, memory 640 stores elements such as execution modules or data structures, or subsets thereof, or extended sets thereof.
[0090] In this embodiment of the application, the corresponding operation is executed by calling the operation instructions stored in the memory 640 (which may be stored in the operating system).
[0091] The processor 610 described above can implement or execute various exemplary logic blocks, units, and circuits described in conjunction with the disclosure of this application. The processor can be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logic blocks, units, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0092] The memory 640 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include combinations of the above types of memory.
[0093] The bus 620 can be an Extended Industry Standard Architecture (EISA) bus, etc. The bus 620 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The symbol is represented by only one line, but this does not mean that there is only one bus or one type of bus.
[0094] Through the above description of the embodiments, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device, and unit described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0095] This application provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the template registration method in the above method embodiments.
[0096] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the template registration method in the method flow shown in the above method embodiments.
[0097] The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: electrical connections having one or more wires; portable computer disks; hard disks; random access memory (RAM); read-only memory (ROM); erasable programmable read-only memory (EPROM); registers; hard disks; optical fibers; portable compact disc read-only memory (CD-ROM); optical storage devices; magnetic storage devices; or any suitable combination thereof; or any other form of computer-readable storage medium known in the art. An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may reside in an application-specific integrated circuit (ASIC). In the embodiments of this application, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0098] Embodiments of the present invention provide a computer program product containing instructions that, when executed on a computer, cause the computer to perform actions such as... Figure 2 and Figure 3 The template registration method described in [the document].
[0099] Since the template registration device, computer-readable storage medium, and computer program product in the embodiments of the present invention can be applied to the above method, the technical effects obtained can also be referred to the above method embodiments. The embodiments of the present invention will not be repeated here.
[0100] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0101] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0102] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0103] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A template registration method, characterized in that, include: In response to a user's confirmation of location information on an image to be recognized, the location and information category of the string to be recognized in the image to be recognized are obtained from the location information; A recognition template corresponding to the image to be recognized is generated based on the position and information category of the string to be recognized. The recognition template includes the position and information category of the string to be recognized. In the case that there are multiple strings to be recognized in the recognition template corresponding to the image to be recognized, the recognition template also includes the relative positional relationship between the multiple strings to be recognized. Comparing the identification template with historical registration templates, if the identification template is not found in the historical registration templates, template registration is performed based on the identification template, where the historical registration templates are already registered templates; wherein, the step of registering the template based on the identification template includes: Erase each of the strings to be identified from the image to be identified; A sample string is generated based on the information category, and the sample string is superimposed onto the position corresponding to the string to be identified to obtain a sample image; The sample image is used as training data, and the sample string is used as a label to correct the recognition template, thereby obtaining the corrected recognition template, and the corrected recognition template is registered.
2. The template registration method according to claim 1, characterized in that, The comparison of the identification template with the historical registration template includes: The identification template and each of the historical registration templates are converted into corresponding matrix information; Clustering algorithms are used to determine the matrix information of the identification template and the distance between the matrix information of each historical registration template. When any of the obtained distances is less than a preset threshold, it is determined that the identification template exists in the historical registration template; when all the obtained distances are greater than the preset threshold, it is determined that the identification template does not exist in the historical registration template.
3. The template registration method according to claim 1, characterized in that, Prior to responding to a user's confirmation of location information on the image to be identified, the method further includes: Receive the image to be identified and obtain the feature information of the image to be identified; Based on the feature information, determine whether there is a template in the historical registration templates that matches the image to be identified; If a matching template exists, the matching template will be used as the identification template. If it does not exist, an interface including the image to be identified is displayed, which is used to request the user to confirm the location information.
4. The template registration method according to claim 1, characterized in that, The method further includes: Based on the recognition template, obtain the position of the string to be recognized in the image to be recognized and / or the relative positional relationship between the multiple strings to be recognized, and extract and recognize the corresponding string to be recognized at the position of each string to be recognized; The recognition result of the string to be recognized is corrected based on the character category of each character in the string to be recognized.
5. The template registration method according to claim 4, characterized in that, The method further includes: In response to the user's confirmation of the character category, the character category of each character in the string to be identified is determined.
6. A template registration device, characterized in that, include: The response module is used to respond to the user's confirmation operation on the image to be recognized, and to obtain the position and information category of the string to be recognized in the image from the location information; The template generation module is used to generate a recognition template corresponding to the image to be recognized based on the position and information category of the string to be recognized. The recognition template includes the position and information category of the string to be recognized, and when there are multiple strings to be recognized in the recognition template corresponding to the image to be recognized, the recognition template also includes the relative positional relationship between the multiple strings to be recognized. The template registration module is used to compare the identified template with historical registered templates. If the identified template is not found in the historical registered templates, the module registers the template based on the identified template. The historical registered templates are already registered templates. The response module is further configured to: in response to the user's confirmation operation on the character category, determine the character category of each character in the string to be identified; The template registration module further includes a training unit, which is used to: erase each of the strings to be identified in the image to be identified; generate a sample string according to the information category, and superimpose the sample string onto the position corresponding to the string to be identified to obtain a sample image; The sample image is used as training data, and the sample string is used as a label to correct the recognition template, thereby obtaining the corrected recognition template, and the corrected recognition template is registered.
7. The template registration device according to claim 6, characterized in that, The template registration device further includes a character recognition unit, used for: obtaining the position of the string to be recognized in the image to be recognized and / or the relative positional relationship between the plurality of strings to be recognized according to the recognition template; extracting and recognizing the corresponding string to be recognized at the position of each string to be recognized; and correcting the recognition result of the string to be recognized according to the character category of each character in the string to be recognized.
8. An electronic device, characterized in that, The electronic device includes a memory and a processor; the memory and the processor are coupled; the memory is used to store computer program code, the computer program code including computer instructions; Wherein, when the processor executes the computer instructions, the electronic device performs the template registration method as described in any one of claims 1-5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed on an electronic device, cause the electronic device to perform the template registration method as described in any one of claims 1-5.