Document orientation recognition method, device and storage medium

By obtaining the document image, calculating the information content value and using the deep learning model to identify the document direction, it solves the identification difficulty problem of existing OCR technology when processing slanted text, achieves accurate identification of document direction and improves OCR recognition efficiency.

CN110378287BActive Publication Date: 2024-08-27TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201910652827.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-07-19
Publication Date
2024-08-27
Estimated Expiration
2040-04-25

AI Technical Summary

Technical Problem

Existing OCR recognition technology is difficult to accurately identify characters when processing tilted text images, making the recognition process difficult. Especially when the text is tilted more than 90 degrees, the character segmentation step becomes difficult, affecting the recognition efficiency.

Method used

By obtaining the document image, convert it into a binary image, select multiple image blocks, calculate the information content value of each image block, and use the fully convolutional network model and the attention model to identify the document direction, and use the residual network model to perform weighted calculations , determine the orientation angle of the document.

Benefits of technology

It achieves rapid and accurate recognition of document orientation, improves the accuracy and efficiency of OCR recognition, and simplifies preprocessing steps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110378287B
    Figure CN110378287B
Patent Text Reader

Abstract

The present application discloses a document direction recognition method, device and storage medium. The document direction recognition method comprises: obtaining a document image, wherein the document image comprises a document to be recognized; determining a binary image corresponding to the document image, and selecting a plurality of image blocks from the binary image; determining the information content value of each image block; and recognizing the direction of the document to be recognized in the document image according to the information content value and the image block, thereby being able to quickly and accurately recognize the document direction. The method is simple and has a good recognition effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a document direction recognition method, device and storage medium. Background Art

[0002] The purpose of document image text processing is to recognize text, graphics and pictures in digital images and extract information as needed. Among them, text processing mainly includes: firstly, layout analysis is performed to segment paragraphs, lines and single words, and then OCR (Optical Character Recognition) is performed.

[0003] In the existing OCR recognition process, the text in the text image often tilts at a certain angle. For example, due to improper user operation during scanning, the text in the scanned image tilts horizontally by 90 degrees. Under normal circumstances, a tilt of more than 3 degrees will cause obvious deformation of the characters. This text tilt phenomenon will cause difficulties in the character segmentation step during OCR recognition, making it difficult to complete the OCR recognition process smoothly. Therefore, how to quickly and accurately detect the tilt angle of the tilted text image and then correct the tilted text image is an important preprocessing technology before the current OCR recognition technology is used. Summary of the invention

[0004] The embodiments of the present application provide a document orientation recognition method, device and storage medium, which can quickly and accurately recognize the document orientation with high accuracy.

[0005] The present application provides a document orientation recognition method, including:

[0006] Acquire a document image, wherein the document image includes a document to be identified;

[0007] Determine a binary image corresponding to the document image, and select a plurality of image blocks from the binary image;

[0008] Determining an information content value of each of the image blocks;

[0009] The direction of the document to be identified in the document image is identified according to the information content value and the image block.

[0010] The embodiment of the present application also provides a document direction recognition device, including:

[0011] An acquisition module, used for acquiring a document image, wherein the document image includes a document to be identified;

[0012] A first determination module, used to determine a binary image corresponding to the document image, and select a plurality of image blocks from the binary image;

[0013] A second determination module, used to determine the information content value of each of the image blocks;

[0014] The recognition module is used to recognize the direction of the document to be recognized in the document image according to the information content value and the image block.

[0015] Furthermore, the second determining module specifically includes:

[0016] A first determination submodule, used to determine the thermal image corresponding to each image block using a trained full convolutional network model;

[0017] A second determination submodule, used to determine a first pixel value of each pixel point in each of the thermal images;

[0018] A third determination submodule, configured to determine a first pixel average value of the corresponding thermal image according to the first pixel value;

[0019] The fourth determination submodule is used to determine the information content value of the corresponding image block according to the first pixel average value.

[0020] Furthermore, the fourth determining submodule is specifically used for:

[0021] Determine a connected domain in each of the image blocks, and an area of ​​each of the connected domains;

[0022] Determine a target connected domain from the connected domains according to the area of ​​the region, and obtain the number of the target connected domains;

[0023] The information content value of the corresponding image block is determined according to the first pixel average value and the number of the target connected domains.

[0024] Furthermore, the fourth determining submodule is specifically used for:

[0025] Determine a second pixel average value of the corresponding image block according to the second pixel value;

[0026] Determine a pixel standard deviation value of a corresponding image block according to the second pixel average value and the second pixel value;

[0027] According to the first pixel average value, the second pixel average value, the pixel standard deviation value and the number of the target connected domains corresponding to the same image block, the information content value of the corresponding image block is determined.

[0028] Furthermore, the identification module is specifically used for:

[0029] determining a target image block from the plurality of image blocks according to the information content value;

[0030] Determine the reading direction angle corresponding to each target image block by using the trained network model;

[0031] The direction of the document to be identified in the document image is identified according to the reading direction angle and the information content value.

