Image direction recognition method, storage medium and device
By intercepting multiple sub-images in a text line image and fusing their text direction sub-probabilities, the problem of low text direction recognition accuracy in the prior art is solved, and the accuracy of text direction recognition is significantly improved.
Patent Information
- Application Number
- CN202110337141.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-29
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-03-29
AI Technical Summary
There are large random errors in the existing text direction recognition process, which affects the text direction recognition effect of text line images, resulting in low recognition accuracy.
By intercepting multiple text line sub-images in the text line image, the sub-probabilities of the first text direction and the second text direction of each text line sub-image are obtained, and fusion judgments are made based on these sub-probabilities to determine the text of the text line image. direction.
The random error in the text direction recognition process of text line images is reduced, and the text direction recognition accuracy of text line images is improved.
Smart Images

Figure CN115147839B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image direction recognition method, storage medium and device. Background Art
[0002] With the continuous development and popularization of computer technology, it is very common to use terminal applications installed in mobile phones, computers and other terminals to recognize text content in text images in daily life. Before recognizing text content, it is usually necessary to first recognize the text direction of the text line image and then recognize its text content, which can improve the recognition accuracy of the text content in the image.
[0003] In the existing text direction recognition process, it is usually necessary to pre-train the convolutional neural network model using training images with text direction labels (forward labels and reverse labels), and then use the trained model to perform text direction recognition on the entire text line image. Due to the high requirements for the required training images, it is easy to cause errors in the direction recognition of the text line image, affecting the recognition effect of the text direction of the text line image. Summary of the invention
[0004] The present application provides an image direction recognition method, storage medium and device, which can reduce random errors in the text direction recognition process of text line images and improve the recognition effect of the text direction of text line images.
[0005] In a first aspect, an embodiment of the present application provides an image direction recognition method, the method comprising:
[0006] intercepting at least two text line sub-images from the text line image;
[0007] Obtain a first sub-probability of a first text direction and a second sub-probability of a second text direction for each of the at least two text line sub-images;
[0008] Determining a text direction of the text line image according to the first sub-probability and the second sub-probability;
[0009] The second text direction is the opposite direction of the first text direction.
[0010] In a second aspect, an embodiment of the present application provides an image direction recognition device, including:
[0011] A capture module, used for capturing at least two text line sub-images from the text line image;
[0012] An acquisition module, configured to acquire a first sub-probability of a first text direction and a second sub-probability of a second text direction of each of the at least two text line sub-images;
[0013] a determination module, configured to determine a text direction of the text line image according to the first sub-probability and the second sub-probability;
[0014] The second text direction is the opposite direction of the first text direction.
[0015] In a third aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the steps of the above-mentioned method.
[0016] In a fourth aspect, an embodiment of the present application provides a computer device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.
[0017] In the embodiment of the present application, multiple text line sub-images are intercepted from the text line image, and the sub-probability of the first text direction and the sub-probability of the second text direction of each text line sub-image are obtained, and the text direction of the text line image is fused and judged based on all the sub-probabilities. By using the text direction sub-probabilities corresponding to the multiple text line sub-images intercepted from the text line image for fusion judgment, the random errors of the multiple sub-probabilities corresponding to each text line sub-image will offset each other, thereby effectively reducing the random errors in the text direction recognition process of the text line image and improving the recognition effect of the text direction of the text line image. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 A schematic diagram of a flow chart of an image direction recognition method provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a flow chart of another image direction recognition method provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of a text line sub-image interception method provided in an embodiment of the present application;
[0022] Figure 4 An exemplary schematic diagram of an image direction recognition method provided in an embodiment of the present application;
[0023] Figure 5 A schematic diagram of the structure of an image direction recognition device provided in an embodiment of the present application;
[0024] Figure 6 A structural diagram of a determination module provided in an embodiment of the present application;
[0025] Figure 7 A schematic diagram of the structure of a direction determination unit provided in an embodiment of the present application;
[0026] Figure 8 A schematic diagram of the structure of another direction determination unit provided in an embodiment of the present application;
[0027] Fig. 9 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the features and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0029] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.
[0030] The image direction recognition method provided in the embodiment of the present application can be applied to image direction recognition devices, wherein the image direction recognition devices may include but are not limited to mobile phones, personal computers, laptops, smart furniture, vehicle-mounted devices, wearable devices and other terminal devices with application installation and operation functions.
[0031] The following will be combined Figure 1-Figure 4 , the image direction recognition method provided in the embodiment of the present application is introduced in detail.
[0032] See also Figure 1, which provides a flow chart of a text method for an embodiment of the present application. Figure 1 As shown, the method may include the following steps S101-S103.
[0033] It should be noted that part or all of the execution body of steps S101-S103 may be an application located in the local terminal, or may also be a functional unit such as a plug-in or software development kit (SDK) set in the application located in the local terminal, or may also be a processing engine located in a network-side server, or may also be a distributed system located on the network side, for example, a processing engine or distributed system in an image direction recognition server on the network side, etc. The embodiments of the present application do not specifically limit this.
[0034] It is understandable that the application may be a local program (NativeApp) installed on the local terminal, or may be a web page program (WebApp) of a browser on the local terminal, which is not limited in the embodiments of the present application.
[0035] S101, capturing at least two text line sub-images from a text line image.
[0036] The text line image refers to an image containing a text line. Usually, the text area in the text image is located by text detection technology, and then the text line content is marked in the form of a bounding box, so that multiple text line images can be extracted from the text image. It should be understood that the text image refers to any image containing text content, such as a photo of a certificate, a photo of a bill, a screenshot of a browsing page, a photo of a book page, etc.
[0037] The text line sub-image refers to an image with the same height as the original text line image and a narrower width, so the text line sub-image contains part of the text content in the text line image.
[0038] It should be noted that any interception method that can obtain a text line sub-image from a text line image falls within the scope of protection of the embodiments of the present application.
[0039] S102: Obtain a first sub-probability of a first text direction and a second sub-probability of a second text direction of each of the at least two text line sub-images.
[0040] Specifically, in the prior art, only text line images can be obtained through text detection technology, but the text direction of the obtained text line images cannot be judged. Therefore, the text direction of the obtained text line images may be either positive or negative. For text line images with negative text directions, if text recognition is performed according to the positive text direction, not only is recognition difficult, but also the recognition accuracy is low. Therefore, before performing text recognition, it is necessary to first identify the text direction of the text line image, and after determining the text direction of the text line image, perform text recognition according to the identified text direction. In the prior art, when performing text direction recognition on a text line image, the probability that the text direction of the text line image is positive and the probability that the text direction is negative are usually determined respectively, and the direction of the text line image is determined according to the two probability values. However, in the above method, only two probability values are used, and both of the two probability values may have large random errors. In view of this technical problem, in the embodiment of the present application, by obtaining multiple text line sub-images, it is helpful to improve the recognition accuracy in the subsequent text direction recognition process, and the specific content is described in detail in the subsequent steps.
[0041] It should be noted that the first text direction in the embodiment of the present application can refer to the positive text line direction, and correspondingly, the second text direction is used to refer to the reverse text line direction. Alternatively, the first text direction in the embodiment of the present application can also refer to the reverse text line direction, and correspondingly, the second text direction refers to the positive text line direction. Regardless of which method is used, it does not affect the substantive content of the embodiment of the present application.
[0042] S103: Determine a text direction of the text line image according to the first sub-probability and the second sub-probability.
[0043] Specifically, it can be understood that the text direction of each text line sub-image is consistent with the direction of the text line text image, so the direction of the text line image can be determined based on the text direction sub-probability of each text line sub-image. From a statistical point of view, the random errors of multiple sub-probability values for fusion judgment will offset each other, so it can reduce the random errors in the process of determining the text direction of the text line image and improve the recognition accuracy of the text direction of the text line image.
[0044] In an embodiment of the present application, multiple text line sub-images are intercepted from a text line image, and the sub-probability of the first text direction and the sub-probability of the second text direction of each text line sub-image are obtained, and the text direction of the text line image is fused and judged based on all the sub-probabilities. In the prior art, the text direction of the text line image is judged only based on the first text direction probability and the second text direction probability of the text line image, and there is a large random error in the recognition process. In contrast, the embodiment of the present application uses multiple text direction sub-probabilities corresponding to multiple text line sub-images for fusion judgment. According to the theory of statistics and probability, the random errors of the multiple sub-probabilities corresponding to each text line sub-image will offset each other, thereby effectively reducing the random errors in the text direction recognition process of the text line image and improving the recognition accuracy of the text direction of the text line image.
[0045] See also Figure 2 , which is a flow chart of an image direction recognition method provided in an embodiment of the present application. Figure 2 As shown, the method may include the following steps S201-S204.
[0046] S201, capturing at least two text line sub-images from a text line image.
[0047] A text line image refers to an image containing a text line. For details, see Figure 3 As shown. Usually, the text area in the text image is located by text detection technology, and then the text line content is marked in the form of a bounding box, so that multiple text line images can be extracted from the text image. It should be understood that the text image refers to any image containing text content, such as a photo of a certificate, a photo of a bill, a screenshot of a browsing page, a photo of a book page, etc.
[0048] A text line sub-image is an image with the same height as the original text line image but narrower width. Figure 3 The text line parts in the three sliding windows in , so the text line sub-image contains part of the text content in the text line image.
[0049] It should be noted that any interception method that can obtain a text line sub-image from a text line image falls within the scope of protection of the embodiments of the present application.
[0050] Optionally, the image direction recognition device may use a parallel sliding window of a preset size to intercept the text line image to obtain at least two text line sub-images.
[0051] Specifically, Figure 3As shown, a parallel sliding window of a preset size can be used with the same height as the text line, and the window can be slid in a direction parallel to the text line. Each time a slide is performed, a text line sub-image can be obtained. After multiple slides, multiple text line sub-images can be captured from the text line image. For example, Figure 3 After the sliding window in slides three times, three text line sub-images containing the text contents of "perfect serious", "disordered patients", and "working mechanism" are obtained. The number of slides can be determined according to actual needs. It can be understood that the contents of different text line sub-images can overlap or not overlap each other, and any of the above-mentioned interception methods falls within the scope of protection of the embodiments of the present application.
[0052] S202: Obtain a first sub-probability of a first text direction and a second sub-probability of a second text direction of each of the at least two text line sub-images.
[0053] Specifically, in the prior art, only text line images can be acquired through text detection technology, but the text direction of the acquired text line image cannot be determined. Therefore, the text direction of the acquired text line image may be either positive or negative. For text line images with negative text directions, if text recognition is performed according to the positive text direction, not only is recognition difficult, but the recognition accuracy is also low. Therefore, before performing text recognition, it is necessary to first identify the text direction of the text line image, and then perform text recognition after the text direction of the text line image is determined. In the prior art, when performing text direction recognition on a text line image, the probability that the text direction of the text line image is positive and the probability that the text direction is directional are usually determined separately, and the direction of the text line image is determined based on the two probability values. However, in the above method, only two probability values are used, and both of the two probability values may have large random errors. In response to this technical problem, in an embodiment of the present application, multiple text line sub-images are acquired. For example, in Figure 3 In the present invention, three text line sub-images containing the text contents of "perfect serious", "disordered patients" and "working mechanism" are intercepted. By determining the sub-probability that the text directions of the three text line sub-images are positive and the sub-probability that they are negative, a total of three positive text line direction sub-probability values and three negative text line direction sub-probability values corresponding to the three text line sub-images are obtained. Compared with the two probability values in the prior art, the use of six sub-probability values helps to improve the recognition accuracy in the subsequent text direction recognition process. The specific content will be described in detail in the subsequent steps.
[0054] It is understandable that the first text direction in the embodiment of the present application can refer to the positive text line direction, and correspondingly, the second text direction is used to refer to the reverse text line direction. Alternatively, the first text direction in the embodiment of the present application can also refer to the reverse text line direction, and correspondingly, the second text direction refers to the positive text line direction. Regardless of which method is used, it does not affect the substantive content of the embodiment of the present application.
[0055] S203, determining a first probability of a first text direction and a second probability of a second text direction of the text line image according to the first sub-probability and the second sub-probability;
[0056] Specifically, it can be understood that the text direction of each text line sub-image is consistent with the direction of the text line text image, so the text direction probability of the text line image of the text line image can be determined based on the text direction sub-probability of each text line sub-image. And the positive text direction probability of the text line image is calculated by the positive text direction sub-probabilities of multiple text line sub-images, and the random errors therein can offset each other, so the accuracy of the positive text direction probability of the text line image can be improved. Similarly, using multiple reverse text direction sub-probabilities corresponding to multiple text line sub-images to determine the reverse text direction probability of the text line image helps to improve the accuracy of the reverse text direction probability of the text line image.
[0057] Optionally, the image direction recognition device can calculate the average value of the first sub-probability and the average value of the second sub-probability; use the average value of the first sub-probability as the first probability of the first text direction of the text line image, and use the average value of the second sub-probability as the second probability of the second text direction of the text line image.
[0058] Specifically, the image direction recognition device can determine the probability of the positive text line direction of the text line image by the average value of the sub-probabilities of the positive text line directions of each text line sub-image. Similarly, the image direction recognition device can determine the probability of the reverse text line direction of the text line image by the average value of the sub-probabilities of the reverse text line directions of each text line sub-image, so as to improve the accuracy of the text direction probability of the text line image.
[0059] S204: Determine a text direction of the text line image according to the first probability and the second probability.
[0060] Specifically, since the image direction recognition device obtains a higher-precision positive text direction probability and a higher-precision reverse text direction probability of the text line image in the aforementioned steps, the text direction of the text line image is judged on this basis, which can improve the recognition accuracy of the text direction of the text line image.
[0061] Optionally, when the first probability is greater than the second probability, and the first probability is greater than a first threshold, the image direction recognition device can determine that the direction of the text line image is a first text direction; when the second probability is greater than the first probability, and the second probability is greater than the first threshold, the image direction recognition device can determine that the direction of the text line image is a second text direction.
[0062] Specifically, the probability of the positive text line direction and the probability of the reverse text line direction of the text line image can be compared first. If the probability of the positive text line direction of the text line image is larger, it indicates that the possibility that the text line direction of the text line image is positive is larger. Then, the first threshold here represents the confidence level, and the value is a certain value between 0 and 1. The first threshold can be pre-set according to actual needs. When the probability of the positive text line direction of the text line image is higher than the confidence level, the text line direction of the text line image can be determined to be positive. Similarly, if the probability of the reverse text line direction of the text line image is larger, it indicates that the possibility that the text line direction of the text line image is reverse is larger. Then, when the probability of the reverse text line direction of the text line image is higher than the confidence level, the text line direction of the text line image can be determined to be reverse.
[0063] Optionally, when the first probability and the second probability are both less than or equal to a first threshold, text recognition processing is performed on the text line image according to the first text direction to obtain a first recognition result; text recognition processing is performed on the text line image according to the second text direction to obtain a second recognition result; semantic recognition processing is performed on the first recognition result and the second recognition result respectively to obtain a third probability that the first recognition result conforms to the semantic order, and a fourth probability that the second recognition result conforms to the semantic order; and the direction of the text line image is determined based on the third probability and the fourth probability.
[0064] Specifically, when both the forward text line direction probability and the reverse text line direction probability of the text line image do not reach the confidence level represented by the first threshold, it indicates that the text line direction of the text line image cannot be determined by the above method. At this time, the semantic recognition result of the text line image can be used to judge the text line direction of the text line image. The N-gram model is an algorithm based on a statistical language model, and the image direction recognition device can use a feature analysis method based on N-Gram to perform semantic recognition processing on the text recognition content of the text line image according to the forward text line direction, and obtain a third probability that the text recognition content of the text line image conforms to the semantic order, and then perform semantic recognition processing on the text recognition content of the text line image according to the reverse text line direction, and obtain a fourth probability that the text recognition content of the text line image conforms to the semantic order.
[0065] Optionally, when the third probability is greater than the fourth probability and the third probability is greater than a second threshold, the direction of the text line image is determined to be the first text direction; when the fourth probability is greater than the third probability and the fourth probability is greater than the second threshold, the direction of the text line image is determined to be the second text direction.
[0066] Specifically, the image direction recognition device can further compare the third probability and the fourth probability. If the third probability is larger, it indicates that the text line direction of the text line image is more likely to be positive. Then, the second threshold here represents the confidence level, and the value is a certain value between 0 and 1. The second threshold can be pre-set according to actual needs. When the third probability, which is a larger value of the two, is higher than the confidence level represented by the second threshold, it can be determined that the text line direction of the text line image is positive. Similarly, if the fourth probability is larger, it indicates that the text line direction of the text line image is more likely to be reverse. At this time, when the fourth probability is higher than the confidence level represented by the second threshold, it can be determined that the text line direction of the text line image is reverse.
[0067] It can be understood that the fourth probability can also refer to performing semantic recognition processing on the text recognition content of the text line image in the forward text line direction, and obtaining the probability that the text recognition content of the text line image conforms to the semantic order. Correspondingly, the third probability refers to performing semantic recognition processing on the text recognition content of the text line image in the reverse text line direction, and obtaining the probability that the text recognition content of the text line image conforms to the semantic order. Regardless of which method is used, it does not affect the substantive content of the embodiments of the present application.
[0068] In the embodiment of the present application, multiple text line sub-images are intercepted in the text line image, and the sub-probability of the first text direction and the sub-probability of the second text direction of each text line sub-image are obtained, and the text direction probability of the text line image with higher accuracy is obtained according to all the sub-probabilities. The embodiment of the present application adopts multiple text direction sub-probabilities corresponding to multiple text line sub-images for fusion judgment. According to the theory of statistics and probability, it can be known that the random errors of the multiple sub-probabilities corresponding to each text line sub-image will offset each other, thereby effectively reducing the random errors in the text direction recognition process of the text line image, and improving the recognition accuracy of the text direction of the text line image. By comparing the positive text line direction probability and the reverse text line direction probability of the text line image, and comparing the larger value of the two with the confidence level represented by the first threshold, when the larger value of the two is higher than the first threshold, the text direction of the text line image is directly determined accordingly. When the larger value of the two is lower than the first threshold, the text recognition result of the text line is semantically recognized according to the positive and reverse text line directions respectively, and the text direction of the text line image is determined according to the semantic recognition result, thereby solving the technical problem of how to determine the text direction of the text line image under different circumstances.
[0069] It should be noted that in the above embodiment, the technical solution of determining the text direction of the text line image according to the first probability and the second probability and the technical solution of determining the text direction of the text line image according to the third probability and the fourth probability can be implemented as separate processes.
[0070] See also Figure 4 , is a schematic diagram of an example of an image direction recognition method provided in an embodiment of the present application. This embodiment is illustrated by an example of an image direction recognition method applied in a terminal. The image direction recognition method may include the following steps:
[0071] S301, intercepting a text line image using a sliding window to obtain at least two text line sub-images.
[0072] A text line image refers to an image containing a text line. For details, see Figure 3 The text line sub-image is an image with the same height as the original text line image and narrower width, see Figure 3 The text line parts in the three sliding windows in , so the text line sub-image contains part of the text content in the text line image.
[0073] like Figure 3 As shown, the image direction recognition device can use a parallel sliding window of a preset size that is the same as the height of the text line, and slide the window in a direction parallel to the text line. Each slide can obtain a text line sub-image, and after multiple slides, multiple text line sub-images can be captured from the text line image. The number of slides can be determined according to actual needs. The contents of different text line sub-images can overlap or not overlap.
[0074] S302, obtaining a positive text direction sub-probability and a negative text direction sub-probability of each text line sub-image.
[0075] S303, fusing the positive text direction sub-probability and the negative text direction sub-probability to obtain the positive text line direction probability and the negative text line direction probability of the text line image, and the larger value of the two.
[0076] Among them, the text direction of each text line sub-image is consistent with the direction of the text line text image, so the text direction sub-probability of each text line sub-image can be used to determine the text direction of the text line image. And the positive text direction probability of the text line image is calculated by the positive text direction sub-probabilities of multiple text line sub-images, and the random errors therein can offset each other, so the accuracy of the positive text direction probability of the text line image can be improved. Similarly, using multiple reverse text direction sub-probabilities corresponding to multiple text line sub-images to determine the reverse text direction probability of the text line image helps to improve the accuracy of the reverse text direction probability of the text line image.
[0077] On this basis, the forward text direction sub-probability and the reverse text direction sub-probability can be first fused to obtain the forward text line direction probability and the reverse text line direction probability of the text line image with higher accuracy. Then, the forward text line direction probability and the reverse text line direction probability of the text line image are compared. If the forward text line direction probability of the text line image is larger, it indicates that the text line direction of the text line image is more likely to be forward. If the reverse text line direction probability of the text line image is larger, it indicates that the text line direction of the text line image is more likely to be reverse.
[0078] S304: Determine whether a larger value of a positive text line direction probability and a negative text line direction probability of the text line image is greater than a preset threshold.
[0079] The preset threshold represents the confidence level, and the value is a value between 0 and 1. The first threshold can be preset according to actual needs. When the larger value is higher than the confidence level, it means that the confidence of the text line direction represented by the larger value is higher than the preset confidence level. For example, when the larger value is the probability of the positive text line direction, and the preset threshold is 0.9, it means that the probability value of the text direction of the text line image is positive is higher than 90%.
[0080] S305: If yes, determine the text direction of the text line image.
[0081] When the larger value of the positive text line direction probability and the reverse text line direction probability of the text line image is greater than a preset threshold value, the text direction of the text line image can be directly determined within the error range allowed by the user. Still taking the example in step S304 as an example, when the error allowed by the user is greater than 10%, the text direction of the text line image can be directly determined to be positive.
[0082] S306: If not, perform text recognition on the text line image in the forward text line direction and the reverse text line direction respectively to obtain a first text recognition result and a second text recognition result.
[0083] S307, using a language model to perform semantic recognition on the two text recognition results, and obtaining the probability that the two semantic recognition results conform to the semantic order.
[0084] Specifically, when both the forward text line direction probability and the reverse text line direction probability of the text line image do not reach the confidence level represented by the preset threshold, it indicates that the text line direction of the text line image cannot be determined by the above method. At this time, the text line direction of the text line image can be judged by the semantic recognition result of the text line image. N-gram is an algorithm based on a statistical language model. The image direction recognition device can use a feature analysis method based on the N-Gram model to perform semantic recognition processing on the text recognition content of the text line image according to the forward text line direction to obtain the probability that the text recognition content of the text line image conforms to the semantic order, and then perform semantic recognition processing on the text recognition content of the text line image according to the reverse text line direction to obtain the probability that the text recognition content of the text line image conforms to the semantic order.
[0085] S308: Determine the text direction of the text line image according to the two probabilities mentioned above.
[0086] Specifically, the image direction recognition device can further compare the two probabilities mentioned above. If the probability that the text recognition content of the text line image conforms to the semantic order according to the positive text line direction is higher, it indicates that the text line direction of the text line image is more likely to be positive. If the probability that the text recognition content of the text line image conforms to the semantic order according to the reverse text line direction is higher, it indicates that the text line direction of the text line image is more likely to be reverse.
[0087] A comparison method using a preset threshold similar to that in step S305 can be used to determine the text direction of the text line image. Specifically, the larger value of the two probabilities is compared with another preset confidence level. If it is greater than the confidence level, the text direction of the text line image can be determined within the allowable error range.
[0088] In an embodiment of the present application, multiple text line sub-images are intercepted from a text line image, and the sub-probability of the forward text direction and the sub-probability of the reverse text direction of each text line sub-image are obtained, and a higher-precision text direction probability of the text line image is obtained based on all the sub-probabilities. The embodiment of the present application uses multiple text direction sub-probabilities corresponding to multiple text line sub-images for fusion judgment. According to the theory of statistics and probability, the random errors of the multiple sub-probabilities corresponding to each text line sub-image will offset each other, thereby effectively reducing the random errors in the text direction recognition process of the text line image and improving the recognition accuracy of the text direction of the text line image. By comparing the forward text line direction probability and the reverse text line direction probability of the text line image, and comparing the larger value of the two with the confidence level represented by the preset threshold, when the larger value of the two is higher than the preset threshold, the text direction of the text line image is directly determined accordingly. When the larger value of the two is lower than the preset threshold, the text recognition results of the text line are semantically recognized according to the positive and negative text line directions respectively, and the text direction of the text line image is determined based on the semantic recognition results, thereby solving the technical problem of how to determine the text direction of the text line image in different situations.
[0089] The following will be combined Figure 5-Figure 8 , the image direction recognition device provided in the embodiment of the present application is introduced in detail. It should be noted that, Figure 5-Figure 8 The image direction recognition device is used to execute the application Figure 1-Figure 4 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 1-Figure 4 The embodiment shown.
[0090] See also Figure 5 , is a schematic diagram of the structure of an image direction recognition device provided in an embodiment of the present application. Figure 5 As shown, the image direction recognition device 1 of the embodiment of the present application may include: a capture module 11, an acquisition module 12 and a determination module 13.
[0091] A capture module 11, used to capture at least two text line sub-images from the text line image;
[0092] The interception module 11 may also be specifically configured to intercept the text line image using a parallel sliding window of a preset size to obtain at least two text line sub-images.
[0093] The acquisition module 12 is configured to acquire a first sub-probability of a first text direction and a second sub-probability of a second text direction of each of the at least two text line sub-images.
[0094] A determination module 13, configured to determine a text direction of the text line image according to the first sub-probability and the second sub-probability;
[0095] The second text direction is the opposite direction of the first text direction.
[0096] For details, see Figure 6 , which is a schematic diagram of the structure of a determination module provided in an embodiment of the present application. Figure 6 As shown, the determination module 13 may include:
[0097] A probability determination unit 131, configured to determine a first probability of a first text direction and a second probability of a second text direction of the text line image according to the first sub-probability and the second sub-probability;
[0098] The probability determination unit 131 may also be specifically configured to calculate an average value of the first sub-probability and an average value of the second sub-probability; use the average value of the first sub-probability as the first probability of the first text direction of the text line image, and use the average value of the second sub-probability as the second probability of the second text direction of the text line image;
[0099] The direction determining unit 132 is configured to determine the text direction of the text line image according to the first probability and the second probability.
[0100] For details, see Figure 7 , which is a schematic diagram of the structure of a direction determination unit provided in an embodiment of the present application. Figure 7 As shown, the direction determination unit 132 may include:
[0101] A first text direction determining subunit 1321, configured to determine that the text direction of the text line image is a first text direction when the first probability is greater than the second probability and the first probability is greater than a first threshold;
[0102] The second text direction determining subunit 1322 is configured to determine that the text direction of the text line image is a second text direction when the second probability is greater than the first probability and the second probability is greater than the first threshold.
[0103] See also Figure 8 , provides another structural diagram of a direction determination unit for an embodiment of the present application. Figure 8 As shown, the direction determination unit 132 may further include:
[0104] A first recognition result acquisition subunit 1323 is configured to perform text recognition processing on the text line image according to the first text direction to obtain a first recognition result when the first probability and the second probability are both less than or equal to a first threshold;
[0105] A second recognition result obtaining subunit 1324 is used to perform text recognition processing on the text line image according to the second text direction to obtain a second recognition result;
[0106] The semantic recognition subunit 1325 is used to perform semantic recognition processing on the first recognition result and the second recognition result respectively to obtain a third probability that the first recognition result conforms to the semantic order and a fourth probability that the second recognition result conforms to the semantic order;
[0107] A text direction determination subunit 1326, configured to determine a text direction of the text line image according to the third probability and the fourth probability;
[0108] Among them, the text direction determination subunit 1326 can also be specifically used to determine that the direction of the text line image is the first text direction when the third probability is greater than the fourth probability and the third probability is greater than the second threshold; when the fourth probability is greater than the third probability and the fourth probability is greater than the second threshold, determine that the direction of the text line image is the second text direction.
[0109] In the embodiment of the present application, multiple text line sub-images are intercepted in the text line image, and the sub-probability of the first text direction and the sub-probability of the second text direction of each text line sub-image are obtained, and the text direction probability of the text line image with higher accuracy is obtained according to all the sub-probabilities. The embodiment of the present application adopts multiple text direction sub-probabilities corresponding to multiple text line sub-images for fusion judgment. According to the theory of statistics and probability, it can be known that the random errors of the multiple sub-probabilities corresponding to each text line sub-image will offset each other, thereby effectively reducing the random errors in the text direction recognition process of the text line image, and improving the recognition accuracy of the text direction of the text line image. By comparing the positive text line direction probability and the reverse text line direction probability of the text line image, and comparing the larger value of the two with the confidence level represented by the first threshold, when the larger value of the two is higher than the first threshold, the text direction of the text line image is directly determined accordingly. When the larger value of the two is lower than the first threshold, the text recognition result of the text line is semantically recognized according to the positive and reverse text line directions respectively, and the text direction of the text line image is determined according to the semantic recognition result, thereby solving the technical problem of how to determine the text direction of the text line image in this case.
[0110] It should be noted that when the image direction recognition device provided in the above embodiment executes the image direction recognition method, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the image direction recognition device provided in the above embodiment and the image direction recognition method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0111] The present application also provides a computer storage medium, which can store multiple program instructions, and the program instructions are suitable for being loaded and executed by a processor as described above. Figure 1-Figure 4 The method steps of the embodiment shown in the figure can be found in the specific implementation process. Figure 1-Figure 4 The specific description of the illustrated embodiment will not be repeated here.
[0112] See also Fig. 9 , which is a schematic diagram of the structure of a computer device according to an embodiment of the present application. Fig. 9 As shown, the computer device 900 may include: at least one processor 901, such as a CPU, at least one network interface 904, an input / output interface 903, a memory 905, and at least one communication bus 902. The communication bus 902 is used to realize the connection and communication between these components. The network interface 904 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface). The memory 905 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 905 may optionally be at least one storage device located away from the aforementioned processor 901. As shown in FIG. Fig. 9 As shown, the memory 905 as a computer storage medium may include an operating system, a network communication module, an input and output interface module, and an image direction recognition application.
[0113] exist Fig. 9 In the computer device 900 shown, the input-output interface 903 is mainly used to provide an input interface for the user and obtain data input by the user.
[0114] In one embodiment, the processor 901 may be used to call the image direction recognition application stored in the memory 905, and specifically perform the following operations:
[0115] intercepting at least two text line sub-images from the text line image;
[0116] Obtain a first sub-probability of a first text direction and a second sub-probability of a second text direction for each of the at least two text line sub-images;
[0117] Determining a text direction of the text line image according to the first sub-probability and the second sub-probability;
[0118] The second text direction is the opposite direction of the first text direction.
[0119] Optionally, when determining the text direction of the text line image according to the first sub-probability and the second sub-probability, the processor 901 specifically performs the following operations:
[0120] Determine a first probability of a first text direction and a second probability of a second text direction of the text line image according to the first sub-probability and the second sub-probability;
[0121] The text direction of the text line image is determined according to the first probability and the second probability.
[0122] Optionally, when determining a first probability of a first text direction and a second probability of a second text direction of the text line image according to the first sub-probability and the second sub-probability, the processor 901 specifically performs the following operations:
[0123] Calculating an average value of the first sub-probabilities and an average value of the second sub-probabilities;
[0124] An average value of the first sub-probabilities is used as a first probability of a first text direction of the text line image, and an average value of the second sub-probabilities is used as a second probability of a second text direction of the text line image.
[0125] Optionally, the processor 901, when determining the text direction of the text line image according to the first probability and the second probability, specifically performs the following operations:
[0126] When the first probability is greater than the second probability, and the first probability is greater than a first threshold, determining that the text direction of the text line image is a first text direction;
[0127] When the second probability is greater than the first probability, and the second probability is greater than the first threshold, the text direction of the text line image is determined to be a second text direction.
[0128] Optionally, the processor 901, when determining the text direction of the text line image according to the first probability and the second probability, specifically performs the following operations:
[0129] When the first probability and the second probability are both less than or equal to a first threshold, performing text recognition processing on the text line image according to the first text direction to obtain a first recognition result;
[0130] Performing text recognition processing on the text line image according to the second text direction to obtain a second recognition result;
[0131] Performing semantic recognition processing on the first recognition result and the second recognition result respectively to obtain a third probability that the first recognition result conforms to the semantic order and a fourth probability that the second recognition result conforms to the semantic order;
[0132] The text direction of the text line image is determined according to the third probability and the fourth probability.
[0133] Optionally, when determining the text direction of the text line image according to the third probability and the fourth probability, the processor 901 specifically performs the following operations:
[0134] When the third probability is greater than the fourth probability, and the third probability is greater than a second threshold, determining that the text direction of the text line image is a first text direction;
[0135] When the fourth probability is greater than the third probability and the fourth probability is greater than the second threshold, the text direction of the text line image is determined to be a second text direction.
[0136] Optionally, the processor 901 performs the following operations when intercepting at least two text line sub-images from the text line image:
[0137] The text line image is intercepted by using a parallel sliding window of a preset size to obtain at least two text line sub-images.
[0138] In the embodiment of the present application, multiple text line sub-images are intercepted in the text line image, and the sub-probability of the first text direction and the sub-probability of the second text direction of each text line sub-image are obtained, and the text direction probability of the text line image with higher accuracy is obtained according to all the sub-probabilities. The embodiment of the present application adopts multiple text direction sub-probabilities corresponding to multiple text line sub-images for fusion judgment. According to the theory of statistics and probability, it can be known that the random errors of the multiple sub-probabilities corresponding to each text line sub-image will offset each other, thereby effectively reducing the random errors in the text direction recognition process of the text line image, and improving the recognition accuracy of the text direction of the text line image. By comparing the positive text line direction probability and the reverse text line direction probability of the text line image, and comparing the larger value of the two with the confidence level represented by the first threshold, when the larger value of the two is higher than the first threshold, the text direction of the text line image is directly determined accordingly. When the larger value of the two is lower than the first threshold, the text recognition result of the text line is semantically recognized according to the positive and reverse text line directions respectively, and the text direction of the text line image is determined according to the semantic recognition result, thereby solving the technical problem of how to determine the text direction of the text line image under different circumstances.
[0139] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0140] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for image direction recognition, It is characterized in that include: intercepting at least two text line sub-images from the text line image; Obtain a first sub-probability of a first text direction and a second sub-probability of a second text direction of each of the text line sub-images in the at least two text line sub-images; Determine a first probability of a first text direction and a second probability of a second text direction of the text line image according to the first sub-probability and the second sub-probability; Determining a text direction of the text line image according to the first probability and the second probability; Wherein, the second text direction is the opposite direction of the first text direction; The determining the text direction of the text line image according to the first probability and the second probability includes: When the first probability and the second probability are both less than or equal to a first threshold, performing text recognition processing on the text line image according to the first text direction to obtain a first recognition result; Performing text recognition processing on the text line image according to the second text direction to obtain a second recognition result; Performing semantic recognition processing on the first recognition result and the second recognition result respectively to obtain a third probability that the first recognition result conforms to the semantic order and a fourth probability that the second recognition result conforms to the semantic order; The text direction of the text line image is determined according to the third probability and the fourth probability.
2. The method according to claim 1, It is characterized in that The determining, according to the first sub-probability and the second sub-probability, a first probability of a first text direction and a second probability of a second text direction of the text line image comprises: Calculating an average value of the first sub-probabilities and an average value of the second sub-probabilities; An average value of the first sub-probabilities is used as a first probability of a first text direction of the text line image, and an average value of the second sub-probabilities is used as a second probability of a second text direction of the text line image.
3. The method according to claim 1, It is characterized in that The determining the text direction of the text line image according to the first probability and the second probability includes: When the first probability is greater than the second probability, and the first probability is greater than a first threshold, determining that the text direction of the text line image is a first text direction; When the second probability is greater than the first probability, and the second probability is greater than the first threshold, the text direction of the text line image is determined to be a second text direction.
4. The method according to claim 1, It is characterized in that The determining the text direction of the text line image according to the third probability and the fourth probability includes: When the third probability is greater than the fourth probability, and the third probability is greater than a second threshold, determining that the text direction of the text line image is a first text direction; When the fourth probability is greater than the third probability and the fourth probability is greater than the second threshold, the text direction of the text line image is determined to be a second text direction.
5. The method according to claim 1, It is characterized in that The step of intercepting at least two text line sub-images from the text line image comprises: The text line image is intercepted by using a parallel sliding window of a preset size to obtain at least two text line sub-images.
6. An image direction recognition device, It is characterized in that include: A capture module, used for capturing at least two text line sub-images from the text line image; An acquisition module, configured to acquire a first sub-probability of a first text direction and a second sub-probability of a second text direction of each of the at least two text line sub-images; a determination module, configured to determine a text direction of the text line image according to the first sub-probability and the second sub-probability; Wherein, the second text direction is the opposite direction of the first text direction; The determination module comprises: A probability determination unit, configured to determine a first probability of a first text direction and a second probability of a second text direction of the text line image according to the first sub-probability and the second sub-probability; a direction determining unit, configured to determine a text direction of the text line image according to the first probability and the second probability; The direction determining unit comprises: a first recognition result acquisition subunit, configured to perform text recognition processing on the text line image according to the first text direction to obtain a first recognition result when the first probability and the second probability are both less than or equal to a first threshold; a second recognition result acquisition subunit, configured to perform text recognition processing on the text line image according to the second text direction to obtain a second recognition result; a semantic recognition subunit, configured to perform semantic recognition processing on the first recognition result and the second recognition result, respectively, to obtain a third probability that the first recognition result conforms to the semantic order, and a fourth probability that the second recognition result conforms to the semantic order; The text direction determination subunit is used to determine the text direction of the text line image according to the third probability and the fourth probability.
7. A computer storage medium, It is characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the steps of the method according to any one of claims 1 to 5.
8. A computer device, It is characterized in that include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method according to any one of claims 1 to 5.
