Text recognition method, device, electronic device and storage medium
Through the method of semantic segmentation and deflection information adjustment, the accuracy of text detection and recognition in natural scene images is improved, and the problem of reduced text recognition accuracy caused by different shooting angles is solved.
Patent Information
- Application Number
- CN201911134547.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-19
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2039-11-19
AI Technical Summary
The text detection accuracy decreases due to different shooting angles, which in turn reduces the text recognition accuracy in natural scene images.
Obtain multiple target pixels and pixel related information of the text to be detected through semantic segmentation, determine the position of each target pixel and the deflection information of the text, and adjust the angle of the text based on the deflection information, thereby improving the accuracy of text detection and recognition. .
It effectively improves the accuracy of text detection, thereby improving the accuracy of text recognition, especially when the text to be detected in the image to be recognized appears to be angularly rotated.
Smart Images

Figure CN111126140B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a text recognition method, device, electronic equipment and storage medium. Background Art
[0002] Natural scene images are images taken directly from real scenes in life by various shooting devices (such as cameras or mobile phones, etc.) without specific restrictions. The text in natural scene images can provide rich semantic information. In order to recognize the text in natural scene images, the text in natural scene images can be recognized by OCR (Optical Character Recognition) technology.
[0003] Among them, OCR technology includes two cascade steps: text detection and text recognition. Text detection is to locate the position where the text appears, and text recognition is to obtain text information using a recognition algorithm. However, different shooting angles will lead to a reduction in the accuracy of text detection, thereby reducing the accuracy of text recognition. Summary of the invention
[0004] The embodiments of the present invention provide a text recognition method, device, electronic device and storage medium, which can improve the accuracy of text detection and thus improve the accuracy of text recognition.
[0005] An embodiment of the present invention provides a text recognition method, comprising:
[0006] Acquire an image to be recognized, wherein the image to be recognized includes text to be detected;
[0007] Performing semantic segmentation on the image to be recognized to obtain a plurality of target pixel points corresponding to the text to be detected and pixel association information corresponding to each target pixel point;
[0008] Based on the pixel association information and the plurality of target pixels, determining the position of each target pixel in the image to be identified and the deflection information of the text to be detected;
[0009] Adjusting the angle of the text to be detected according to the deflection information;
[0010] Perform text recognition on the adjusted text to be detected to obtain a text recognition result.
[0011] Accordingly, an embodiment of the present invention further provides a text recognition device, comprising:
[0012] An acquisition module, used for acquiring an image to be recognized, wherein the image to be recognized includes text to be detected;
[0013] A segmentation module is used to perform semantic segmentation on the image to be identified to obtain a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel;
[0014] A determination module, used to determine the position of each target pixel point in the image to be identified and the deflection information of the text to be detected based on the pixel association information and the multiple target pixel points;
[0015] An adjustment module, used for adjusting the angle of the text to be detected according to the deflection information;
[0016] The recognition module is used to perform text recognition on the adjusted text to be detected to obtain a text recognition result.
[0017] Optionally, in some embodiments of the present invention, the adjustment module includes:
[0018] A construction unit, configured to construct a text area corresponding to the to-be-detected text in the to-be-recognized image according to a plurality of target pixels and pixel association information corresponding to each target pixel;
[0019] An adjustment unit is used to adjust the angle of the text area according to the deflection information.
[0020] Optionally, in some embodiments of the present invention, the adjustment unit includes:
[0021] An extraction subunit, configured to extract angle information of the text area from the deflection information, wherein the angle information includes an angle prediction value corresponding to each pixel point in the text area;
[0022] A processing subunit, used for performing weighted average processing on the multiple angle prediction values to obtain the predicted deflection angle corresponding to the text area;
[0023] The adjusting subunit is used to adjust the angle of the text area based on the predicted deflection angle.
[0024] Optionally, in some embodiments of the present invention, the adjusting subunit is specifically used for:
[0025] Obtain the direction vector corresponding to each edge of the text area;
[0026] Constructing a unit vector corresponding to the predicted deflection angle;
[0027] Calculate the product of the unit vector and each direction vector respectively;
[0028] According to the calculation result, a target vector is determined from a plurality of direction vectors;
[0029] The angle of the text box is adjusted using the target vector and the predicted deflection angle.
[0030] Optionally, in some embodiments of the present invention, the adjusting subunit is specifically used for:
[0031] Obtaining coordinates corresponding to each vertex of the text area;
[0032] Based on the predicted deflection angle, coordinate transformation is performed on the coordinates corresponding to each vertex;
[0033] The angle of the text area is adjusted according to the transformed coordinates.
[0034] Optionally, in some embodiments of the present invention, the construction unit includes:
[0035] A first acquisition subunit is used to acquire a reference pixel corresponding to each target pixel based on pixel association information corresponding to each target pixel;
[0036] A second acquisition subunit is used to acquire the position information of the target pixel point in the text to be detected;
[0037] The construction subunit is used to construct a text area corresponding to the text to be detected on the image to be recognized according to the position information and the corresponding reference pixel points.
[0038] Optionally, in some embodiments of the present invention, the determining module is specifically used to:
[0039] Determine the position of each target pixel in the text to be detected according to the distribution of the multiple target pixels in the image to be recognized;
[0040] Based on the pixel association information, the angle corresponding to each pixel is predicted by the angle prediction sub-model in the preset text detection model to obtain the angle prediction value corresponding to each pixel;
[0041] The deflection information of the text to be detected is constructed according to the multiple angle prediction values.
[0042] Optionally, in some embodiments of the present invention, the segmentation module is specifically used to:
[0043] Extracting features of the image to be identified to obtain a text feature image corresponding to the image to be identified;
[0044] Classify the pixels in the text feature image by using the first classification sub-model in the preset text detection model to obtain a pixel prediction value corresponding to each pixel, wherein the pixel prediction value refers to the probability that each pixel in the text feature image belongs to the area where the text to be detected is located;
[0045] Based on the pixel prediction value, determining a plurality of target pixel points corresponding to the text to be detected;
[0046] Classify multiple target pixels through the second classification sub-model in the preset text detection model to obtain the classification confidence corresponding to each target pixel, where the classification confidence refers to the probability that the target pixel belongs to the text to be detected;
[0047] According to the classification confidence, pixel association information corresponding to each target pixel is constructed.
[0048] After acquiring an image to be recognized, the embodiment of the present invention includes a text to be detected, and semantic segmentation is performed on the image to be recognized to obtain multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel. Then, based on the pixel association information and multiple target pixels, the position of each target pixel in the image to be recognized and the deflection information of the text to be detected are determined. Then, the angle of the text to be detected is adjusted according to the deflection information. Finally, text recognition is performed on the adjusted text to be detected to obtain a text recognition result. Therefore, the scheme can effectively improve the accuracy of text detection, and thus improve the accuracy of text recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0050] Figure 1a is a scene schematic diagram of a text recognition method provided by an embodiment of the present invention;
[0051] Figure 1b is a flowchart of a text recognition method provided by an embodiment of the present invention;
[0052] Figure 1c It is a schematic diagram of a scenario of extracting features of an image to be recognized in a text recognition method provided by an embodiment of the present invention;
[0053] Figure 1d 8 is a schematic diagram of the 8-neighborhood of a target pixel in the text recognition method provided by an embodiment of the present invention;
[0054] Figure 1e is a schematic diagram of a text line deviating from a preset direction in a text recognition method provided by an embodiment of the present invention;
[0055] Figure 1fis another scenario schematic diagram of the text recognition method provided by an embodiment of the present invention;
[0056] Figure 1g is a schematic diagram of adjusting the angle of a text box in a text recognition method provided by an embodiment of the present invention;
[0057] Figure 2 is another flowchart of the text recognition method provided by an embodiment of the present invention;
[0058] Figure 3 is a structural schematic diagram of a text recognition device provided by an embodiment of the present invention;
[0059] Figure 4 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0061] Embodiments of the present invention provide a text recognition method, device, electronic device and storage medium.
[0062] The text recognition device may be integrated into a terminal, which may include a mobile phone, a tablet computer or a personal computer (PC).
[0063] For example, see Figure 1a The text recognition device is integrated on a mobile phone, which may include a camera and a display screen. When a user takes a picture of a food menu through a camera, the mobile phone can obtain an image to be recognized corresponding to the menu through the camera, wherein the image to be recognized includes the text content of the menu (i.e., the text to be detected). Then, the mobile phone performs semantic segmentation on the image to be recognized to obtain multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel. Then, the mobile phone can determine the position of each target pixel in the image to be recognized and the deflection information of the text to be detected based on the pixel association information and the multiple target pixels. Then, the mobile phone adjusts the angle of the text to be detected according to the deflection information. Finally, the mobile phone performs text recognition on the adjusted text to be detected to obtain a text recognition result. For example, the mobile phone can recognize the name of the dish on the menu, etc.
[0064] Since the scheme is based on pixel association information and multiple target pixels, the position of each target pixel in the image to be identified and the deflection information of the text to be detected are determined, and then the angle of the text to be detected is adjusted according to the deflection information, that is, the angle of the text to be detected is corrected through the deflection information, which facilitates the subsequent recognition of the text to be detected. In other words, the scheme can improve the accuracy of text detection, thereby improving the accuracy of text recognition.
[0065] It should be noted that the order of description of the following embodiments is not intended to limit the priority order of the embodiments.
[0066] A text recognition method comprises: obtaining an image to be recognized, the image to be recognized including text to be detected, performing semantic segmentation on the image to be recognized, obtaining a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel, determining the position of each target pixel in the image to be recognized and deflection information of the text to be detected based on the pixel association information and the plurality of target pixels, adjusting the angle of the text to be detected according to the deflection information, performing text recognition on the adjusted text to be detected, and obtaining a text recognition result.
[0067] See also Figure 1b , Figure 1b The following is a flow chart of a text recognition method provided by an embodiment of the present invention. The specific flow of the text recognition method may be as follows:
[0068] 101. Obtain an image to be identified.
[0069] The image to be identified includes text to be detected. The image to be identified may be pre-stored locally, or obtained by accessing a network interface, or obtained by real-time photography by a camera, depending on actual conditions.
[0070] 102. Perform semantic segmentation on the image to be recognized to obtain multiple target pixel points corresponding to the text to be detected and pixel association information corresponding to each target pixel point.
[0071] Among them, the semantic segmentation of the image is to perform pixel-level recognition and segmentation to obtain the category information and precise location information of the objects in the image. It can be understood that in the embodiment of the present invention, semantic segmentation is performed on the image to be recognized, and the pixel points corresponding to the text to be detected, that is, the target pixel points, and the pixel association information corresponding to the target pixel points can be obtained.
[0072] Pixel association information can be understood as pixel neighborhood information. It should be noted that in image processing, neighborhood refers to a set of pixels adjacent to a certain pixel, reflecting the spatial relationship between pixels. The pixel association information can be pixel 4 neighborhood information, pixel diagonal neighborhood information or pixel 8 neighborhood information. The pixel 8 neighborhood information can be considered as the information obtained by fusing the pixel 4 neighborhood information with the pixel diagonal neighborhood information. When a pixel point is located at the boundary of the image, it can be considered that some neighborhood points corresponding to the pixel point fall outside the image.
[0073] For example, the pixels of the image to be identified can be classified by the first classification sub-model in the preset text detection model, so as to determine the pixels belonging to the area where the text to be detected is located and the pixels of the background area. In an embodiment of the present invention, the background area can be considered as an area other than the text to be detected, and the pixels of the image to be identified can be classified by the second classification sub-model in the preset text detection model to obtain the probability that each target pixel belongs to the text to be detected. That is, in some embodiments, the step of "semantically segmenting the image to be identified to obtain multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel" can specifically include:
[0074] (11) extracting features of the image to be identified to obtain a text feature image corresponding to the image to be identified;
[0075] (12) classifying the pixels in the text feature image by using the first classification sub-model in the preset text detection model to obtain a pixel prediction value corresponding to each pixel;
[0076] (13) determining a plurality of target pixel points corresponding to the text to be detected based on the pixel prediction values;
[0077] (14) classifying a plurality of target pixels using a second classification sub-model in a preset text detection model to obtain a classification confidence corresponding to each target pixel;
[0078] (15) Based on the classification confidence, construct the pixel association information corresponding to each target pixel.
[0079] Among them, the pixel prediction value refers to the probability that each pixel in the text feature image belongs to the area where the text to be detected is located, and the classification confidence refers to the probability that the target pixel belongs to the text to be detected. First, a convolutional neural network such as FPN (Feature Pyramid Network) feature pyramid network can be used. Figure 1cAs shown in the figure, feature extraction is performed on the image to be identified. The image to be identified first passes through a convolutional neural network composed of nine convolutional layers to output a feature map of 512 layers and a size of 32*32. Then, the feature map is input into FPN. After three stages of upsampling, a text feature map of 32 layers and a size of 256*256 is finally output. Subsequently, the pixels in the text feature image are classified by the first classification sub-model in the preset text detection model to obtain the pixel prediction value corresponding to each pixel. Then, based on the pixel prediction value, multiple target pixels corresponding to the text to be detected are determined. Then, the multiple target pixels are classified by the second classification sub-model in the preset text detection model to obtain the classification confidence corresponding to each target pixel. Finally, according to the classification confidence, it can be determined whether the target pixel has a connection relationship with the 8 neighborhoods. The 8 neighborhoods refer to the upper neighborhood, the lower neighborhood, the left neighborhood, the right neighborhood and the diagonal neighborhood. Figure 1d As shown, the pixel association information corresponding to the target pixel point is then constructed based on these connection relationships.
[0080] The text detection model may be pre-established, and the text detection model may be trained by a plurality of images containing text and annotated with pixel types, that is, in some embodiments, it may further include:
[0081] (21) Collecting training sample sets;
[0082] (22) determining the sample currently being processed from the training sample set to obtain the current processing object;
[0083] (23) Inputting the current processing object into the detection model to obtain the pixel prediction value of the current processing object;
[0084] (24) Obtain the true pixel value of the current processing object;
[0085] (25) The detection model is converged based on the true pixel value and the pixel prediction value to obtain the text detection model.
[0086] Convolution layer: mainly used for feature extraction of input images (such as training samples or images to be recognized), wherein the convolution kernel size can be determined according to the actual application. For example, the convolution kernel sizes from the first convolution layer to the fourth convolution layer can be (7, 7), (5, 5), (3, 3), (3, 3) respectively; optionally, in order to reduce the complexity of calculation and improve the calculation efficiency, in this embodiment, the convolution kernel sizes of the four convolution layers can be set to (3, 3), the activation function all adopts "relu (rectified linear unit)", and the padding (padding refers to the space between the element border and the element content defined by the attribute) mode is set to "same". The "same" filling mode can be simply understood as filling the edge with 0, and the number of 0s on the left (top) is the same as or one less than the number of 0s on the right (bottom). Optionally, the convolutional layers can be directly connected to each other to speed up the network convergence. In order to further reduce the amount of calculation, downsampling (pooling) operations can be performed in all layers from the second to the fourth convolutional layers or in any 1 to 2 layers. The downsampling operation is basically the same as the convolution operation, except that the downsampled convolution kernel only takes the maximum value (maxpooling) or the average value (average pooling) of the corresponding position. For the convenience of description, in the embodiments of the present invention, downsampling operations are performed in the second convolutional layer and the third convolutional layer, and the downsampling operation is specifically max pooling. For example, the downsampling operation is described.
[0087] It should be noted that, for the convenience of description, in an embodiment of the present invention, the layer where the activation function is located and the downsampling layer (also called the pooling layer) are both included in the convolution layer. It should be understood that the structure can also be considered to include a convolution layer, a layer where the activation function is located, a downsampling layer (i.e., a pooling layer) and a fully connected layer. Of course, it can also include an input layer for inputting data and an output layer for outputting data, which will not be repeated here.
[0088] Fully connected layer: It can map the learned features to the sample label space. It mainly plays the role of "classifier" in the entire convolutional neural network. Each node of the fully connected layer is connected to all nodes output by the previous layer (such as the downsampling layer in the convolutional layer). Among them, a node in the fully connected layer is called a neuron in the fully connected layer. The number of neurons in the fully connected layer can be determined according to the needs of the actual application. For example, in this text detection model, the number of neurons in the fully connected layer can be set to 512, or 128, etc. Similar to the convolutional layer, in the fully connected layer, nonlinear factors can be added by adding activation functions. For example, the activation function sigmoid (S-type function) can be added.
[0089] For example, specifically, multiple images containing text and marked with pixel types can be collected through multiple channels. These multiple images can include images corresponding to multiple different texts, or images corresponding to the same text at different angles. Then, one image is input into the first classification sub-model of the detection model. Through the first classification sub-model, the pixels in the image are classified to obtain the pixel prediction value corresponding to each pixel. Then, the true pixel value of the image is obtained. Finally, the first classification sub-model is converged based on the true pixel value and the pixel prediction value to obtain the first classification sub-model of the text detection model. Similarly, the same method can be used for the second classification sub-model of the text detection model, which will not be repeated here.
[0090] 103. Based on the pixel association information and the multiple target pixels, determine the position of each target pixel in the image to be recognized and the deflection information of the text to be detected.
[0091] The deflection information of the text to be detected may be information that the text line where the text to be detected is located deviates from a preset direction, for example, Figure 1e As shown, taking the direction of text line A as the preset direction, when other text lines are not parallel to text line A and the angle between other text lines and text line A is not 0 degrees, it can be considered that they deviate from the preset direction, and the deflection information corresponding to the deviated text line can be generated according to the angle between the deviated text line and text line A.
[0092] For example, specifically, the position of the target pixel in the to-be-detected text can be determined based on the distribution information of the target pixel in the to-be-detected image, and then, based on the pixel association relationship, the angle corresponding to each pixel can be predicted by the angle prediction submodel in the preset text detection model to obtain the angle prediction value corresponding to each pixel, and finally, the deflection information of the to-be-detected text can be constructed based on the multiple angle prediction values. That is, in some embodiments, the step of "determining the position of each target pixel in the to-be-detected image and the deflection information of the to-be-detected text based on the pixel association information and the multiple target pixels" can specifically include:
[0093] (31) determining the position of each target pixel in the text to be detected according to the distribution of the plurality of target pixels in the image to be identified;
[0094] (32) Based on the pixel association information, the angle corresponding to each pixel is predicted by the angle prediction sub-model in the preset text detection model to obtain the angle prediction value corresponding to each pixel;
[0095] (33) Construct the deflection information of the text to be detected based on multiple angle prediction values.
[0096] Among them, the angle prediction value refers to the probability that the text to be detected where the target pixel point is located is deflected. For example, please refer to Figure 1f , the text to be detected is "It is recommended to use code scanning payment", the preset direction is the horizontal direction. From Figure 1f , it can be seen that the angles of the 8 characters "推 (tuī)", "荐 (jiàn)", "使 (shǐ)", "用 (yòng)", "扫 (sǎo)", "码 (mǎ)", "支 (zhī)" and "付 (fù)" deviating from the preset direction are all different. Therefore, the angle prediction sub-model in the preset text detection model can be used to predict the angles corresponding to the pixel points of each character respectively, and obtain the angle prediction value corresponding to each pixel point. Then, the deflection information of the text to be detected can be constructed based on these angle prediction values. For example, the deflection angle corresponding to each character can be calculated, and then the deflection information of the text to be detected can be constructed through the deflection angles of each character, and then step 104 is executed.
[0097] 104. Adjust the angle of the text to be detected according to the deflection information.
[0098] When determining the deflection information of the text to be detected, based on this deflection information, the angle of the text to be detected can be adjusted. For example, if the deflection information indicates that the text to be detected deviates from the preset direction by 30 degrees, then the text to be detected can be rotated by 30 degrees so that the included angle between the text to be detected and the preset direction is 0 degree.
[0099] Furthermore, the text area corresponding to the text to be detected can be extracted, and the angle of the text area can be adjusted through the deflection information. That is, in some embodiments, the step of "adjusting the angle of the text to be detected according to the deflection information" may specifically include:
[0100] (41) Construct the text area corresponding to the text to be detected in the image to be recognized according to multiple target pixel points and the pixel association information corresponding to each target pixel point;
[0101] (42) Adjust the angle of the text area through the deflection information.
[0102] For example, specifically, based on the pixel association information corresponding to each target pixel point, 8 reference pixel points corresponding to the target pixel point can be obtained. Then, the position information of the target pixel point in the text to be detected is obtained. Finally, according to the position information and the corresponding reference pixel points, the text area corresponding to the text to be detected is constructed on the image to be recognized. That is, in some embodiments, the step of "constructing the text area corresponding to the text to be detected in the image to be recognized according to multiple target pixel points and the pixel association information corresponding to each target pixel point" includes:
[0103] (51) Obtain the reference pixel points corresponding to each target pixel point based on the pixel association information corresponding to each target pixel point;
[0104] (52) Obtaining the position information of the target pixel in the text to be detected;
[0105] (53) Based on the position information and the corresponding reference pixel points, a text area corresponding to the text to be detected is constructed on the image to be recognized.
[0106] Furthermore, based on the 8-neighborhood information of the target pixel point, the pixel points within a preset range can be obtained as the reference pixel points corresponding to the target pixel point. That is, in some embodiments, the step of "obtaining the reference pixel points corresponding to each target pixel point based on the pixel association information corresponding to each target pixel point" can specifically include: taking the target pixel point as the center, obtaining the pixel points within the preset range according to the pixel association information corresponding to the target pixel point, and obtaining the reference pixel point corresponding to the target pixel point.
[0107] In addition, the angle information of the text area can be extracted from the deflection information. The angle information can include the angle prediction value corresponding to each pixel in the text area. Then, the angle of the text area is adjusted based on the angle prediction values. That is, in some embodiments, the step of "adjusting the angle of the text area by using the deflection information" can specifically include:
[0108] (61) extracting angle information of the text area from the deflection information, where the angle information includes an angle prediction value corresponding to each pixel point in the text area;
[0109] (62) performing weighted average processing on multiple angle prediction values to obtain a predicted deflection angle corresponding to the text area;
[0110] (63) The angle of the text region is adjusted based on the predicted deflection angle.
[0111] For example, the average value of multiple angle prediction values may be taken, and the following formula may be used:
[0112]
[0113] Among them, Box_angle is the predicted deflection angle corresponding to the text area, P is the angle prediction value, Box_loc is the angle information of the text area, and N is the number of target pixels. When the predicted deflection angle corresponding to the text area is calculated, the angle of the text area can be adjusted by the predicted deflection angle.
[0114] It should be noted that there are two ways to adjust the angle of the text area by predicting the deflection angle.
[0115] The first method is to obtain the coordinates corresponding to each vertex of the text area, and then calculate the sine value corresponding to the predicted deflection angle and the cosine value corresponding to the predicted deflection angle, and transform the coordinates corresponding to each vertex by using the sine value and the cosine value. Finally, the angle of the text area is adjusted according to the transformed coordinates. That is, in some embodiments, the step of "adjusting the angle of the text area based on the predicted deflection angle" may specifically include:
[0116] (71) Obtain the coordinates corresponding to each vertex in the text area;
[0117] (72) Based on the predicted deflection angle, coordinate transformation is performed on the coordinates corresponding to each vertex;
[0118] (73) Adjust the angle of the text area according to the transformed coordinates.
[0119] The second method: the direction vector corresponding to each edge of the text area can be obtained, and then the unit vector corresponding to the predicted deflection angle is constructed, and then the product of the unit vector and each direction vector is calculated respectively, and then the target vector is determined from the multiple direction vectors according to the calculation results, and finally, the angle of the text box is adjusted according to the target vector and the predicted deflection angle. That is, in some embodiments, the step of "adjusting the angle of the text area based on the predicted deflection angle" can specifically include:
[0120] (81) Obtain the direction vector corresponding to each edge of the text area;
[0121] (82) constructing a unit vector corresponding to the predicted deflection angle;
[0122] (83) Calculate the product of the unit vector and each direction vector respectively;
[0123] (84) determining a target vector from a plurality of direction vectors according to the calculation result;
[0124] (85) The angle of the text box is adjusted using the target vector and the predicted deflection angle.
[0125] For example, see Figure 1g , the text area is a rectangular area, which includes vertices A, B, C and D. The direction vector ab of the AB side, the direction vector cd of the CD side, the direction vector bc of the BC side and the direction vector da corresponding to the DA side are obtained respectively. Then, the unit vector h corresponding to the predicted deflection angle is constructed, and the product of the unit vector and each direction vector is calculated respectively. From Figure 1gIt can be seen that the product of the direction vector ab and the unit vector is the largest, so the direction vector ab can be determined as the target vector. Then, the starting point of the target vector can be obtained, and the starting point of the target vector can be transformed by predicting the deflection angle. Then, according to the length of each side of the text area, the adjusted text area is constructed with the starting point of the target vector. It should be noted that the starting point of the target vector can be determined by detecting the orientation of the font in the text to be detected, as shown in Figure 1g It can be seen from the figure that point A is the starting point of the target vector. After adjusting the angle of the text box, step 105 can be executed.
[0126] 105. Perform text recognition on the adjusted text to be detected to obtain a text recognition result.
[0127] For example, specifically, the adjusted text to be detected may be subjected to text recognition by using an OCR (Optical Character Recognition) technology to obtain a text recognition result.
[0128] After acquiring an image to be recognized, the embodiment of the present invention includes a text to be detected, and semantic segmentation is performed on the image to be recognized to obtain multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel. Then, based on the pixel association information and the multiple target pixels, the position of each target pixel in the image to be recognized and the deflection information of the text to be detected are determined. Then, the angle of the text to be detected is adjusted according to the deflection information. Finally, text recognition is performed on the adjusted text to be detected to obtain a text recognition result. Compared with the existing text recognition scheme, the text recognition method of the present invention can adjust the angle of the text to be detected according to the deflection information of the text to be detected. When the text to be detected in the image to be recognized rotates at an angle, the deflection information of the text to be detected can be determined based on the pixel association information and the multiple target pixels. Then, the angle of the text to be detected is adjusted according to the deflection information. Therefore, the scheme can effectively improve the accuracy of text detection, thereby improving the accuracy of text recognition.
[0129] The method described in the embodiment will be further described in detail below with examples.
[0130] In this embodiment, the text recognition device is specifically integrated in a terminal as an example for description.
[0131] See also Figure 2 , a text recognition method, the specific process can be as follows:
[0132] 201. The terminal obtains an image to be recognized.
[0133] Among them, the image to be identified includes the text to be detected. The image to be identified can be pre-stored locally, or obtained by the terminal through accessing the network interface, or obtained by real-time shooting by the terminal's camera, depending on the actual situation.
[0134] 202. The terminal performs semantic segmentation on the image to be recognized to obtain a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel.
[0135] For example, the terminal can classify the pixels of the image to be recognized through the first classification submodel in the preset text detection model, so as to determine the pixels belonging to the area where the text to be detected is located and the pixels in the background area, and can classify the pixels of the image to be recognized through the second classification submodel in the preset text detection model to obtain the probability that each target pixel belongs to the text to be detected.
[0136] 203. The terminal determines the position of each target pixel in the image to be recognized and the deflection information of the text to be detected based on the pixel association information and the multiple target pixels.
[0137] For example, the terminal can determine the position of the target pixel in the text to be detected based on the distribution information of the target pixel in the image to be identified. Then, the terminal can predict the angle corresponding to each pixel based on the pixel association relationship through the angle prediction submodel in the preset text detection model to obtain the angle prediction value corresponding to each pixel. Finally, the terminal constructs the deflection information of the text to be detected based on multiple angle prediction values.
[0138] 204. The terminal adjusts the angle of the text to be detected according to the deflection information.
[0139] For example, specifically, the terminal obtains the 8 reference pixels corresponding to the target pixel based on the pixel association information corresponding to each target pixel, and then obtains the position information of the target pixel in the text to be detected. Then, the terminal can construct a text area corresponding to the text to be detected on the image to be identified based on the position information and the corresponding reference pixels. Then, the terminal can extract the angle information of the text area from the deflection information, and the angle information may include the angle prediction value corresponding to each pixel in the text area. Then, the angle of the text area is adjusted based on these angle prediction values.
[0140] 205. The terminal performs text recognition on the adjusted text to be detected to obtain a text recognition result.
[0141] For example, specifically, the terminal may perform text recognition on the adjusted text to be detected by using an OCR (Optical Character Recognition) technology to obtain a text recognition result.
[0142] After the terminal of the embodiment of the present invention obtains the image to be recognized, the image to be recognized includes the text to be detected, and the terminal performs semantic segmentation on the image to be recognized to obtain multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel. Then, based on the pixel association information and the multiple target pixels, the terminal determines the position of each target pixel in the image to be recognized and the deflection information of the text to be detected. Then, the terminal adjusts the angle of the text to be detected according to the deflection information. Finally, the terminal performs text recognition on the adjusted text to be detected to obtain a text recognition result. Compared with the existing text recognition scheme, the terminal of the present invention can adjust the angle of the text to be detected according to the deflection information of the text to be detected. When the text to be detected in the image to be recognized rotates at an angle, the terminal can determine the deflection information of the text to be detected based on the pixel association information and the multiple target pixels. Then, the terminal can adjust the angle of the text to be detected according to the deflection information. Therefore, the scheme can effectively improve the accuracy of text detection, thereby improving the accuracy of text recognition.
[0143] To facilitate understanding of the text recognition method provided by an embodiment of the present invention, a QR code scanning payment scenario is used as an example for explanation. First, a user captures an image of a QR code through a camera of a mobile phone. The image includes a QR code and text content (i.e., text to be detected). The mobile phone can perform feature extraction on the image through a preset pyramid model to obtain a feature image corresponding to the image. Then, the mobile phone can perform semantic segmentation on the feature image using a preset text detection model to obtain pixel-level text classification information corresponding to the feature image, connection information of pixel-level 8 neighborhoods, and angle information. The pixel-level text classification information is used to classify pixels in the feature image to obtain pixels corresponding to the text area and pixels corresponding to the background area. The connection information of pixel-level 8 neighborhoods is used to classify pixels in the text area. The pixel of the 8-neighborhood judgment is performed, and the angle information is used to judge the rotation angle of the text line to which the current pixel belongs. It should be noted that the preset text detection model includes a pixel classification branch, an 8-neighborhood classification branch and an angle branch. The three branches can be composed of a three-layer convolutional network. The number of convolution kernels of the pixel classification branch and the 8-neighborhood classification branch are two, and the number of convolution kernels of the angle branch is one. The pixel classification branch is connected to the softmax and Crossentropy branches to calculate the classification loss, the 8-neighborhood classification branch is connected to the softmax and Crossentropy branches to calculate the classification loss, and the angle branch is connected to the sigmoid and Euclidean distance loss function to calculate the regression loss. The overall loss function of the network is composed of three branches, as follows:
[0144] L(p cls ,p link ,p angle ,g cls ,g link ,g angle )=L cls (p cls ,g cls )+[g cls >0]L link (p link ,g link )
[0145] +[g cls >0]L angle (p angle ,g angle )
[0146] Among them, g cls ,g link ,g angle are the true values of the classification, 8-domain and angle branches, respectively, cls ,p link ,p angle is the corresponding predicted value, L cls and Llink is the standard multi-class cross entropy loss, L angle is the Euclidean distance loss function.
[0147] Subsequently, in the next stage, first, based on the pixel-level text classification information and the connection information of the pixel-level 8-neighborhood, the classification branch set and the 8-neighborhood branch set can be obtained, and then the Disjoint Set Data Structure method is used to connect them to obtain a connected component (CCs) set. Each element in the set represents the text to be detected. By taking the minimum outer rectangle of the CCs set, the coordinate information of the four corners of the text to be detected can be obtained, and the text area corresponding to the text to be detected is constructed according to the coordinate information, and then the predicted rotation angle of the text to be detected is calculated. Finally, the angle of the text area is adjusted by the predicted rotation angle.
[0148] In order to better implement the text recognition method of the embodiment of the present invention, the embodiment of the present invention also provides a text recognition device based on the above (referred to as recognition device). The meanings of the terms are the same as those in the above text recognition method, and the specific implementation details can refer to the description in the method embodiment.
[0149] See also Figure 3 , Figure 3 The schematic diagram of the structure of the text recognition device provided by the embodiment of the present invention, wherein the processing device may include an acquisition module 301, a segmentation module 302, a determination module 303, an adjustment module 304 and a recognition module 305, which may be specifically as follows:
[0150] The acquisition module 301 is used to acquire the image to be recognized.
[0151] The image to be identified includes text to be detected, and the image to be identified may be pre-stored locally, or may be obtained by the acquisition module 301 by accessing a network interface.
[0152] The segmentation module 302 is used to perform semantic segmentation on the image to be recognized, and obtain multiple target pixel points corresponding to the text to be detected and pixel association information corresponding to each target pixel point.
[0153] For example, the segmentation module 302 can classify the pixels of the image to be identified by using the first classification sub-model in the preset text detection model, thereby determining the pixels belonging to the area where the text to be detected is located and the pixels of the background area. In addition, the segmentation module 302 can classify the pixels of the image to be identified by using the second classification sub-model in the preset text detection model, and obtain the probability that each target pixel belongs to the text to be detected.
[0154] Optionally, in some embodiments, the segmentation module 302 can be specifically used to: extract features from the image to be identified to obtain a text feature image corresponding to the image to be identified; classify the pixels in the text feature image through a first classification sub-model in a preset text detection model to obtain a pixel prediction value corresponding to each pixel, where the pixel prediction value refers to the probability that each pixel in the text feature image belongs to the area where the text to be detected is located; based on the pixel prediction value, determine multiple target pixels corresponding to the text to be detected; classify the multiple target pixels through a second classification sub-model in the preset text detection model to obtain a classification confidence corresponding to each target pixel, where the classification confidence refers to the probability that the target pixel belongs to the text to be detected; and construct pixel association information corresponding to each target pixel based on the classification confidence.
[0155] The determination module 303 is used to determine the position of each target pixel in the image to be recognized and the deflection information of the text to be detected based on the pixel association information and the multiple target pixels.
[0156] For example, the determination module 303 can determine the position of the target pixel in the to-be-detected text according to the distribution information of the target pixel in the to-be-detected image. Then, the determination module 303 can predict the angle corresponding to each pixel through the angle prediction submodel in the preset text detection model based on the pixel association relationship to obtain the angle prediction value corresponding to each pixel. Finally, the determination module 303 constructs the deflection information of the to-be-detected text according to the multiple angle prediction values.
[0157] Optionally, in some embodiments, the determination module 303 can be specifically used to: determine the position of each target pixel in the text to be detected according to the distribution of multiple target pixel points in the image to be identified, predict the angle corresponding to each pixel through the angle prediction sub-model in the preset text detection model based on pixel association information, obtain the angle prediction value corresponding to each pixel, and construct the deflection information of the text to be detected according to the multiple angle prediction values.
[0158] The adjustment module 304 is used to adjust the angle of the text to be detected according to the deflection information.
[0159] For example, specifically, the adjustment module 304 obtains the 8 reference pixels corresponding to the target pixel based on the pixel association information corresponding to each target pixel, and then obtains the position information of the target pixel in the text to be detected. Then, the adjustment module 304 can construct a text area corresponding to the text to be detected on the image to be identified based on the position information and the corresponding reference pixels. Then, the adjustment module 304 can extract the angle information of the text area from the deflection information, and the angle information may include the angle prediction value corresponding to each pixel in the text area. Then, the angle of the text area is adjusted based on these angle prediction values.
[0160] Optionally, in some embodiments, the adjustment module 304 may specifically include:
[0161] A construction unit, used to construct a text area corresponding to the text to be detected in the image to be recognized according to the multiple target pixels and the pixel association information corresponding to each target pixel;
[0162] The adjustment unit is used to adjust the angle of the text area through the deflection information.
[0163] Optionally, in some embodiments, the construction unit may specifically include:
[0164] A first acquisition subunit is used to acquire a reference pixel corresponding to each target pixel based on pixel association information corresponding to each target pixel;
[0165] The second acquisition subunit is used to acquire the position information of the target pixel point in the text to be detected;
[0166] The construction subunit is used to construct a text area corresponding to the text to be detected on the image to be recognized according to the position information and the corresponding reference pixel points.
[0167] Optionally, in some embodiments, the adjusting unit includes:
[0168] An extraction subunit, used to extract angle information of the text area from the deflection information, where the angle information includes an angle prediction value corresponding to each pixel point in the text area;
[0169] A processing subunit, used for performing weighted average processing on multiple angle prediction values to obtain a predicted deflection angle corresponding to the text area;
[0170] The adjustment subunit is used to adjust the angle of the text area based on the predicted deflection angle.
[0171] Optionally, in some embodiments, the adjustment subunit can be specifically used to: obtain the direction vector corresponding to each edge of the text area, construct a unit vector corresponding to the predicted deflection angle, respectively calculate the product of the unit vector and each direction vector, determine the target vector from multiple direction vectors based on the calculation results, and adjust the angle of the text box through the target vector and the predicted deflection angle.
[0172] Optionally, in some embodiments, the adjustment subunit may be specifically used to: obtain coordinates corresponding to each vertex of the text area, perform coordinate transformation on the coordinates corresponding to each vertex based on the predicted deflection angle, and adjust the angle of the text area according to the transformed coordinates.
[0173] The recognition module 305 is used to perform text recognition on the adjusted text to be detected to obtain a text recognition result.
[0174] After the acquisition module 301 of the embodiment of the present invention acquires the image to be recognized, the image to be recognized includes the text to be detected, the segmentation module 302 performs semantic segmentation on the image to be recognized, obtains multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel, then the determination module 303 determines the position of each target pixel in the image to be recognized and the deflection information of the text to be detected based on the pixel association information and the multiple target pixels, then the adjustment module 304 adjusts the angle of the text to be detected according to the deflection information, and finally, the recognition module 305 performs text recognition on the adjusted text to be detected to obtain a text recognition result. Compared with the existing text recognition scheme, the adjustment module 304 of the present invention can adjust the angle of the text to be detected according to the deflection information of the text to be detected, when the text to be detected in the image to be recognized rotates at an angle, the terminal can determine the deflection information of the text to be detected based on the pixel association information and the multiple target pixels, then the terminal can adjust the angle of the text to be detected according to the deflection information, therefore, the scheme can effectively improve the accuracy of text detection, thereby improving the accuracy of text recognition.
[0175] In addition, an embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:
[0176] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 4 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0177] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data, thereby performing overall detection of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0178] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 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. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0179] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0180] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0181] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:
[0182] An image to be recognized is obtained, the image to be recognized includes a text to be detected, semantic segmentation is performed on the image to be recognized, a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel are obtained, the position of each target pixel in the image to be recognized and the deflection information of the text to be detected are determined based on the pixel association information and the plurality of target pixels, the angle of the text to be detected is adjusted according to the deflection information, text recognition is performed on the adjusted text to be detected, and a text recognition result is obtained.
[0183] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0184] After acquiring an image to be recognized, the embodiment of the present invention includes a text to be detected, and semantic segmentation is performed on the image to be recognized to obtain multiple target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel. Then, based on the pixel association information and the multiple target pixels, the position of each target pixel in the image to be recognized and the deflection information of the text to be detected are determined. Then, the angle of the text to be detected is adjusted according to the deflection information. Finally, text recognition is performed on the adjusted text to be detected to obtain a text recognition result. Compared with the existing text recognition scheme, the text recognition method of the present invention can adjust the angle of the text to be detected according to the deflection information of the text to be detected. When the text to be detected in the image to be recognized rotates at an angle, the deflection information of the text to be detected can be determined based on the pixel association information and the multiple target pixels. Then, the angle of the text to be detected is adjusted according to the deflection information. Therefore, the scheme can effectively improve the accuracy of text detection, thereby improving the accuracy of text recognition.
[0185] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0186] To this end, an embodiment of the present invention provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any text recognition method provided in the embodiment of the present invention. For example, the instructions can execute the following steps:
[0187] An image to be recognized is obtained, the image to be recognized includes a text to be detected, semantic segmentation is performed on the image to be recognized, a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel are obtained, the position of each target pixel in the image to be recognized and the deflection information of the text to be detected are determined based on the pixel association information and the plurality of target pixels, the angle of the text to be detected is adjusted according to the deflection information, text recognition is performed on the adjusted text to be detected, and a text recognition result is obtained.
[0188] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0189] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0190] Since the instructions stored in the storage medium can execute the steps in any text recognition method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any text recognition method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0191] The above is a detailed introduction to a text recognition method, device, electronic device and storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A text recognition method, characterized in that: include: Acquire an image to be recognized, wherein the image to be recognized includes text to be detected; Performing semantic segmentation on the image to be recognized to obtain a plurality of target pixel points corresponding to the text to be detected and pixel association information corresponding to each target pixel point; Based on the pixel association information and the plurality of target pixels, determining the position of each target pixel in the image to be recognized and the deflection information of the text to be detected includes: Determine the position of each target pixel in the text to be detected according to the distribution of the multiple target pixels in the image to be recognized; Based on the pixel association information, the angle corresponding to each pixel is predicted by the angle prediction submodel in the preset text detection model to obtain the angle prediction value corresponding to each pixel. The angle prediction value refers to the probability of the text to be detected where the target pixel is located being deflected. Constructing deflection information of the text to be detected according to multiple angle prediction values; Adjusting the angle of the text to be detected according to the deflection information; Perform text recognition on the adjusted text to be detected to obtain a text recognition result.
2. The method according to claim 1, characterized in that The adjusting the angle of the text to be detected according to the deflection information includes: Constructing a text area corresponding to the text to be detected in the image to be recognized according to a plurality of target pixels and pixel association information corresponding to each target pixel; The angle of the text area is adjusted according to the deflection information.
3. The method according to claim 2, characterized in that The adjusting the angle of the text area by using the deflection information includes: Extracting angle information of the text area from the deflection information, the angle information including an angle prediction value corresponding to each pixel point in the text area; Performing weighted average processing on multiple angle prediction values to obtain a predicted deflection angle corresponding to the text area; The angle of the text region is adjusted based on the predicted deflection angle.
4. The method according to claim 3, characterized in that The adjusting the angle of the text area based on the predicted deflection angle includes: Obtain the direction vector corresponding to each edge of the text area; Constructing a unit vector corresponding to the predicted deflection angle; Calculate the product of the unit vector and each direction vector respectively; According to the calculation result, a target vector is determined from a plurality of direction vectors; The angle of the text area is adjusted using the target vector and the predicted deflection angle.
5. The method according to claim 3, characterized in that: The adjusting the angle of the text area based on the predicted deflection angle includes: Obtaining coordinates corresponding to each vertex of the text area; Based on the predicted deflection angle, coordinate transformation is performed on the coordinates corresponding to each vertex; The angle of the text area is adjusted according to the transformed coordinates.
6. The method according to claim 2, characterized in that The step of constructing a text area corresponding to the text to be detected in the image to be recognized according to the plurality of target pixels and the pixel association information corresponding to each target pixel includes: Based on the pixel association information corresponding to each target pixel, a reference pixel corresponding to each target pixel is obtained; Obtaining position information of the target pixel in the text to be detected; According to the position information and the corresponding reference pixel points, a text area corresponding to the text to be detected is constructed on the image to be recognized.
7. The method according to claim 6, characterized in that The obtaining, based on the pixel association information corresponding to each target pixel, a reference pixel corresponding to each target pixel, comprises: Taking the target pixel point as the center, pixels within a preset range are acquired according to pixel association information corresponding to the target pixel point to obtain a reference pixel point corresponding to the target pixel point.
8. The method according to any one of claims 1 to 7, characterized in that: The semantic segmentation of the image to be recognized to obtain a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel includes: Extracting features of the image to be identified to obtain a text feature image corresponding to the image to be identified; Classify the pixels in the text feature image by using the first classification sub-model in the preset text detection model to obtain a pixel prediction value corresponding to each pixel, wherein the pixel prediction value refers to the probability that each pixel in the text feature image belongs to the area where the text to be detected is located; Based on the pixel prediction value, determining a plurality of target pixel points corresponding to the text to be detected; Using the second classification sub-model in the preset text detection model, multiple target pixels are classified to obtain the classification confidence corresponding to each target pixel; Determine the connection relationship between each target pixel and the 8-neighborhood according to the classification confidence; According to the connection relationship, pixel association information corresponding to each target pixel is constructed.
9. A text recognition device, characterized in that: include: An acquisition module, used for acquiring an image to be recognized, wherein the image to be recognized includes text to be detected; A segmentation module is used to perform semantic segmentation on the image to be identified to obtain a plurality of target pixels corresponding to the text to be detected and pixel association information corresponding to each target pixel; A determination module, used to determine the position of each target pixel in the image to be identified and the deflection information of the text to be detected based on the pixel association information and the multiple target pixels, including: Determine the position of each target pixel in the text to be detected according to the distribution of the multiple target pixels in the image to be recognized; Based on the pixel association information, the angle corresponding to each pixel is predicted by the angle prediction submodel in the preset text detection model to obtain the angle prediction value corresponding to each pixel. The angle prediction value refers to the probability of the text to be detected where the target pixel is located being deflected. Constructing deflection information of the text to be detected according to multiple angle prediction values; An adjustment module, used for adjusting the angle of the text to be detected according to the deflection information; The recognition module is used to perform text recognition on the adjusted text to be detected to obtain a text recognition result.
10. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the text recognition method according to any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium, characterized in that: A computer program is stored thereon, wherein when the computer program is executed by a processor, the steps of the text recognition method according to any one of claims 1 to 8 are implemented.