[0032] Furthermore, the identification module is specifically used for:

[0033] summing the information content values ​​to obtain a sum value;

[0034] Determine a weight value of each target image block according to the sum value and the information content value;

[0035] The reading direction angle is weightedly calculated according to the weight value to obtain a target direction angle, and the direction indicated by the target direction angle is used as the direction of the document to be identified in the document image.

[0036] Furthermore, the network model includes a residual network model and an attention model, and the recognition module is specifically used for:

[0037] Inputting each of the target image blocks into a trained residual network model to process the target image block, wherein the residual network model includes at least four layers of residual blocks;

[0038] During the processing, a first feature map in the second layer residual block is obtained;

[0039] Inputting the first feature map obtained into the trained attention model to obtain an attention image;

[0040] Obtain the second feature map output from the third layer residual block;

[0041] Performing a dot multiplication operation on the second feature map and the attention map to obtain a third feature map;

[0042] The third feature map is input into the fourth layer residual block to obtain the reading direction angle.

[0043] An embodiment of the present application also provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions are suitable for being loaded by a processor to execute any of the above-mentioned document direction recognition methods.

[0044] The document direction recognition method, device and storage medium provided in the present application obtain a document image, which includes a document to be recognized, then determine a binary image corresponding to the document image, and select multiple image blocks from the binary image, then determine the information content value of each image block, and recognize the direction of the document to be recognized in the document image based on the information content value and the image block, thereby being able to quickly and accurately recognize the document direction. The method is simple and has a good recognition effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The technical solution and other beneficial effects of the present application will be made apparent by describing in detail the specific implementation methods of the present application in conjunction with the accompanying drawings.

[0046] Figure 1 A scenario diagram of a document orientation recognition system provided in an embodiment of the present application.

[0047] Figure 2 A flowchart of a document orientation recognition method provided in an embodiment of the present application.

[0048] Figure 3 Another flowchart of the document orientation recognition method provided in an embodiment of the present application.

[0049] Figure 4 A flowchart of step S1034 provided in an embodiment of the present application.

[0050] Figure 5 A schematic diagram of the framework of the document orientation recognition process provided in an embodiment of the present application.

[0051] Figure 6 A flowchart of the medical document recognition process provided in an embodiment of the present application.

[0052] Figure 7 Another structural schematic diagram of the document orientation recognition device provided in an embodiment of the present application.

[0053] Figure 8 A schematic diagram of the structure of a document orientation recognition device provided in an embodiment of the present application.

[0054] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 this application.

[0056] Embodiments of the present application provide a document orientation recognition method, device, storage medium, and electronic device.

[0057] See also Figure 1 , Figure 1 This is a scenario diagram of a document orientation recognition system. The document orientation recognition system may include any one of the document orientation recognition devices provided in the embodiments of the present application. The document orientation recognition device may be integrated in an electronic device, such as a mobile terminal or a server.

[0058] The electronic device can obtain a document image, which includes a document to be identified; determine a binary image corresponding to the document image, and select multiple image blocks from the binary image; determine the information content value of each image block; and identify the direction of the document to be identified in the document image based on the information content value and the image block.

[0059] The document to be identified may include text and / or images, and the document image may be obtained by processing the document to be identified through a scanning device or a camera. The binary image means that each pixel on the image has only two possible values ​​or grayscale states, such as 1 and 0. The information content value mainly refers to the amount of effective information (such as text, image). Generally, the larger the information content value, the smaller the blank area and the more effective information it contains.

[0060] For example, in Figure 1 In the process of correcting the orientation of a scanned image of a medical document, the scanned image can be first converted into a grayscale image and then the grayscale image can be corrected. Figure 2 After the binary image is obtained by quantization, a certain number of image blocks can be selected from the binary image by random or specified selection method. The specified selection method can be set based on the image position, such as selecting image blocks in the center area of ​​the image. The number can be set manually, such as 20. After that, the information content value of each image block can be determined, and the reading direction angle of the medical document can be determined based on the information content value and the image block, such as 90°, that is, the direction of the medical document.

[0061] like Figure 2 As shown, Figure 2 : is a flow chart of a document direction recognition method provided in an embodiment of the present application. The specific flow of the document direction recognition method can be as follows:

[0062] S101. Acquire a document image, wherein the document image includes a document to be identified.

[0063] In this embodiment, the document to be identified may include text and / or images, and the document image may be obtained by processing the document to be identified through a scanning device or a photographing device.

[0064] S102. Determine a binary image corresponding to the document image, and select multiple image blocks from the binary image.

[0065] In this embodiment, the binary image means that each pixel on the image has only two possible values ​​or grayscale levels, such as 0 and 255. Specifically, the document image can be converted into a grayscale image first, and then the grayscale image can be converted into a grayscale image. Figure 2 The number and size of the image blocks can be set in advance, for example, 20 blocks and 448 pixels * 448 pixels in size. The image blocks can be randomly selected by a random function or based on the image position, for example, the image blocks in the middle area, one-third area, etc. of the image can be selected.

