Character recognition method and electronic device
By determining the proportion of the character area in the image and using the sliding window attribute to intercept small images for character recognition, the problem of unclear recognition and high error rate caused by the small proportion of the character area in the existing technology is solved, and the accuracy of character recognition is improved. Accuracy.
Patent Information
- Application Number
- CN202011399487.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-01
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-12-01
AI Technical Summary
In the existing technology, the character area in the image accounts for a small proportion, resulting in unclear or unrecognizable characters, resulting in a high recognition error rate.
By determining the proportion of the character area in the image, if it is less than the preset value, use the sliding window attribute to intercept multiple small images for character recognition, reduce the amount of compression, improve the individual character size and spacing clarity, thereby improving the recognition accuracy.
It effectively improves the accuracy of character recognition, especially when the character area is small, avoiding recognition errors and loss of character information.
Smart Images

Figure CN112613348B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a character recognition method and electronic equipment. Background Art
[0002] With the advancement of technology, more and more fields are changing from manual monitoring to intelligent monitoring, especially in the fields of traffic capture or container transportation monitoring. During monitoring, the identity of the object is confirmed by recognizing the characters of the object, thereby achieving the purpose of monitoring.
[0003] The prior art uses the following method to perform character recognition. Specifically, the size of the image is first compressed to a fixed size, multiple characters in a character area in the image are segmented to obtain a single character, and then the single character is recognized.
[0004] However, when the image is taken, the shooting location is far away from the character area, resulting in a relatively small proportion of the character area in the image, and the font in the image will be relatively small. After compression, the character area in the image will be even smaller, resulting in a relatively fuzzy gap between the characters, so that when the character area is segmented, the segmentation is unclear. Or during recognition, the character area may not be recognized as a character area at all because the proportion of the character area is too small, that is, the character cannot be recognized, resulting in a high recognition error rate. Summary of the invention
[0005] The present invention provides a character recognition method and a recognition device. Before character recognition, if it is determined that the proportion of the character area in the first image containing the characters is relatively small, a determined sliding window attribute is used to intercept multiple second images of a size smaller than the first image from the first image. After compression, the compression amount becomes smaller, so that the individual characters are larger and the spacing between the characters is clearer during recognition, which can improve the recognition accuracy.
[0006] In a first aspect, an embodiment of the present invention provides a character recognition method, comprising:
[0007] Determine the proportion of the character area in the first image containing the character;
[0008] If the proportion of the character area in the first image is less than a preset value, determining the properties of the sliding window corresponding to the proportion range to which the proportion of the character area belongs according to the correspondence between the preset proportion range and the properties of the sliding window; the properties of the sliding window include the size of the sliding window and the moving step length;
[0009] Using the determined sliding window attribute, a plurality of second images are intercepted from the first image, and character recognition is performed based on the plurality of second images.
[0010] The above method first determines the proportion of the character area in the first image containing the characters. When the proportion is less than a preset value, that is, the character area in the first image is relatively small, the attributes of the sliding window corresponding to the proportion range to which the proportion of the character area belongs are determined according to the correspondence between the preset proportion range and the attributes of the sliding window. Then, the determined attributes of the sliding window are used to intercept multiple second images smaller in size than the first image from the first image to perform character recognition. Compared with directly compressing the first image, the compression amount is reduced, so that the individual characters are larger, and the spacing between the characters is clearer and easier to recognize, thereby improving the accuracy of character recognition.
[0011] In a possible implementation manner, performing character recognition according to the plurality of second images includes:
[0012] Identify a second image containing characters from a plurality of second images and mark a character region in the identified second image, and determine a layout type of the characters in the second image containing characters;
[0013] Character recognition is performed on characters in a character area in the second image containing the characters according to the layout type of the characters.
[0014] The above method recognizes the character area of the image and the layout type of the characters, so that the characters can be recognized by the layout type during character recognition. This method of recognizing different layouts improves the accuracy of character recognition.
[0015] In a possible implementation, identifying a second image containing characters from a plurality of second images and marking a character region in the identified second image, and determining a layout type of characters in the second image containing characters, includes:
[0016] Using a region recognition network, a second image containing characters is recognized from a plurality of second images, and a character region in the recognized second image is marked;
[0017] The preset layout type is compared with the layout of the characters in the second image containing the characters, and the preset layout type with the highest contrast is determined as the layout type of the characters in the second image.
[0018] The above method can identify the second image containing characters and the character area in the second image through the area recognition network, and find the layout type with the highest contrast from the preset layout types as the layout type of the characters in the second image. When performing character recognition, different layouts can be recognized to improve the accuracy of character recognition.
[0019] In a possible implementation, identifying a second image containing characters from a plurality of second images, and determining a character region and a layout type of the characters in the second image containing characters, includes:
[0020] Using a layout classification neural network, a second image containing characters is identified from a plurality of second images, a character region in the identified second image is marked, and a layout type of the characters in the second image containing characters is determined;
[0021] The training process of the layout classification neural network includes:
[0022] Taking a sample image as input, taking a character region and a character layout type in the sample image as output, performing multiple rounds of training on a basic neural network to obtain the layout classification neural network;
[0023] In each round of training, the sample image is input into the basic neural network, and the output result is input into the first loss function to calculate the first loss value. At the same time, the sample image is input into the basic neural network, and the output result is input into the second loss function to calculate the second loss value. According to the first loss value and the second loss value, the parameters in the basic network are adjusted;
[0024] The first loss function is the SmoothL1 loss function, and the second loss function is the GIOU loss function.
[0025] The above method can be recognized through the layout classification neural network, and introduces the SmoothL1 loss function and the GIOU loss function during training to improve the training accuracy.
[0026] In a possible implementation, after marking the character region in the recognized second image, and before performing character recognition on the character region in the second image containing the characters according to the layout type of the characters, the method further includes:
[0027] If the number of extracted character regions includes multiple ones, and the multiple character regions have overlapping areas in the first image, the multiple character regions are merged.
[0028] In the above method, since multiple second images are used to identify character areas, when the second images are captured, the same character area may be divided into multiple second images. Therefore, in order to improve the integrity of the recognized character area, the number of extracted character areas includes multiple areas, and if the multiple character areas have overlapping areas in the first image, the multiple character areas are fused.
[0029] In a possible implementation, after marking the recognized character region in the second image, and before performing character recognition on characters in the character region in the second image containing the characters according to the layout type of the characters, the method further includes:
[0030] A preset background image is used to fill the background of the character area whose aspect ratio is not within a preset range, and the size of the filled character area is adjusted to a preset size.
[0031] The above method will adjust the size of the character area before performing character recognition. In order to avoid distortion of the characters in the character area when adjusting the size of the character area, the present invention will use a preset background image to fill the background of the character area whose aspect ratio is not within the preset range. In this way, when the size of the filled character area is adjusted, distortion of the characters in the character area is avoided, the difficulty of character recognition is reduced, and at the same time, the problem of low recognition accuracy caused by inconsistent sizes during the character recognition process is avoided.
[0032] In a possible implementation, character recognition is performed on a character region in a second image containing characters according to the layout type of the characters, including:
[0033] According to the character layout type, the character area is segmented to obtain multiple areas containing single characters;
[0034] Character recognition is performed on each of the multiple regions containing a single character.
[0035] The above method divides the character area according to the character layout type during recognition, so as to obtain the area of a single character. Character recognition is performed on the area of a single character, avoiding the problem of low recognition accuracy caused by unclear character boundaries when recognizing multiple characters together.
[0036] In a possible implementation, character recognition is performed on a plurality of regions containing single characters respectively, including:
[0037] Extract features from multiple regions containing single characters to obtain multiple feature maps;
[0038] Through the attention model, multiple feature maps are fused to obtain a comprehensive feature map;
[0039] Character recognition is performed according to the comprehensive feature map.
[0040] In the above method, when performing character recognition, the feature extraction of the character area is first performed to obtain multiple feature maps, and then the multiple feature maps are fused through the attention model to obtain a comprehensive feature map, and character recognition is performed based on the comprehensive feature map. This not only simplifies the character recognition process, but also makes the classification features richer due to the use of the attention model, thereby improving the accuracy of character recognition.
[0041] In a possible implementation, character recognition is performed on a character region in a second image containing characters according to the layout type of the characters, including:
[0042] Performing character recognition on a character region in a second image containing characters according to a type of character layout by using an object detection network;
[0043] Among them, the training process of the target detection network includes:
[0044] The sample image and the layout type of the characters in the sample image are taken as input, the characters in the sample image are taken as output, and the basic neural network is trained for multiple rounds to obtain the target detection network.
[0045] The above method can perform character recognition on the second image containing characters through the target detection network, thereby improving the recognition accuracy.
[0046] In a possible implementation manner, determining the proportion of the character area in the first image containing the characters includes:
[0047] If the resolution of the image taken by the camera device is not less than the preset resolution, the proportion of the character area in the first image corresponding to the current installation position of the camera device is determined based on the correspondence between the installation position of the camera device and the proportion of the character area taken by the camera device; the first image is taken by the camera device.
[0048] In the above method, when the image resolution is relatively high, since the installation position of the camera device is related to the size of the shooting area, and further to the proportion of the character area, it is possible to pre-set the correspondence between the installation position of the camera device and the proportion of the character area photographed by the camera device, thereby obtaining the proportion of the character area in the first image. In this way, the proportion of the character area in the first image can be obtained without actually measuring the position of the character area in the first image, thereby simplifying the processing method.
[0049] In a possible implementation, the method further includes:
[0050] If the resolution of the image captured by the camera device is smaller than the preset resolution, the size of the first image is adjusted to the preset size, and character recognition is performed on the resized first image.
[0051] The above method can be used when the resolution of the image taken by the camera device is relatively small. Considering that the resolution of the character area in the first image will also be relatively small and difficult to recognize, the size of the first image can be adjusted to a preset recognition size, and character recognition can be directly performed on the first image, thereby improving the accuracy of character recognition.
[0052] In a second aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor:
[0053] The memory is used to store program codes used when the electronic device is running;
[0054] The processor is used to execute the program code to implement the character recognition method as described in any one of the first aspects.
[0055] In a third aspect, the present application further provides a computer storage medium having a computer program stored thereon, which, when executed by a processing unit, implements the steps of the character recognition method described in the first aspect.
[0056] In addition, the technical effects brought about by any implementation method in the second to third aspects can refer to the technical effects brought about by different implementation methods in the first aspect, and will not be repeated here.
[0057] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present invention, and together with the description are used to explain the principles of the present invention, and do not constitute improper limitations of the present invention.
[0059] Figure 1 is a schematic diagram of a process of a character recognition method provided by an embodiment of the present invention;
[0060] Figure 2 is a schematic diagram of a relationship between a first image, a second image, and a character area provided by an embodiment of the present invention;
[0061] Figure 3 It is a schematic diagram of the workflow of a license plate recognition method provided by an embodiment of the present invention;
[0062] Figure 4 It is a schematic diagram of the relationship between a first image captured and a second image intercepted from the first image in license plate recognition provided by an embodiment of the present invention;
[0063] Figure 5 is a schematic diagram of a working process of a carriage character recognition method provided by an embodiment of the present invention;
[0064] Figure 6 is a schematic diagram of a working process of performing character recognition based on multiple second images provided by an embodiment of the present invention;
[0065] Figure 7 is a schematic diagram of a character recognition process provided by an embodiment of the present invention when character areas in multiple second images overlap in a first image;
[0066] Figure 8 is a schematic diagram of performing background filling on a character area whose aspect ratio is not within a preset range, provided by an embodiment of the present invention;
[0067] Fig. 9 It is a schematic diagram of the working process of an attention mechanism of a convolutional neural network provided by an embodiment of the present invention;
[0068] Fig.10 It is a schematic diagram of the working process of a channel attention module in an attention mechanism of a convolutional neural network provided by an embodiment of the present invention;
[0069] Fig.11 It is a schematic diagram of the working process of a spatial attention module in an attention mechanism of a convolutional neural network provided by an embodiment of the present invention;
[0070] Fig.12 is a schematic diagram of a complete workflow of a character recognition method provided by an embodiment of the present invention;
[0071] Fig.13 is a structural block diagram of an electronic device provided by an embodiment of the present invention;
[0072] Fig.14 It is a structural block diagram of another acquisition device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0073] In order to enable ordinary persons in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.
[0074] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein.
[0075] The application scenarios described in the embodiments of the present invention are intended to more clearly illustrate the technical solutions of the embodiments of the present invention, and do not constitute a limitation on the technical solutions provided by the embodiments of the present invention. A person of ordinary skill in the art can appreciate that, with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present invention are also applicable to similar technical problems.
[0076] At present, after the image is collected, the image is subjected to character recognition. If the character area in the image accounts for a relatively small proportion, it is easy to fail to recognize, resulting in loss of character information and a relatively low recognition rate.
[0077] A character recognition method and electronic device provided by an embodiment of the present invention, before performing character recognition, determines that the character area in an image containing characters accounts for a relatively small proportion, and changes the size of the image to be recognized, thereby changing the clarity of individual characters and between characters in the image to be recognized, thereby improving the recognition rate of character recognition.
[0078] The technology of the present invention is described in detail below with reference to the accompanying drawings.
[0079] Combination Figure 1 As shown, a character recognition method provided by an embodiment of the present invention is shown, comprising:
[0080] S100: Determine the proportion of the character area in the first image containing the characters.
[0081] The proportion of the character region in the first image containing the characters is the ratio between the area of the character region in the first image and the area of the first image, or the ratio between the length of the character region in the first image and the length of the first image.
[0082] S101: If the proportion of the character area in the first image is less than a preset value, determine the properties of the sliding window corresponding to the proportion range to which the character area proportion belongs according to the correspondence between the preset proportion range and the properties of the sliding window. The properties of the sliding window include the size of the sliding window and the moving step.
[0083] S102: using the determined sliding window attribute, intercepting a plurality of second images from the first image, and performing character recognition based on the plurality of second images.
[0084] After extracting the plurality of second images from the first image and before performing character recognition based on the plurality of second images, the method further includes adjusting the plurality of second images to a fixed size. The size of the fixed size may be determined by a neural network during character recognition.
[0085] Combination Figure 2As shown, C1 represents the first image, C2 is the character area in the first image, and C3 represents one of the second images captured when the capture action is performed according to the size of the sliding window and the moving step length. The second image is an image containing the character area. It can be seen that the area of the first image C1 is smaller than the area of the second image C3, so when the area of the character area C2 remains unchanged, the proportion of the character area C2 in the second image C3 becomes larger than the proportion of the character area C2 in the first image C1. Before character recognition, when the size is adjusted to a fixed size, compared with directly using the first image for compression, the individual characters in the second image become larger and the spacing between the characters is clearer. In this way, when recognizing characters, they are easier to recognize, thereby improving the accuracy of character recognition.
[0086] Among them, the size of the character area in the image may be different, that is, there will be different proportions. If you want the proportion of the character area in the intercepted second image to be similar, you can determine the correspondence between different proportion ranges and the sliding window. When the proportion range is small, the size of the sliding window in the sliding window attribute is configured to be smaller and the moving step is smaller; when the proportion range is large, the size of the sliding window in the sliding window attribute is configured to be larger and the moving step is larger. After determining the correspondence, according to the proportion range to which the currently determined proportion belongs, in the determined correspondence, the corresponding sliding window attribute is searched. According to the attributes of the found sliding window, multiple second images are intercepted from the first image. According to the multiple second images, the characters do not change much when performing character recognition. This can avoid the problem that the corresponding features cannot be accurately recognized when the character size changes greatly, that is, the feature changes greatly. Therefore, the present invention can not only change the proportion of the character area, but also perform character recognition with a second image of suitable size, thereby improving the accuracy of character recognition.
[0087] Taking the image of a license plate as an example, when photographing a license plate, a camera is usually set up on a railing erected on the roadside. When shooting, since the camera is at a relatively high height from the ground, the proportion of the license plate photographed may be relatively small.
[0088] Based on the above situation, combined with Figure 3 As shown, a license plate recognition method is provided, comprising:
[0089] S300: Determine the proportion of the license plate in the captured vehicle image;
[0090] S301: if the proportion of the license plate in the captured vehicle image is less than a preset value, determining the attribute of the sliding window corresponding to the proportion range to which the proportion of the license plate belongs according to the correspondence between the preset proportion range and the attribute of the sliding window;
[0091] S302: Using the determined sliding window attributes, a plurality of small images are captured from the captured image of the vehicle, and license plate recognition is performed based on the plurality of small images.
[0092] like Figure 4 As shown, a schematic diagram of a captured vehicle is shown. C4 is an image of the captured vehicle, and C5 is a small image captured from the captured vehicle image. The area of the captured vehicle image C4 is smaller than the area of the small image C5 captured from the captured vehicle image, so when the area of the license plate area remains unchanged, the proportion of the license plate area in the small image C5 captured from the captured vehicle image is relatively large, and then the small image C5 captured from the captured vehicle image is subjected to license plate recognition, thereby improving the accuracy of license plate recognition.
[0093] Taking the images of containers as an example, since there are a large number of containers, in order to save the number of cameras, multiple containers will be photographed in one photo. At the same time, the text on the container accounts for a relatively small proportion compared to the container itself. Therefore, when multiple containers appear in the same picture, the font on the container accounts for a relatively small proportion, which makes it more difficult to identify the font on the container.
[0094] Based on the above situation, combined with Figure 5 As shown, a carriage identification method is provided, comprising:
[0095] S500: Determine the proportion of the character area in the image containing the carriage;
[0096] S501: if the proportion of the character area in the image containing the carriage is less than a preset value, determining the attribute of the sliding window corresponding to the proportion range to which the proportion of the license plate belongs according to the correspondence between the preset proportion range and the attribute of the sliding window;
[0097] S502: Using the determined sliding window attributes, a plurality of small images are captured from the image containing the carriage, and character recognition on the carriage is performed based on the plurality of small images.
[0098] If the image of the container contains two or more character areas, the proportion of each character area in the image is determined. For each character area, the attribute of the sliding window corresponding to the proportion range to which the proportion of the character area belongs is determined based on the correspondence between the preset proportion range and the attribute of the sliding window. If the attributes of the determined sliding windows are different, the sliding window with the smallest size in the attributes is used, multiple small images are captured from the image, and the characters in each character area are recognized.
[0099] Among them, since the proportion of the character area in the first image is the same as the proportion of the actual shooting area and the actual character area corresponding to the first image, the proportion of the actual shooting area and the actual character area corresponding to the first image is determined as the proportion of the character area in the first image containing the characters.
[0100] The ratio of the actual shooting area and the actual character area corresponding to the first image is obtained by way 1, that is, the ratio of the area of the actual shooting area and the area of the actual character area corresponding to the first image.
[0101] The area of the actual shooting region and the area of the actual character region corresponding to the first image can be obtained by actual manual measurement.
[0102] Method 2 for obtaining the ratio of the length of the actual shooting area corresponding to the first image to the length corresponding to the actual character area.
[0103] That is, the length corresponding to the actual character area is a part of the length of the actual shooting area corresponding to the first image, and the proportion of this part to the total length is determined.
[0104] The length of the actual shooting area and the length of the actual character area corresponding to the first image can be obtained by actual manual measurement.
[0105] Considering that the character area in the image with a large resolution is also relatively clear, the second image can be intercepted by proportion to perform character recognition. The character area in the image with a small resolution is also relatively fuzzy. If character recognition is still performed by intercepting the second image, the resolution of the second image is smaller, and there are fewer elements in character recognition, thereby reducing the recognition accuracy. In view of this, an embodiment of the present invention provides a method for determining the proportion of the character area in a first image containing characters, including: if the resolution of the image captured by the camera device is not less than the preset resolution, then according to the corresponding relationship between the installation position of the camera device and the proportion of the character area captured by the camera device, determine the proportion of the character area in the first image corresponding to the current installation position of the camera device; the first image is captured by the camera device. If the resolution of the image captured by the camera device is less than the preset resolution, the size of the first image is adjusted to the preset size, and character recognition is performed on the resized first image.
[0106] Among them, the correspondence between the installation position of the camera device and the proportion of the character area photographed by the camera device can be pre-set. The user can capture images with the camera device at different installation positions, and then identify the proportion of the character area of the captured image, and determine the correspondence between the installation position of the camera device and the proportion of the character area photographed by the camera device according to the minimum proportion corresponding to different installation positions.
[0107] When method 1 of implementing S600 is used to identify character areas, the preset size is the size required by the area recognition network. When method 2 of implementing S600 is used to identify character areas, the preset size is the size required by the layout classification neural network.
[0108] Combination Figure 6 As shown, the methods for character recognition include:
[0109] S600: Identify a second image containing characters from a plurality of second images, mark a character region in the identified second image, and determine a layout type of the characters in the second image containing characters.
[0110] S601: performing character recognition on characters in a character area in a second image containing the characters according to the layout type of the characters.
[0111] The embodiment of the present invention further provides the following two methods to implement S600.
[0112] Method 1: Through a region recognition network, a second image containing characters is identified from multiple second images and the character area in the identified second image is marked; a preset layout type is compared with the layout of the characters in the second image containing the characters, and the preset layout type with the highest contrast is determined as the layout type of the characters in the second image.
[0113] The training process of the region recognition network is as follows: the sample image randomly selected from the sample set is used as input, the character area in the sample image is used as output, and the basic neural network is trained multiple times to obtain the region recognition network. In each round of training, the sample image is input into the basic neural network, and the output result is input into the loss function to calculate the loss value. According to the loss value, the parameters in the basic network are adjusted.
[0114] The preset layout types include single-row, multi-row, single-column, multi-column, multi-row and multi-column, etc.
[0115] When comparing the preset layout type with the layout of characters in the second image containing characters, first, draw the layout of the characters in the second image containing characters based on the gaps between characters, and then compare the preset layout type with the drawn layout to determine the preset layout type with the highest contrast as the layout type of the characters in the second image.
[0116] Method 2: using a layout classification neural network, identifying a second image containing characters from a plurality of second images and marking a character region in the identified second image, and determining a layout type of the characters in the second image containing characters;
[0117] The training process of the layout classification neural network includes:
[0118] Taking a sample image as input, taking a character region and a character layout type in the sample image as output, performing multiple rounds of training on a basic neural network to obtain the layout classification neural network;
[0119] In each round of training, the sample image is input into the basic neural network, and the output result is input into the first loss function to calculate the first loss value. At the same time, the sample image is input into the basic neural network, and the output result is input into the second loss function to calculate the second loss value. According to the first loss value and the second loss value, the parameters in the basic network are adjusted;
[0120] The first loss function is the SmoothL1 loss function, and the second loss function is the GIOU loss function.
[0121] The layout neural network is a neural network that uses different layout types as classification targets. The layout classification neural network can distinguish character areas of different layout types.
[0122] Especially for character recognition on the carriage, since the characters on the carriage may exist in a single line, multiple lines, a single column, multiple columns, etc., the layout classification neural network can not only identify the character area on the carriage but also identify the layout type of the characters.
[0123] Specifically, since the present invention can distinguish character regions of different layout types through the layout classification neural network, and can output the layout type of the character region, for example, single row, 2 rows, single column, 3 columns, etc., when performing character recognition, if the character region is segmented, the character region can be segmented according to the recognized layout type. For example, if the layout type is recognized as 2 rows and 3 columns, then when segmenting, characters of 2 rows and 3 columns are segmented, that is, 6 characters are obtained.
[0124] The plurality of second images are input into the layout classification neural network for character region recognition, and the working process of determining the character region in the second image containing the characters is as follows:
[0125] The plurality of second images are input one by one into the layout classification neural network for character area recognition, the second image containing the characters is recognized, and the character area and the layout type of the characters in the recognized second image are marked.
[0126] In order to improve processing efficiency, multiple second images are input into multiple layout classification neural networks for character recognition to determine the character area and the layout type of the characters in the second image containing the characters.
[0127] When multiple second images are input into multiple layout classification neural networks for character recognition, multiple threads need to be established at the same time, and multiple threads are started at the same time, so as to improve processing efficiency.
[0128] It should be noted that the number of threads started simultaneously may be less than or equal to the number of second images, that is, when the number of second images is N, the number of established threads may be less than N or the same as N.
[0129] When the number is less than N, the layout classification neural network of the number of established threads is called to perform parallel character area recognition on the second images of the number of established threads, that is, to identify whether each second image includes a character area, and if so, output its position and the layout type of the character.
[0130] When a sliding window is used to capture an image, the capture may be performed in a manner where the moving step is smaller than the size of the sliding window. For example, the size of the sliding window is 5000*2048, and the moving step is 2500. Since the multiple second images captured from the first image have overlapping areas, for the same character area, the number of recognized character areas includes multiple areas, and each area comes from a different second image. At the same time, the position information of the multiple character areas in the first image overlaps. In order to avoid character loss, an embodiment of the present invention provides a method, including:
[0131] If the number of extracted character regions includes multiple ones, and the multiple character regions overlap in the first image, the multiple character regions are merged.
[0132] For example, combined with Figure 7 As shown, in one of the second images P1, the character area P11 is identified, and in the other second image P2, the character area P22 is identified. The area of the character area P11 in the first image and the area of the character area P22 in the first image have overlapping parts, which are marked with dotted boxes. The character area P11 and the character area P22 are then merged, and the merged character area is subjected to character recognition processing.
[0133] Specifically, the training process involves randomly selecting sample images from the sample set and inputting them into the basic neural network to obtain the output result. The output result is then input into the first loss function to calculate the first loss value, and the output result is then input into the second loss function to calculate the second loss value. The parameters in the basic network are adjusted according to the first loss value and the second loss value. The basic network is trained in this way until the output result is less different from the standard result and meets expectations, and the training is completed.
[0134] In this way, by introducing two loss functions in the training process and adjusting the parameters in the basic network, the robustness of the trained layout classification neural network is improved.
[0135] The method for acquiring the sample set is as follows: the user collects a large number of images containing character areas of different formats as the sample set, and the collected sample set is transformed to obtain new images as the sample set, that is, the sample set is expanded.
[0136] The sample set can be augmented by some or all of the following:
[0137] Method 1: Use a sliding window method to divide a captured image into multiple small images, and use each small image as a new sample image.
[0138] Method 2: Use data enhancement method on the sample images in the sample set to obtain multiple new sample images.
[0139] For example, by cropping, multiple images containing character areas are cropped from an image, and the positions of the character areas in these images are different. For example, the character area in the new image can be cropped to be in the upper left corner, the character area in the new image can be cropped to be in the upper right corner, and so on.
[0140] By adding a border, a new background image is added to the sample image to generate a new sample image.
[0141] By means of grayscale transformation, the color of the pixels in the sample image is changed to different grayscale values to obtain a new image as the sample image.
[0142] By using the mixup linear difference method, the fmix method, and the cutmix method, images are randomly selected from the sample set for mixing to obtain new images as sample images, so as to achieve the purpose of sample image expansion.
[0143] Method 3: According to the generation rules of scene features, characters of different layouts are obtained, and the images of the generated character areas of different layouts are used as samples.
[0144] When the scene is to recognize characters in a carriage, since the carriage character area includes multi-row character areas, single-line character areas, multi-column character areas, and single-column character areas, according to the generation rules of carriage features, characters are extracted from different font types to generate carriage characters, and then the size of the character area is determined according to the size of its font, and the character area is added to the background image of the carriage to obtain a sample set of images containing the character area.
[0145] For example, the first to fourth characters are composed of English letters, the fifth to tenth characters are composed of numbers, and the eleventh character is composed of numbers. According to the above rules, a new box number on the carriage is generated, the font size of the box number is determined, the size of the character area is determined, and an image is generated as a sample image for training.
[0146] When the scenario is to recognize characters on a license plate, when generating a character area, the characters on the license plate are determined according to the font type in the license plate, and the character area of the license plate is determined according to the font size, and the image containing the character area is used as a sample set.
[0147] For example, the first character of the license plate number is the abbreviation of the province, the second character of the license plate number is an English capital letter, the third character is a dot, and the fourth to eighth characters are a mixture of numbers and English capital letters. According to these rules, a new license plate number is generated and the license plate number is used as a sample image.
[0148] The embodiment of the present invention further provides the following method to implement S601.
[0149] According to the character layout type, the character area is segmented to obtain multiple areas containing single characters; and character recognition is performed on the multiple areas containing single characters respectively.
[0150] The specific method of performing character recognition on multiple regions containing single characters respectively is: performing feature extraction on multiple regions containing single characters to obtain multiple feature maps.
[0151] Furthermore, in order to improve the calculation accuracy, an attention mechanism is added to the object detection network, thereby improving the accuracy of character recognition. Specifically:
[0152] Feature extraction is performed on multiple regions containing single characters to obtain multiple feature maps; multiple feature maps are fused through an attention model to obtain a comprehensive feature map; character recognition is performed based on the comprehensive feature map.
[0153] Specifically, the target detection network can be used to extract features from the character area to obtain multiple feature maps, and then the multiple feature maps can be fused through the attention model to obtain a comprehensive feature map; and then the target detection network can be used to perform character recognition based on the comprehensive feature map. The target detection network can be obtained by training a convolutional neural network as the basic network.
[0154] The object detection network is used to extract multi-scale features from the character area, and each scale forms a feature map. Then, the features in each feature map are weighted through the attention model to obtain each weighted feature map. Then, the features corresponding to the same position in each feature map are added to obtain a comprehensive feature map, and character recognition is performed based on the comprehensive feature map.
[0155] Among them, the attention model is a model that assigns weights to the extracted feature maps.
[0156] Combination Fig. 9As shown in the figure, the working principle diagram of the attention model is shown. The attention model can be called Convolutional Block Attention Module, which is used for the attention mechanism of convolutional neural network. First, the input image is feature extracted through the convolutional neural network to obtain a feature map, that is, the Input Feature in the figure. Then, the feature map passes through the channel attention module (Channel Attention Module) to obtain the channel weight (named ChannelAttention Mc), and the channel weight is assigned to the Input Feature. Then, the feature map assigned with the channel weight (named Channel-refined Feature F) passes through the spatial attention module (Spatial Attention Module) to obtain the spatial weight (named Spatial Attention Ms), and the spatial weight is assigned to the feature map assigned with the channel weight, and the weighted feature map assigned with the spatial weight and the channel weight is output.
[0157] Among them, combined Fig.10 As shown in the figure, the working process of the channel attention module is as follows: the Input Feature is subjected to feature dimensionality reduction through maximum pooling (MaxPool) and average pooling (AvgPool), and then through MLP, i.e., multi-layer perceptron, fully connected layer, and Shared MLP is a shared multi-layer perceptron, that is, the feature maps obtained by the two different dimensionality reduction methods after maximum pooling (MaxPool) and average pooling (AvgPool) are fully connected to obtain the channel weight (Channel Attention Mc).
[0158] Combination Fig.11 As shown in the figure, the working process of the spatial attention module is as follows: the feature map (Channel-refined Feature F) with channel weights is processed by the maximum pooling (MaxPool) and the average pooling (AvgPool), that is, after the feature dimension is reduced, the convolution layer (conv layer) is used to obtain the spatial weight (Spatial Attention Module).
[0159] Among them, for character areas with different layouts, the changes in their aspect ratios are relatively large. For example, the character areas of a single row and a single column have a relatively large aspect ratio. Before being input into the second neural network, the size of the image needs to be adjusted, and the aspect ratio of the size of the output image is the same. Therefore, when adjusting, the image may be distorted during adjustment due to the large change in the aspect ratio, resulting in character recognition errors. For example, when the aspect ratio is 10:1, when adjusting the image size, for example, when adjusting its size, it is likely to lengthen the width, causing the characters to become slender. Therefore, in order to avoid the above situation, the present invention can also use a preset background image to fill the background of the character area whose aspect ratio is not within the preset range before performing character recognition on the character area, and adjust the size of the filled character area to the preset size.
[0160] The effect after filling may be that the aspect ratio is 1. The preset range is a range of about 1, for example, between 0.8 and 1.2.
[0161] Combination Figure 8 As shown, the aspect ratio of the character area B1 is 5:1, and then the background image is used to increase the existing width of the area by 4 points in the width direction. For example, the background images b~b4 are added to B1, and the filled character area is combined to obtain the aspect ratio of the filled character area, so that the aspect ratio of the filled character area is 1, and then the size of the filled character area is adjusted to the preset size.
[0162] For the second neural network mentioned above, the training process is: taking the sample image randomly selected from the sample set and the layout type of the characters in the sample image as input, taking the characters in the sample image as output, training the basic neural network multiple times to obtain the second neural network.
[0163] Specifically, randomly select an image containing a character area from the sample set and the type of the character layout in the image and input it into the basic neural network to obtain the output result, input the output result into the loss function to calculate the loss value, and adjust the parameters in the basic network according to the loss value. This process is repeated until the output result is less different from the standard result, and the training is completed.
[0164] The method for obtaining the sample set is similar to that of the above-mentioned layout classification neural network, that is, the user collects a large number of images containing characters as the sample set, and the images can be processed to obtain new images as sample images.
[0165] Method 1: based on the sample set in the sample set of the above-mentioned layout classification neural network, the character area is cut out and used as the sample image of the neural network for character recognition.
[0166] Method 2: The cut-out character area is expanded by border expansion to obtain a new image as a sample image.
[0167] Method 3: Rotate the cut-out character area by a small angle to obtain a new image as a sample image, for example, rotate 5 degrees or 10 degrees.
[0168] Method 4: grayscale conversion of the cut-out character area, that is, changing the grayscale value of the pixel points in the cut-out character area to obtain a new image with different grayscale values as a sample image.
[0169] Method 5: According to the generation rules of scene features, characters of different formats are obtained, and the images of the generated characters of different formats are used as samples. Furthermore, the background of the character area in the collected image is cut off, and the generated characters are added to the background of the character area in the collected image, and the obtained new image is used as a sample.
[0170] When the scenario is to recognize characters in a carriage, characters are extracted from different font types and font sizes according to the generation rules of carriage features to generate carriage characters, and images of the characters are used as samples.
[0171] When the scenario is to recognize characters on a license plate, characters are extracted from different font types and font sizes according to the generation rules of license plate features to generate a license plate, and the image of the license plate is used as a sample.
[0172] Based on the above introduction, combined with Fig.12 As shown, a complete process of character recognition is shown, including:
[0173] S1200: Determine the proportion of the character area in the first image containing the characters;
[0174] S1201: If the proportion of the character area in the first image is less than a preset value, determine the attribute of the sliding window corresponding to the proportion range to which the proportion of the character area belongs according to the correspondence between the preset proportion range and the attribute of the sliding window.
[0175] S1202: Using the determined sliding window attribute, capture a plurality of second images from the first image.
[0176] S1203: Using a layout classification neural network, identify a second image containing characters from a plurality of second images and mark the character region in the identified second image, and determine the layout type of the characters in the second image containing characters.
[0177] S1204: Determine whether the aspect ratio of the character area is within a preset range. If so, execute S1206; if not, execute S1205 first and then S1206.
[0178] S1205: Using a preset background image to fill the background of the character area whose aspect ratio is not within a preset range.
[0179] S1206: Adjust the size of the character area to a preset size.
[0180] S1207: Performing character recognition on characters in a character area in a second image containing characters according to the layout type of the characters through a target detection network.
[0181] An embodiment of the present invention provides an electronic device 1300, Fig.13 As shown, it includes: a memory 1310 and a processor 1320:
[0182] The memory 1310 is used to store program codes used when the terminal device is running;
[0183] The processor 1320 is used to execute the program code to implement the following process:
[0184] Determine the proportion of the character area in the first image containing the character;
[0185] If the proportion of the character area in the first image is less than a preset value, determining the properties of the sliding window corresponding to the proportion range to which the proportion of the character area belongs according to the correspondence between the preset proportion range and the properties of the sliding window; the properties of the sliding window include the size of the sliding window and the moving step length;
[0186] Using the determined sliding window attribute, a plurality of second images are intercepted from the first image, and character recognition is performed based on the plurality of second images.
[0187] Optionally, the processor 1320 is specifically configured to:
[0188] Using a region recognition network, a second image containing characters is recognized from a plurality of second images, and a character region in the recognized second image is marked;
[0189] The preset layout type is compared with the layout of the characters in the second image containing the characters, and the preset layout type with the highest contrast is determined as the layout type of the characters in the second image.
[0190] Optionally, the processor 1320 is specifically configured to:
[0191] Recognize a second image containing characters from a plurality of second images, and determine a character region and a layout type of the characters in the second image containing characters;
[0192] According to the layout type of the characters, character recognition is performed on a character area in the second image containing the characters.
[0193] Optionally, the processor 1320 is specifically configured to: identify a second image containing characters from a plurality of second images and mark a character region in the identified second image through a layout classification neural network, and determine a layout type of characters in the second image containing characters;
[0194] The training process of the layout classification neural network includes:
[0195] Taking a sample image as input, taking a character region and a character layout type in the sample image as output, performing multiple rounds of training on a basic neural network to obtain the layout classification neural network;
[0196] In each round of training, the sample image is input into the basic neural network, and the output result is input into the first loss function to calculate the first loss value. At the same time, the sample image is input into the basic neural network, and the output result is input into the second loss function to calculate the second loss value. According to the first loss value and the second loss value, the parameters in the basic network are adjusted;
[0197] The first loss function is the SmoothL1 loss function, and the second loss function is the GIOU loss function.
[0198] Optionally, the processor 1320 is further configured to:
[0199] If the number of extracted character regions includes multiple ones, and the multiple character regions have overlapping areas in the first image, the multiple character regions are merged.
[0200] Optionally, the processor 1320 is specifically configured to:
[0201] According to the character layout type, the character area is segmented to obtain multiple areas containing single characters;
[0202] Character recognition is performed on each of the multiple regions containing a single character.
[0203] Optionally, the processor 1320 is specifically configured to:
[0204] Extract features from multiple regions containing single characters to obtain multiple feature maps;
[0205] Through the attention model, multiple feature maps are fused to obtain a comprehensive feature map;
[0206] Character recognition is performed according to the comprehensive feature map.
[0207] Optionally, the processor 1320 is specifically configured to: perform character recognition on a character region in the second image containing characters according to a layout type of the characters through a target detection network;
[0208] Among them, the training process of the target detection network includes:
[0209] The sample image and the layout type of the characters in the sample image are taken as input, the characters in the sample image are taken as output, and the basic neural network is trained for multiple rounds to obtain the target detection network.
[0210] Optionally, the processor 1320 is further configured to:
[0211] A preset background image is used to fill the background of the character area whose aspect ratio is not within a preset range, and the size of the filled character area is adjusted to a preset size.
[0212] Optionally, the processor 1320 is specifically used to: if the resolution of the image taken by the camera device is not less than a preset resolution, determine the proportion of the character area in the first image corresponding to the current installation position of the camera device according to the corresponding relationship between the installation position of the camera device and the proportion of the character area taken by the camera device; the first image is taken by the camera device.
[0213] Optionally, the processor 1320 is further configured to:
[0214] If the resolution of the image captured by the camera device is smaller than the preset resolution, the size of the first image is adjusted to a preset recognition size, and character recognition is performed on the resized first image.
[0215] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory including instructions, and the instructions can be executed by the processor 1320 to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0216] The acquisition device may also be an electronic device with communication function. Therefore, in addition to the processor and memory described above, the acquisition device may also be combined with Fig.14As shown, it also includes: a camera unit 1410, a radio frequency (RF) circuit 1420, a wireless fidelity (Wi-Fi) module 1430, a communication interface 1440, an input unit 1450, a display unit 1460, a power supply 1470, a processor 1480, a memory 1490 and other components. Those skilled in the art can understand that Fig.14 The structure of the electronic device shown in the figure does not constitute a limitation on the electronic device. The electronic device provided in the embodiment of the present application may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0217] Combine the following Fig.14 The components of the electronic device 1300 are described in detail:
[0218] The camera unit 1410 is used to realize the camera function of the electronic device 1300. The camera unit 1410 can also realize the scanning function of the electronic device 1300, scan the scanning object (two-dimensional code / barcode), and obtain the image information of the barcode.
[0219] The electronic device 1300 can receive images sent by other devices through the RF circuit 1420 , the Wi-Fi module 1430 , and the communication module of the communication interface 1440 .
[0220] The RF circuit 1420 can be used for receiving and sending data during the communication process. In particular, after receiving the downlink data from the base station, the RF circuit 1420 sends it to the processor 1480 for processing; in addition, the uplink data to be sent is sent to the base station. Generally, the RF circuit 1420 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc.
[0221] In addition, the RF circuit 1420 can also communicate with the network and other electronic devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0222] Wi-Fi technology is a short-range wireless transmission technology. The electronic device 1300 can connect to an access point (AP) through the Wi-Fi module 1430 to access the data network. The Wi-Fi module 1430 can be used for receiving and sending data during the communication process.
[0223] The electronic device 1300 can be physically connected to other electronic devices through the communication interface 1440. Optionally, the communication interface 1440 is connected to the communication interface of the other electronic device through a cable to achieve data transmission between the electronic device 1300 and the other electronic device.
[0224] Since in the embodiment of the present application, the electronic device 1300 can implement communication services and send information to other contacts, the electronic device 1300 needs to have a data transmission function, that is, the electronic device 1300 needs to include a communication module. Fig.14 Communication modules such as the RF circuit 1420, the Wi-Fi module 1430, and the communication interface 1440 are shown, but it is understandable that at least one of the above components or other communication modules (such as a Bluetooth module) for implementing communication exist in the electronic device 1300 to perform data transmission.
[0225] For example, when the electronic device 1300 is a mobile phone, the electronic device 1300 may include the RF circuit 1420 and may also include the Wi-Fi module 1430; when the electronic device 1300 is a computer, the electronic device 1300 may include the communication interface 1440 and may also include the Wi-Fi module 1430; when the electronic device 1300 is a tablet computer, the electronic device 1300 may include the Wi-Fi module.
[0226] The input unit 1450 may be used to receive digital or character information input by a user, and to generate key signal input related to user settings and function control of the electronic device 1300. For example, the user may input the percentage of a character area in an image through the input unit 1450.
[0227] Optionally, the input unit 1450 may include a touch panel 1451 and other input terminals 1452 .
[0228] Among them, the touch panel 1451, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on or near the touch panel 1451 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 1451 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 1480, and can receive and execute commands sent by the processor 1480. In addition, the touch panel 1451 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave.
[0229] Optionally, the other input terminals 1452 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.
[0230] The display unit 1460 may be used to display information input by the user or information provided to the user and various menus of the electronic device 1300. The display unit 1460 is a display system of the electronic device 1300, which is used to present an interface and realize human-computer interaction. For example, the display unit 1460 may display characters obtained through character recognition.
[0231] The display unit 1460 may include a display panel 1461. Optionally, the display panel 1461 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0232] Furthermore, the touch panel 1451 may cover the display panel 1461. When the touch panel 1451 detects a touch operation on or near it, it transmits it to the processor 1480 to determine the type of touch event. Then the processor 1480 provides corresponding visual output on the display panel 1461 according to the type of touch event.
[0233] Although in Fig.14 In the embodiment, the touch panel 1451 and the display panel 1461 are two independent components to realize the input and output functions of the electronic device 1300, but in some embodiments, the touch panel 1451 and the display panel 1461 can be integrated to realize the input and output functions of the electronic device 1300.
[0234] The memory 1490 can be used to store software programs and modules. The processor 1480 executes various functional applications and data processing of the electronic device 1300 by running the software programs and modules stored in the memory 1490. The memory 1490 includes Fig.13 The function of the memory 1310 in.
[0235] Optionally, the memory 1490 may mainly include a program storage area and a data storage area. The program storage area may store an operating system, various application programs (such as communication applications), and a face recognition module, etc.; the data storage area may store data created according to the use of the electronic device (such as various multimedia files such as pictures and video files, and face information templates), etc.
[0236] In addition, the memory 1490 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0237] The processor 1480 is the control center of the electronic device 1300. It connects various components using various interfaces and lines, and executes various functions and processes data of the electronic device 1300 by running or executing software programs and / or modules stored in the memory 1490 and calling data stored in the memory 1490, thereby realizing various services based on the electronic device. The processor 1480 includes Fig.13 The function of processor 1320 in.
[0238] Optionally, the processor 1480 may include one or more processing units. Optionally, the processor 1480 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 1480.
[0239] The electronic device 1300 also includes a power supply 1470 (such as a battery) for supplying power to various components. Optionally, the power supply 1470 can be logically connected to the processor 1480 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.
[0240] An embodiment of the present invention further provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes any one of the character recognition methods described above in the embodiment of the present invention.
[0241] Those skilled in the art will readily appreciate other embodiments of the invention after considering the specification and practicing the invention invented herein. The invention is intended to cover any variations, uses or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not invented by the present invention. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the invention are indicated by the following claims.
[0242] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A character recognition method, characterized in that: include: Determine the proportion of the character area in the first image containing the character; If the proportion of the character area in the first image is less than a preset value, determining the properties of the sliding window corresponding to the proportion range to which the proportion of the character area belongs according to the correspondence between the preset proportion range and the properties of the sliding window; the properties of the sliding window include the size of the sliding window and the moving step length; Using the determined sliding window attribute, intercepting a plurality of second images from the first image, and performing character recognition based on the plurality of second images; Performing character recognition according to the plurality of second images includes: Identify a second image containing characters from a plurality of second images and mark a character region in the identified second image, and determine a layout type of the characters in the second image containing characters; Character recognition is performed on characters in a character area in the second image containing the characters according to the layout type of the characters.
2. The character recognition method according to claim 1, characterized in that: Identifying a second image containing characters from a plurality of second images and marking a character region in the identified second image, and determining a layout type of the characters in the second image containing characters, comprises: Using a region recognition network, a second image containing characters is recognized from a plurality of second images, and a character region in the recognized second image is marked; The preset layout type is compared with the layout of the characters in the second image containing the characters, and the preset layout type with the highest contrast is determined as the layout type of the characters in the second image.
3. The character recognition method according to claim 1, characterized in that: Identifying a second image containing characters from a plurality of second images, and determining a character region and a layout type of the characters in the second image containing characters, comprises: Using a layout classification neural network, a second image containing characters is identified from a plurality of second images, a character region in the identified second image is marked, and a layout type of the characters in the second image containing characters is determined; The training process of the layout classification neural network includes: Taking a sample image as input, taking a character region and a character layout type in the sample image as output, performing multiple rounds of training on a basic neural network to obtain the layout classification neural network; In each round of training, the sample image is input into the basic neural network, and the output result is input into the first loss function to calculate the first loss value. At the same time, the sample image is input into the basic neural network, and the output result is input into the second loss function to calculate the second loss value. According to the first loss value and the second loss value, the parameters in the basic network are adjusted; The first loss function is the SmoothL1 loss function, and the second loss function is the GIOU loss function.
4. The character recognition method according to claim 1, characterized in that: After marking the recognized character region in the second image, and before performing character recognition on the characters in the character region in the second image containing the characters according to the layout type of the characters, the method further includes: If the number of extracted character regions includes multiple ones, and the multiple character regions overlap in the first image, the multiple character regions are merged.
5. The character recognition method according to claim 1, characterized in that: After marking the character region in the recognized second image, and before performing character recognition on the character region in the second image containing the characters according to the layout type of the characters, the method further includes: A preset background image is used to fill the background of the character area whose aspect ratio is not within a preset range, and the size of the filled character area is adjusted to a preset size.
6. The character recognition method according to any one of claims 1 to 5, characterized in that: According to the layout type of the characters, character recognition is performed on a character region in the second image containing the characters, including: According to the character layout type, the character area is segmented to obtain multiple areas containing single characters; Character recognition is performed on each of the multiple regions containing a single character.
7. The character recognition method according to claim 6, characterized in that: Character recognition is performed on multiple regions containing single characters, including: Extract features from multiple regions containing single characters to obtain multiple feature maps; Through the attention model, multiple feature maps are fused to obtain a comprehensive feature map; Character recognition is performed according to the comprehensive feature map.
8. The character recognition method according to any one of claims 1 to 5, characterized in that: According to the layout type of the characters, character recognition is performed on a character region in the second image containing the characters, including: Performing character recognition on a character region in a second image containing characters according to a type of character layout by using an object detection network; Among them, the training process of the target detection network includes: The sample image and the layout type of the characters in the sample image are taken as input, the characters in the sample image are taken as output, and the basic neural network is trained for multiple rounds to obtain the target detection network.
9. The character recognition method according to claim 1, characterized in that: The determining the proportion of the character area in the first image containing the characters comprises: If the resolution of the image taken by the camera device is not less than the preset resolution, the proportion of the character area in the first image corresponding to the current installation position of the camera device is determined based on the correspondence between the installation position of the camera device and the proportion of the character area taken by the camera device; the first image is taken by the camera device.
10. The character recognition method according to claim 9, characterized in that: The method further comprises: If the resolution of the image captured by the camera device is smaller than the preset resolution, the size of the first image is adjusted to a preset recognition size, and character recognition is performed on the resized first image.
11. An electronic device, characterized in that: include: Memory and processor: The memory is used to store program codes used when the electronic device is running; The processor is used to execute the program code to implement the character recognition method according to any one of claims 1 to 10.
12. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the character recognition method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Vehicle type judgment method and vehicle type judgment device
CN103530608A
Character identification method and device
CN106485246A
Non-segmented character positioning and identification method based on deep learning
CN107133616A
Text recognition network training method and optical character recognition method
CN110135423A
DE2108145A1