[0066] S103. Determine the information content value of each image block.

[0067] In this embodiment, the information content value mainly refers to the amount of effective information contained. Generally, the larger the information content value is, the smaller the blank area is, and the more effective information is contained.

[0068] For example, see Figure 3 , the above step S103 may specifically include:

[0069] S1031. Determine the thermal image corresponding to each image block using the trained fully convolutional network model.

[0070] In this embodiment, the thermal image and the image block are usually of the same size and have the same number of pixels. The thermal image is actually a probability map, which is used to indicate the matrix containing the distribution of valid information. The value of the matrix tends to 1 where valid information (such as text and images) is contained, and the value tends to 0 where invalid information (such as blank content) is contained.

[0071] S1032. Determine the first pixel value of each pixel in the thermal image.

[0072] S1033. Determine a first pixel average value of the corresponding thermal image according to the first pixel value.

[0073] In this embodiment, the value range of the first pixel value is [0,1], and the first pixel average value is Where n is the number of pixels in the thermal image, h i is the first pixel value of the i-th pixel on the heat map.

[0074] S1034. Determine the information content value of the corresponding image block according to the first pixel average value.

[0075] In this embodiment, the first pixel average value can be directly used as the information content value of the corresponding image block, or the information content value can be determined in combination with other reference factors, for example, see Figure 4 , the above step S1034 may further include:

[0076] 1-1. Determine the connected domains in each image block and the area of ​​each connected domain.

[0077] In this embodiment, a connected domain generally refers to an image region composed of pixels with the same pixel value and adjacent positions in the image, and the area of ​​the region generally refers to the number of pixels contained in each connected domain. For example, for a binary image, the connected domain is an image region composed of adjacent pixels with a pixel value of 0 (or 255). Specifically, the connected domain in the image block can be determined with the help of the OpenCV open source computer vision library, and then the area of ​​the connected domain is determined based on the number of pixels in each connected domain.

[0078] 1-2. Determine a target connected domain from the connected domains according to the area of ​​the region, and obtain the number of the target connected domains.

[0079] In this embodiment, in order to prevent the interference of salt and pepper noise and invalid information, for connected domains with a small or too large area, such as an area less than 4 pixels, or an area not less than 1 / 3 of the overall area of ​​the small image block, subsequent analysis may not be performed. At the same time, for connected domains with pixel values ​​of all 0 (i.e., blank), since they do not contain valid information, subsequent analysis may also be omitted. In other words, connected domains with an area within a specified range and non-zero pixel values ​​are taken as target connected domains.

[0080] 1-3. Determine the information content value of the corresponding image block according to the first pixel average value and the number of the target connected domains.

[0081] In this embodiment, the information content value of the image block can be directly determined based on the two reference factors of the number of target connected domains and the first pixel average value of the heat map. For example, the first pixel average value S4 and the number of target connected domains S3 are weighted and the obtained value is used as the information content value. Alternatively, it can be determined in combination with other reference factors. In this case, step 1-3 can further include:

[0082] Determine a second pixel average value of the corresponding image block according to the second pixel value;

[0083] Determine a pixel standard deviation value of the corresponding image block according to the second pixel average value and the second pixel value;

[0084] According to the first pixel average value, the second pixel average value, the pixel standard deviation value and the number of the target connected domains corresponding to the same image block, the information content value of the corresponding image block is determined.

[0085] In this embodiment, the second pixel average value The pixel standard deviation Wherein n is the number of pixels in the image block, and Pi is the second pixel value of the i-th pixel.

[0086] The information content value S final The calculation formula can be Among them, S1 is the second pixel average value, S2 is the pixel standard deviation value, S3 is the number of target connected domains, S4 is the first pixel average value, λ i is the corresponding preset weight value.

[0087] It should be noted that when determining the information content value of a single image block, S1 to S4 can be used as reference factors at the same time, or one of them can be used as a reference factor alone, or any two or three of them can be used as reference factors. When one of S1 to S4 is used as a reference factor, its value can be directly used as the information content value, and when any two, three or all of S1 to S4 are used as reference factors, the information content value can be calculated using a weighted algorithm.

[0088] S104. Identify the direction of the document to be identified in the document image according to the information content value and the image block.

[0089] In this embodiment, the document direction can be determined based on all image blocks, for example, by calculating the ratio of information content values, and using the trained network model to determine the reading direction angle corresponding to each image block, and then performing weighted calculation on the reading direction angle according to the ratio, and the obtained direction angle represents the document direction. Alternatively, part of the image blocks can be selected to determine the document direction. In this case, Figure 3 In the above step S104, the above step S104 may specifically include:

[0090] S1041. Determine a target image block from the multiple image blocks according to the information content value.

[0091] In this embodiment, image blocks with information content values ​​higher than a certain value may be selected as target image blocks, or the information content values ​​may be sorted by size and image blocks corresponding to the top information content values ​​may be selected as target image blocks.

[0092] S1042. Determine the reading direction angle corresponding to each target image block using the trained network model.

[0093] In this embodiment, the network model is mainly a machine learning (ML) model, wherein machine learning is a multi-field interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other subjects. It specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching.

[0094] For example, the network model may include a residual network (Residual Networks, ResNet) model and an attention model (Attention Model), wherein the residual network model may include multiple layers of residual blocks, and the attention model is accessed by skip connections between the multiple layers of residual blocks. The attention model may include a U-Net neural network and a sigmoid logic function. The attention model mainly plays the role of a weight, which is used to indicate the area that the downstream structure of the network should pay attention to. By introducing the attention model into the residual network model, the attention model can obtain an attention map from the upstream feature map and suppress the downstream non-effective information, which is beneficial for the entire network model to learn features with effective information and improve the accuracy of reading direction angle recognition. It should be noted that in addition to using a trained network model to identify the direction angle of the target image block, projection method or other direction recognition methods can also be used for recognition, which is not limited here.

[0095] For example, the number of layers of the residual block may be four. In this case, the above step S1042 may specifically include:

[0096] Inputting each target image block into a trained residual network model to process the target image block, wherein the residual network model includes at least four layers of residual blocks;

[0097] During the processing, a first feature map in the second layer residual block is obtained;

[0098] Inputting the obtained first feature map into the trained attention model to obtain an attention image;

[0099] Obtain the second feature map output from the third layer residual block;

[0100] Perform a dot multiplication operation on the second feature map and the attention map to obtain a third feature map;

[0101] The third feature map is input into the fourth layer residual block to obtain the reading direction angle.

[0102] In this embodiment, see Figure 3 The residual network model includes an input layer, four residual block layers and an output layer. The attention model is connected to the output ends of the second layer residual block and the third layer residual block by a jump connection. Therefore, in the process of processing the target image block, the target image block will first be input through the input end of the residual network, and then transferred to the first layer residual block and the second layer residual block for processing in sequence. The processed data (that is, the first feature map) is simultaneously transferred to the third layer residual block and the attention model for processing to obtain the second feature map and the attention image, respectively, wherein the value range of the pixel value on the attention image is limited to [0,1], the number of channels is 1, and the two images have the same size. Afterwards, the two images are dot-multiplied to obtain the third feature map, and transmitted as input data to the fourth residual block for processing, and finally the reading direction angle is output through the output end.

[0103] It should be noted that the residual network model and the attention model should be trained in advance, such as preparing an image sample set in advance and marking the reading direction angle of each image sample. At the same time, the residual network model and the attention model are combined and connected as required, and then the image sample set and the annotations are input into the combined model for training to obtain the trained network model.

[0104] S1043. Identify the direction of the document to be identified in the document image according to the reading direction angle and the information content value.

[0105] For example, the above step S1043 may specifically include:

[0106] 2-1. Sum the information content values ​​to obtain a sum value;

[0107] 2-2. Determine the weight value of each target image block according to the sum value and the information content value;

[0108] 2-3. Perform weighted calculation on the reading direction angle according to the weight value to obtain a target direction angle, and use the direction indicated by the target direction angle as the direction of the document to be identified in the document image.

[0109] In this embodiment, the weight value Where h is the total number of target image blocks, w i is the weight value of the i-th target image block, is the information content value of the i-th target image block. Target direction angle Where V i is the reading direction angle of the i-th target image block.

[0110] The following will take the application of the document direction recognition method to electronic equipment and the document to be recognized as a medical document as an example to briefly introduce the process of the document direction recognition method.

[0111] See also Figure 5 The process processing framework includes three parts: data set, scorer and network model. Specifically, when it is necessary to identify the direction of medical documents in document images, the data set can first pre-process the document image, such as converting the document image into a grayscale image and Figure 2 Then, 20 small image blocks B1 to B20 are randomly obtained from the binary image through a random function (see Figure 6 ), and the scorer will determine four score values ​​for each small image block, such as the pixel average value S1, the pixel standard deviation value S2, the number of target connected domains S3, and the pixel average value S4 of the corresponding thermal map, where the pixel average value S1 and the pixel standard deviation value S2 can be directly calculated according to the pixel values ​​of the pixels in the small image block. At the same time, OpenCV is used to determine the connected domain in each small image block, and the connected domain with an area within the specified range and a non-zero pixel value is selected as the target connected domain, and the number of the target connected domain is taken as S3. At the same time, the trained full convolutional network model is used to obtain the thermal image corresponding to each small image block, and the pixel average value S4 is calculated according to the pixel values ​​of the pixels in the thermal image. Then, the formula Calculate the comprehensive score S for each small image block final (i.e., information content value), where λ is the corresponding preset weight value, and the first 8 small image blocks with the highest comprehensive scores are selected, such as B1, B2…B5 and B20. Then, the reading direction angle V of these 8 small image blocks is identified through the trained network model (residual network model and attention model) i For example, the reading direction angle V1 of B1 is 90°, the reading direction angle V2 of B2 is 270°, and so on. Then, according to the comprehensive score S of these 8 small image blocks, final Calculate the respective weight values, where the weight values For example, the weight value w1 of B1 is 0.75, the weight value w2 of B2 is 0.20, and so on. Then, the target direction angle of the medical document in the document image is calculated. For example, V=0.75*90°+0.20*270°+…=90°, then determine whether the target direction angle is within a certain range, such as -5°~5°. If so, no direction correction is required and the process ends. If not, direction correction is performed, such as flipping the document image 90° to facilitate subsequent optical character recognition operations.

[0112] From the above, it can be seen that the document direction recognition method provided by the present application obtains a document image, which includes a document to be recognized, then determines a binary image corresponding to the document image, and selects multiple image blocks from the binary image, then determines the information content value of each image block, and identifies the direction of the document to be recognized in the document image based on the information content value and the image block, thereby being able to quickly and accurately recognize the document direction. The method is simple and has a good recognition effect.

[0113] According to the method described in the above embodiment, this embodiment will be further described from the perspective of a document orientation recognition device, which can be implemented as an independent entity or integrated into an electronic device.

[0114] See also Figure 7 , Figure 7 The document direction recognition device provided by the embodiment of the present application is specifically described, which is applied to an electronic device. The document direction recognition device may include: an acquisition module 10, a first determination module 20, a second determination module 30 and a recognition module 40, wherein:

[0115] (1) Obtain module 10

[0116] The acquisition module 10 is used to acquire a document image, wherein the document image includes a document to be identified.

[0117] In this embodiment, the document to be identified may include text and / or images, and the document image may be obtained by processing the document to be identified through a scanning device or a photographing device.

[0118] (2) First determination module 20

[0119] The first determining module 20 is used to determine a binary image corresponding to the document image and select a plurality of image blocks from the binary image.

[0120] In this embodiment, the binary image means that each pixel on the image has only two possible values ​​or grayscale levels, such as 0 and 255. Specifically, the document image can be converted into a grayscale image first, and then the grayscale image can be converted into a grayscale image. Figure 2 The number and size of the image blocks can be set in advance, for example, 20 blocks and 448 pixels * 448 pixels in size. The image blocks can be randomly selected by a random function or based on the image position, for example, the image blocks in the middle area, one-third area, etc. of the image can be selected.

[0121] (3) Second determination module 30

[0122] The second determination module 30 is used to determine the information content value of each image block.

[0123] In this embodiment, the information content value mainly refers to the amount of effective information contained. Generally, the larger the information content value is, the smaller the blank area is, and the more effective information is contained.

[0124] For example, see Figure 8 , the second determination module 30 specifically includes:

[0125] The first determination submodule 31 is used to determine the thermal image corresponding to each image block by using the trained full convolutional network model.

[0126] In this embodiment, the thermal image and the image block are usually of the same size and have the same number of pixels. The thermal image is actually a probability map, which is used to indicate the matrix containing the distribution of valid information. The value of the matrix tends to 1 where valid information (such as text and images) is contained, and the value tends to 0 where invalid information (such as blank content) is contained.

[0127] The second determining submodule 32 is used to determine the first pixel value of each pixel in the thermal image.

[0128] The third determination submodule 33 is used to determine a first pixel average value of the corresponding thermal image according to the first pixel value.

[0129] In this embodiment, the value range of the first pixel value is [0,1], and the first pixel average value is Where n is the number of pixels in the thermal image, h i is the first pixel value of the i-th pixel on the heat map.

[0130] The fourth determination submodule 34 is configured to determine an information content value of a corresponding image block according to the first pixel average value.

[0131] In this embodiment, the first pixel average value may be directly used as the information content value of the corresponding image block, or the information content value may be determined in combination with other reference factors. For example, the above step S1034 may further include:

[0132] 1-1. Determine the connected domains in each image block and the area of ​​each connected domain.

[0133] In this embodiment, a connected domain generally refers to an image region composed of pixels with the same pixel value and adjacent positions in the image, and the area of ​​the region generally refers to the number of pixels contained in each connected domain. For example, for a binary image, the connected domain is an image region composed of adjacent pixels with a pixel value of 0 (or 255). Specifically, the connected domain in the image block can be determined with the help of the OpenCV open source computer vision library, and then the area of ​​the connected domain is determined based on the number of pixels in each connected domain.

[0134] 1-2. Determine a target connected domain from the connected domains according to the area of ​​the region, and obtain the number of the target connected domains.

[0135] In this embodiment, in order to prevent the interference of salt and pepper noise and invalid information, for connected domains with a small or too large area, such as an area less than 4 pixels, or an area not less than 1 / 3 of the overall area of ​​the small image block, subsequent analysis may not be performed. At the same time, for connected domains with pixel values ​​of all 0 (i.e., blank), since they do not contain valid information, subsequent analysis may also be omitted. In other words, connected domains with an area within a specified range and non-zero pixel values ​​are taken as target connected domains.

[0136] 1-3. Determine the information content value of the corresponding image block according to the first pixel average value and the number of the target connected domains.

[0137] In this embodiment, the information content value of the image block can be directly determined based on the two reference factors of the number of target connected domains and the first pixel average value of the heat map. For example, the first pixel average value S4 and the number of target connected domains S3 are weighted and the obtained value is used as the information content value. Alternatively, it can be determined in combination with other reference factors. In this case, step 1-3 can further include:

[0138] Determine a second pixel average value of the corresponding image block according to the second pixel value;

[0139] Determine a pixel standard deviation value of the corresponding image block according to the second pixel average value and the second pixel value;

[0140] According to the first pixel average value, the second pixel average value, the pixel standard deviation value and the number of the target connected domains corresponding to the same image block, the information content value of the corresponding image block is determined.

[0141] In this embodiment, the second pixel average value The pixel standard deviation Wherein n is the number of pixels in the image block, and Pi is the second pixel value of the i-th pixel.

[0142] The information content value S final The calculation formula can be Among them, S1 is the second pixel average value, S2 is the pixel standard deviation value, S3 is the number of target connected domains, S4 is the first pixel average value, λ i is the corresponding preset weight value.

[0143] It should be noted that when determining the information content value of a single image block, S1 to S4 can be used as reference factors at the same time, or one of them can be used as a reference factor alone, or any two or three of them can be used as reference factors. When one of S1 to S4 is used as a reference factor, its value can be directly used as the information content value, and when any two, three or all of S1 to S4 are used as reference factors, the information content value can be calculated using a weighted algorithm.

[0144] (4) Identification module 40

[0145] The identification module 40 is used to identify the direction of the document to be identified in the document image according to the information content value and the image block.

[0146] In this embodiment, the document direction can be determined based on all image blocks, for example, by calculating the ratio of information content values, and using the trained network model to determine the reading direction angle corresponding to each image block, and then performing weighted calculation on the reading direction angle according to the ratio, and the obtained direction angle represents the document direction. Alternatively, part of the image blocks can be selected to determine the document direction. In this case, the recognition module 40 can be specifically used for:

[0147] S1041. Determine a target image block from the multiple image blocks according to the information content value.

[0148] In this embodiment, image blocks with information content values ​​higher than a certain value may be selected as target image blocks, or the information content values ​​may be sorted by size and image blocks corresponding to the top information content values ​​may be selected as target image blocks.

[0149] S1042. Determine the reading direction angle corresponding to each target image block using the trained network model.

[0150] In this embodiment, the network model is mainly a machine learning (ML) model, wherein machine learning is a multi-field interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other subjects. It specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching.

[0151] For example, the network model may include a residual network (Residual Networks, ResNet) model and an attention model (Attention Model), wherein the residual network model may include multiple layers of residual blocks, and the attention model is connected by skip connection between the multiple layers of residual blocks. The attention model may include a U-Net neural network and a sigmoid logic function. The attention model mainly plays the role of a weight, which is used to indicate the area that the downstream structure of the network should pay attention to. By introducing the attention model into the residual network model, the attention model can obtain an attention map from the upstream feature map and suppress the downstream non-effective information, which is conducive to the entire network model to learn features with effective information and improve the accuracy of reading direction angle recognition.

[0152] For example, the number of layers of the residual block may be four. In this case, the above step S1042 may specifically include:

[0153] Inputting each target image block into a trained residual network model to process the target image block, wherein the residual network model includes at least four layers of residual blocks;

[0154] During the processing, a first feature map in the second layer residual block is obtained;

[0155] Inputting the obtained first feature map into the trained attention model to obtain an attention image;

[0156] Obtain the second feature map output from the third layer residual block;

[0157] Perform a dot multiplication operation on the second feature map and the attention map to obtain a third feature map;

[0158] The third feature map is input into the fourth layer residual block to obtain the reading direction angle.

[0159] In this embodiment, see Figure 3 The residual network model includes an input layer, four residual block layers and an output layer. The attention model is connected to the output ends of the second layer residual block and the third layer residual block by a jump connection. Therefore, in the process of processing the target image block, the target image block will first be input through the input end of the residual network, and then transferred to the first layer residual block and the second layer residual block for processing in sequence. The processed data (that is, the first feature map) is simultaneously transferred to the third layer residual block and the attention model for processing to obtain the second feature map and the attention image, respectively, wherein the value range of the pixel value on the attention image is limited to [0,1], the number of channels is 1, and the two images have the same size. Afterwards, the two images are dot-multiplied to obtain the third feature map, and transmitted as input data to the fourth residual block for processing, and finally the reading direction angle is output through the output end.

[0160] It should be noted that the residual network model and the attention model should be trained in advance, such as preparing an image sample set in advance and marking the reading direction angle of each image sample. At the same time, the residual network model and the attention model are combined and connected as required, and then the image sample set and the annotations are input into the combined model for training to obtain the trained network model.

[0161] S1043. Identify the direction of the document to be identified in the document image according to the reading direction angle and the information content value.

[0162] For example, when executing the above step S1043, the identification module 40 may be further used to:

[0163] 2-1. Sum the information content values ​​to obtain a sum value;

[0164] 2-2. Determine the weight value of each target image block according to the sum value and the information content value;

[0165] 2-3. Perform weighted calculation on the reading direction angle according to the weight value to obtain a target direction angle, and use the direction indicated by the target direction angle as the direction of the document to be identified in the document image.

[0166] In this embodiment, the weight value Where h is the total number of target image blocks, w i is the weight value of the i-th target image block, is the information content value of the i-th target image block. Target direction angle Where V i is the reading direction angle of the i-th target image block.

[0167] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0168] As can be seen from the above, the document direction recognition device provided in this embodiment obtains a document image through an acquisition module 10, and the document image includes a document to be recognized. Then, the first determination module 20 determines the binary image corresponding to the document image, and selects multiple image blocks from the binary image. Then, the second determination module 30 determines the information content value of each image block, and the recognition module 40 recognizes the direction of the document to be recognized in the document image according to the information content value and the image block, thereby being able to quickly realize accurate recognition of the document direction. The method is simple and the recognition effect is good.

[0169] Correspondingly, an embodiment of the present invention further provides a document orientation recognition system, including any one of the document orientation recognition devices provided by the embodiments of the present invention. The document orientation recognition device can be integrated into an electronic device.

[0170] Among them, the electronic device can obtain a document image, which includes a document to be identified; determine a binary image corresponding to the document image, and select multiple image blocks from the binary image; determine the information content value of each image block; and identify the direction of the document to be identified in the document image based on the information content value and the image block.

[0171] The specific implementation of each of the above devices can be found in the previous embodiments, which will not be described in detail here.

[0172] Since the document orientation recognition system can include any one of the document orientation recognition devices provided in the embodiments of the present invention, the beneficial effects that can be achieved by any one of the document orientation recognition devices provided in the embodiments of the present invention can be achieved. For details, please refer to the previous embodiments and will not be repeated here.

[0173] Accordingly, an embodiment of the present invention further provides an electronic device, such as Fig. 9 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:

[0174] The electronic device may include one or more processors 401 of processing cores, one or more computer-readable storage media memories 402, radio frequency (RF) circuits 403, power supplies 404, input units 405, and display units 406. Those skilled in the art will appreciate that Fig. 9 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.

[0175] 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.

[0176] 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.

[0177] The RF circuit 403 can be used for receiving and sending signals during the process of sending and receiving information. In particular, after receiving the downlink information of the base station, it is handed over to one or more processors 401 for processing; in addition, the data related to the uplink is sent to the base station. Generally, the RF circuit 403 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a user identity module (SIM) card, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 403 can also communicate with the network and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobilecommunication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.

[0178] The electronic device also includes a power supply 404 (such as a battery) for supplying power to each component. Preferably, the power supply 404 can be logically connected to the processor 401 through a power management system, so that the power management system can manage charging, discharging, power consumption, etc. The power supply 404 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0179] The electronic device may also include an input unit 405, which can 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. Specifically, in a specific embodiment, the input unit 405 may include a touch-sensitive surface and other input devices. The touch-sensitive surface, also known as a touch display screen or a touch pad, can collect user touch operations on or near it (such as operations performed by users using fingers, styluses, or any other suitable objects or accessories on or near the touch-sensitive surface), and drive corresponding connection devices according to a pre-set program. Optionally, the touch-sensitive surface may include a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into touch point coordinates, and then sends it to the processor 401, and can receive and execute commands sent by the processor 401. In addition, the touch-sensitive surface can be implemented using multiple types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch-sensitive surface, the input unit 405 may also include other input devices. Specifically, other input devices may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.

[0180] The electronic device may also include a display unit 406, which may be used to display information input by a user or information provided to a user, as well as various graphical user interfaces of the electronic device, which may be composed of graphics, text, icons, videos, and any combination thereof. The display unit 406 may include a display panel, and optionally, the display panel may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like. Furthermore, the touch-sensitive surface may cover the display panel, and when the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor 401 to determine the type of touch event, and then the processor 401 provides a corresponding visual output on the display panel according to the type of touch event. Although in Fig. 9 In the embodiment, the touch-sensitive surface and the display panel are used as two independent components to realize input and output functions, but in some embodiments, the touch-sensitive surface and the display panel can be integrated to realize input and output functions.

[0181] Although not shown, the electronic device may also include a camera, a Bluetooth module, etc., which will not be described in detail here. Specifically in this embodiment, the processor 401 in the electronic device will load the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application program stored in the memory 402 to achieve various functions, as follows:

[0182] Acquire a document image, wherein the document image includes a document to be identified;

[0183] Determine a binary image corresponding to the document image, and select a plurality of image blocks from the binary image;

[0184] Determine the information content value of each image block;

[0185] The direction of the document to be identified in the document image is identified according to the information content value and the image block.

[0186] The electronic device can achieve the effective effects that can be achieved by any document direction recognition device provided in the embodiments of the present invention. Please refer to the previous embodiments for details, which will not be repeated here.

[0187] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0188] The document direction recognition method, device, storage medium and electronic device provided in the embodiments of the present invention are introduced in detail above. The principles and implementation methods of the present invention are explained in this article using specific examples. 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 technical personnel in this field, 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 document orientation recognition method, It is characterized in that include: Acquire a document image, wherein the document image includes a document to be identified; Determine a binary image corresponding to the document image, and select a plurality of image blocks from the binary image; Determining the information content value of each of the image blocks, comprising: Determine the thermal image corresponding to each of the image blocks using the trained fully convolutional network model; determine the first pixel value of each pixel in each of the thermal images; Determine a first pixel average value of the corresponding thermal image according to the first pixel value; Determine the information content value of the corresponding image block according to the first pixel average value; The determining the information content value of the corresponding image block according to the first pixel average value includes: Determine a connected domain in each of the image blocks and an area of ​​each of the connected domains; determine a target connected domain from the connected domains according to the area, and obtain the number of the target connected domains; determine an information content value of the corresponding image block according to the first pixel average value and the number of the target connected domains; The determining the information content value of the corresponding image block according to the first pixel average value and the number of the target connected domains includes: Determine a second pixel average value of the corresponding image block according to the second pixel value of each pixel point in each of the image blocks; determine a pixel standard deviation value of the corresponding image block according to the second pixel average value and the second pixel value; determine an information content value of the corresponding image block according to the first pixel average value, the second pixel average value, the pixel standard deviation value and the number of the target connected domains corresponding to the same image block; The direction of the document to be identified in the document image is identified according to the information content value and the image block.

2. The document orientation recognition method according to claim 1, It is characterized in that The step of identifying the direction of the document to be identified in the document image according to the information content value and the image block comprises: determining a target image block from the plurality of image blocks according to the information content value; Determine the reading direction angle corresponding to each target image block by using the trained network model; The direction of the document to be identified in the document image is identified according to the reading direction angle and the information content value.

3. The document orientation recognition method according to claim 2, It is characterized in that The step of identifying the direction of the document to be identified in the document image according to the reading direction angle and the information content value comprises: summing the information content values ​​to obtain a sum value; Determine a weight value of each target image block according to the sum value and the information content value; The reading direction angle is weightedly calculated according to the weight value to obtain a target direction angle, and the direction indicated by the target direction angle is used as the direction of the document to be identified in the document image.

4. The document orientation recognition method according to claim 2, It is characterized in that The network model includes a residual network model and an attention model, and the method of using the trained network model to determine the reading direction angle corresponding to each target image block includes: Inputting each of the target image blocks into a trained residual network model to process the target image block, wherein the residual network model includes at least four layers of residual blocks; During the processing, a first feature map in the second layer residual block is obtained; Inputting the first feature map obtained into the trained attention model to obtain an attention image; Obtain the second feature map output from the third layer residual block; Performing a dot multiplication operation on the second feature map and the attention map to obtain a third feature map; The third feature map is input into the fourth layer residual block to obtain the reading direction angle.

5. A document direction recognition device, It is characterized in that include: An acquisition module, used for acquiring a document image, wherein the document image includes a document to be identified; A first determination module, used to determine a binary image corresponding to the document image, and select a plurality of image blocks from the binary image; A second determination module, used to determine the information content value of each of the image blocks; The second determination module specifically includes: The first determination submodule is used to determine the thermal image corresponding to each of the image blocks using the trained full convolutional network model; the second determination submodule is used to determine the first pixel value of each pixel in each of the thermal images; the third determination submodule is used to determine the first pixel average value of the corresponding thermal image according to the first pixel value; the fourth determination submodule is used to determine the information content value of the corresponding image block according to the first pixel average value, The fourth determination submodule is specifically used for: Determine a connected domain in each of the image blocks and an area of ​​each of the connected domains; determine a target connected domain from the connected domains according to the area, and obtain the number of the target connected domains; determine an information content value of the corresponding image block according to the first pixel average value and the number of the target connected domains; The determining the information content value of the corresponding image block according to the first pixel average value and the number of the target connected domains includes: Determine a second pixel average value of the corresponding image block according to the second pixel value of each pixel point in each of the image blocks; determine a pixel standard deviation value of the corresponding image block according to the second pixel average value and the second pixel value; determine an information content value of the corresponding image block according to the first pixel average value, the second pixel average value, the pixel standard deviation value and the number of the target connected domains corresponding to the same image block; The recognition module is used to recognize the direction of the document to be recognized in the document image according to the information content value and the image block.

6. A computer-readable storage medium, It is characterized in that The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the document direction recognition method according to any one of claims 1 to 4.