A method, device, equipment and medium for structuring image information

The text frame detection and sorting of images is carried out through the text recognition and detection network, combined with affine change matrix correction and regular extraction, which solves the problems of LayoutLM's slow processing speed and large GPU resource usage in image understanding tasks, achieving fast and low-resource information extraction and sorting.

CN113850208BActive Publication Date: 2024-09-27PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111148607.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-29
Publication Date
2024-09-27
Estimated Expiration
2041-09-29

AI Technical Summary

Technical Problem

When the image understanding task based on LayoutLM processes real-world images, due to the large number of matrix operations and Softmax operations in the Attention operation, the processing speed is slow and valuable GPU resources are occupied.

Method used

Use text recognition network and text detection network to detect and recognize text in the image to be processed, obtain the minimum circumscribed rectangle and text information of the text box, and update the text box position through affine change matrix correction, sort the text boxes according to the preset order, and merge the text information, and finally use regular rules to extract the destination label.

Benefits of technology

It achieves a fast information extraction process, reduces the demand for server system resources, and avoids dependence on GPU resources. The text information obtained is highly readable and suitable for subsequent word processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113850208B
    Figure CN113850208B
Patent Text Reader

Abstract

The present invention relates to the field of artificial intelligence technology, and provides a method, device, equipment and medium for structuring image information, by obtaining a to-be-processed image; using a text recognition network and a text detection network to perform text detection and recognition on the to-be-processed image to obtain the first minimum circumscribed rectangle of each detected text box and the corresponding text information; sorting the text boxes obtained by the text detection network in a preset order; merging the text information of all text boxes according to the sorting result to obtain the text content in the to-be-processed image; and using regular rules to extract information of a target label from the text content. Compared with the prior art, the present invention has a faster processing speed in the information extraction process, has a very low demand on server system resources, and does not require GPU resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and medium for structuring image information. Background Art

[0002] With the rise of Transformer, solutions based on LayoutLM to handle a large number of image understanding tasks in the real world (such as information extraction from document images and document layout classification) have been widely used. However, due to the large number of matrix operations and Softmax operations in the Attention operation, the processing speed of a single task is relatively slow (about 100ms), and it also takes up valuable GPU resources. Summary of the invention

[0003] The purpose of the present invention is to provide a method, device, equipment and medium for structuring picture information, thereby overcoming one or more problems caused by limitations and defects of related technologies at least to a certain extent.

[0004] To achieve the above-mentioned purpose and other related purposes, the present invention provides a method for structuring image information, comprising:

[0005] Obtaining a to-be-processed image, wherein the to-be-processed image is a card image or a form document image;

[0006] Using a text recognition network and a text detection network to perform text detection and recognition on the image to be processed, so as to obtain the first minimum bounding rectangle of each detected text box and the corresponding text information;

[0007] Selecting the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratios are greater than a first preset value as the picture rotation angle;

[0008] Constructing an affine transformation matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box;

[0009] According to the second minimum circumscribed rectangle of each of the text boxes, sorting all the text boxes in a preset order;

[0010] Merge the text information of all text boxes according to the sorting result to obtain the text content in the image to be processed;

[0011] Regular rules are used to extract information of the target tag from the text content.

[0012] In one embodiment of the present invention, a text recognition network and a text detection network are used to perform text detection and recognition on the image to be processed to obtain the first minimum bounding rectangle of each detected text box and the corresponding text information, including:

[0013] Inputting the image to be processed into the text detection network to perform text detection, so as to obtain the first minimum bounding rectangle of each detected text box;

[0014] According to the first minimum bounding rectangle of each of the text boxes, intercepting a partial picture corresponding to the first minimum bounding rectangle area of ​​each of the text boxes from the picture to be processed;

[0015] The local image corresponding to the first minimum circumscribed rectangular area of ​​each of the text boxes is input into the text recognition network for text recognition to obtain the text information corresponding to each of the text boxes.

[0016] In one embodiment of the present invention, the image to be processed is input into a text detection network for text detection to obtain a first minimum bounding rectangle of each of the detected text boxes, including:

[0017] The image to be processed is input into a progressive expansion network, a differentiable binarization network or a pixel aggregation network for text detection to obtain a first minimum bounding rectangle of each detected text box.

[0018] In one embodiment of the present invention, the local image corresponding to the first minimum circumscribed rectangular area of ​​each text box is input into a text recognition network for text recognition to obtain text information corresponding to each text box, including:

[0019] The local image corresponding to the first minimum circumscribed rectangular area of ​​each text box is input into a convolutional recurrent neural network for text recognition to obtain text information corresponding to each text box.

[0020] In one embodiment of the present invention, constructing an affine transformation matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box includes:

[0021] Selecting the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratios are greater than a first preset value as the picture rotation angle;

[0022] The affine transformation matrix of the image is constructed using the length, width and rotation angle of the image to be processed as parameters.

[0023] In one embodiment of the present invention, the rotation angle of the image to be processed is less than 15°.

[0024] In one embodiment of the present invention, correcting and updating the first minimum bounding rectangle of each text box according to the affine change matrix of the image to obtain the second minimum bounding rectangle of each text box includes:

[0025] Perform a linear transformation on each vertex of the first minimum enclosing rectangle of each text box according to the affine transformation matrix of the image to obtain the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and update the first minimum enclosing rectangle of each text box according to the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and use the updated first minimum enclosing rectangle of each text box as the second minimum enclosing rectangle of each text box.

[0026] In one embodiment of the present invention, sorting all the text boxes in a preset order according to the second minimum circumscribed rectangle of each text box includes:

[0027] According to the ordinate of the center point of the second minimum circumscribed rectangle of each text box, sorting the text boxes in ascending order;

[0028] Obtain all the text boxes belonging to the same row according to a preset rule;

[0029] Sort the horizontal positions of all the text boxes belonging to the same row according to the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box;

[0030] The preset rule for determining that the two text boxes belong to the same row is:

[0031] (1) The difference Δy between the ordinates of the center points of the second minimum circumscribed rectangles of two adjacent text boxes is less than a spacing threshold, wherein the spacing threshold is defined as 0.3-0.7 times the average value of the heights of the second minimum circumscribed rectangles of all the text boxes;

[0032] (2) The ratio of the difference Δy between the center points of the second minimum circumscribed rectangles of two adjacent text boxes and the difference Δx between the center points satisfies tan -1 (Δy / Δx)<15°;

[0033] When (1) and (2) are satisfied at the same time, it is determined that the two text boxes belong to the same row.

[0034] To achieve the above-mentioned purpose and other related purposes, the present invention further provides a picture information structuring device, the picture information structuring device comprising:

[0035] An image acquisition module is used to acquire the image to be processed, wherein the image to be processed is a card image or a form document image;

[0036] A detection and recognition module, used to perform text detection and recognition on the image to be processed using a text recognition network and a text detection network, so as to obtain a first minimum bounding rectangle of each detected text box and corresponding text information;

[0037] An affine change matrix acquisition module, used to construct an affine change matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box;

[0038] A correction and update module, used for correcting and updating the first minimum bounding rectangle of each of the text boxes according to the affine change matrix of the image, so as to obtain the second minimum bounding rectangle of each of the text boxes;

[0039] A text sorting module, used for sorting all the text boxes in a preset order according to the second minimum circumscribed rectangle of each text box;

[0040] A text acquisition module, used to merge the text information of all text boxes according to the sorting result to obtain the text content in the image to be processed;

[0041] The tag extraction module is used to extract the target tag information from the text content by using regular rules.

[0042] To achieve the above objectives and other related objectives, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0043] To achieve the above objectives and other related objectives, the present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.

[0044] The image information structuring method, device, equipment and medium of the present invention can obtain a collection of text information in images with higher readability by specially sorting the text information detection and recognition results in the extraction and information structuring application of card image information or table document image information, and subsequently non-deep learning model technical means can be used to obtain the information of the target label.

[0045] The picture information structuring method, device, equipment and medium of the present invention can obtain a text box sequence with a high degree of restoration of the original picture information by specially sorting the text boxes detected in the picture to be processed, which is convenient for subsequent text processing.

[0046] Compared with the existing technical means of deep learning models, the image information structuring method, device, equipment and medium of the present invention have a very fast processing speed (ms level) in the information extraction process, have a very low demand for server system resources, and do not require GPU resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A flow chart showing a preferred embodiment of the method for structuring picture information of the present invention.

[0048] Figure 2 A picture of a sample residence certificate is shown.

[0049] Figure 3 A sub-step flow chart of step S20 of a preferred embodiment of the method for structuring picture information of the present invention is shown.

[0050] Figure 4 Shows the Figure 2 The residence certificate sample image is a schematic diagram of the result of merging and integrating the text information of all text boxes according to the initial sequence of each text box after text detection and recognition in step S20.

[0051] Figure 5 A schematic diagram showing the text content of the residence certificate sample image obtained in step S70 of the present invention.

[0052] Figure 6 A functional module diagram of a preferred embodiment of the image information structuring device of the present invention is shown.

[0053] Figure 7 A schematic diagram of the structure of an electronic device of a preferred embodiment of the method for structuring picture information of the present invention is shown. DETAILED DESCRIPTION

[0054] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention.

[0055] See also Figure 1-7 It should be noted that the illustrations provided in this embodiment are only used to illustrate the basic concept of the present invention in a schematic manner, and the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0056] Figure 1A flow chart showing a preferred embodiment of the method for structuring picture information of the present invention.

[0057] The image information structuring method is applied to one or more electronic devices, wherein the electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), programmable gate arrays (FPGA), digital processors (DSP), embedded devices, etc.

[0058] The electronic device may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.

[0059] The electronic device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.

[0060] The network where the electronic device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (VPN), etc.

[0061] The following will be combined Figure 1 The image information structuring method of the present invention is described in detail.

[0062] A method for structuring image information, comprising:

[0063] First, step S10 is executed to obtain a picture to be processed, where the picture to be processed is a card picture or a form document picture.

[0064] In this application, the card image will be used as an example for explanation. The card image has the characteristics of fixed structure and single style. Figure 2For example, the information in the residence permit sample is usually displayed in the form of key-value pairs (for example, "name: Zhou XX"). In general, the key-value pairs are arranged in the form of left and right or top and bottom, and have special type relationships.

[0065] It should be noted that the image to be processed in the present application is an image with a rotation angle less than 15°.

[0066] Next, step S20 is performed to detect and recognize text on the image to be processed using a text recognition network and a text detection network to obtain the minimum bounding rectangle (defined as the first minimum bounding rectangle) of each detected text box and the corresponding text information. The text box refers to a text area consisting of one or more adjacent characters.

[0067] Figure 3 FIG. 4 is a flow chart showing the sub-steps of step S20 of a preferred embodiment of the method for structuring picture information of the present invention. Figure 3 As shown, the step of using a text recognition network and a text detection network to perform text detection and recognition on the image to be processed to obtain the minimum bounding rectangle of each detected text box and the corresponding text information may further include:

[0068] Step S21, inputting the image to be processed into a text detection network to perform text detection, so as to obtain the first minimum bounding rectangle of each detected text box;

[0069] Step S22, according to the first minimum bounding rectangle of each text box, intercepting a partial picture corresponding to the first minimum bounding rectangle area of ​​each text box from the picture to be processed;

[0070] Step S23: input the local image corresponding to the first minimum circumscribed rectangular area of ​​each text box into a text recognition network for text recognition to obtain text information corresponding to each text box.

[0071] In the step of inputting the image to be processed into a text detection network for text detection to obtain the first minimum enclosing rectangle of each detected text box, that is, in step S21, the first minimum enclosing rectangle of each text box includes parameter data such as center point coordinates, width, height, rotation angle relative to the horizontal direction, and coordinate information of four vertex corners.

[0072] In the present invention, a progressive scale expansion network (PSENET) can be used as the text detection network to perform text detection on the image to be processed to obtain the first minimum bounding rectangle of each detected text box, wherein the progressive scale expansion network is an algorithm that gradually expands the scaled text kernel into the real text. Of course, a differentiable binarization network (DBNET) or a pixel aggregation network (PANNET) can also be used as the text detection network.

[0073] In the step of cutting out a partial image corresponding to the first minimum bounding rectangle area of ​​each text box from the image to be processed according to the first minimum bounding rectangle of each text box, that is, step S22, for example, the Mat CutImage function of opencv can be used to cut out a partial image corresponding to the first minimum bounding rectangle area of ​​each text box from the image to be processed, and the partial image includes the corresponding text box and the minimum bounding rectangle.

[0074] In the present invention, the text recognition network can be, for example, a convolutional recurrent neural network (CRNN), which is a model for recognizing text, and is mainly used to solve image-based sequence recognition problems, especially scene text recognition problems. The entire CRNN is divided into three parts, namely, a convolutional layer, a recurrent layer, and a transcription layer, wherein the convolutional layer is used to extract a feature sequence from an input image; the recurrent layer is composed of a bidirectional LSTM recurrent neural network, which is used to predict the label distribution of the feature sequence obtained from the convolutional layer; the transcription layer is used to convert the label distribution obtained from the recurrent layer into the final recognition result through operations such as deduplication and integration.

[0075] because Figure 2 The residence permit image in the image is slightly tilted (the tilt angle is less than 15°). If the initial sequence of each text box after text detection and recognition in step S20 is followed, the result of merging and integrating the text information of all text boxes is as follows: Figure 4 As shown, the text information is disordered and the target information cannot be extracted using simple text processing methods.

[0076] In order to offset the influence of a small rotation of the image to be processed on the text merging result, the present invention provides a special text box sorting method to sort the text boxes obtained by the text detection network according to normal reading, corresponding to steps S30-S60.

[0077] Next, an affine transformation matrix of the image is constructed according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box. Specifically, first, the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratio is greater than the first preset value is selected as the image rotation angle (step S30), and then, the affine transformation matrix of the image is constructed with the length, width and the image rotation angle of the image to be processed as parameters (step S40). Since the first minimum circumscribed rectangle of the text box with a larger aspect ratio has a greater impact when the image is tilted, the median of the rotation angles of the first minimum circumscribed rectangles of all text boxes with an aspect ratio greater than 3 (first preset value) can be used as the image rotation angle in step S30, and the image rotation angle is used to construct the affine transformation matrix of the image of the first minimum circumscribed rectangle of the text box. It should be noted that the first preset value can be automatically configured according to actual needs, and the present invention is not limited.

[0078] Selecting the median of the rotation angles of the first minimum bounding rectangles of all the text boxes whose aspect ratios are greater than the first preset value as the image rotation angle can reduce the problem that when the image is tilted, the first minimum bounding rectangle of the text box with a larger aspect ratio is more affected. The rotation angle of the first minimum bounding rectangle is defined as the angle between the horizontal axis (x-axis) rotated counterclockwise and the first side of the first minimum bounding rectangle encountered.

[0079] In step S40, for example, the RotationMatrix2D function in the opencv library can be used to construct the affine transformation matrix of the image with the length, width and rotation angle of the image to be processed as parameters. The expression of the affine transformation matrix M of the image is as follows:

[0080]

[0081] Among them, dx and dy refer to the x and y components of the scaling factor respectively.

[0082] Next, step S50 is executed to correct and update the first minimum bounding rectangle of each text box according to the affine transformation matrix of the image to obtain the second minimum bounding rectangle of each text box.

[0083] Specifically, a linear transformation can be performed on each vertex of the first minimum enclosing rectangle of each text box according to the affine transformation matrix of the image to obtain the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and the first minimum enclosing rectangle of each text box can be updated according to the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and the updated first minimum enclosing rectangle of each text box is used as the second minimum enclosing rectangle of each text box.

[0084] Next, step S60 is executed to sort all the text boxes according to the second minimum circumscribed rectangle of each text box in a normal reading order (preset order), wherein the normal reading order refers to an order from left to right and from top to bottom.

[0085] Specifically, firstly, the text boxes are sorted in ascending order according to the ordinate of the center point of the second minimum circumscribed rectangle of each text box; then, all the text boxes belonging to the same row are obtained according to a preset rule; finally, all the text boxes belonging to the same row are sorted in horizontal position according to the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box, wherein the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box refers to the minimum value of the horizontal coordinates of the four vertices of the second minimum circumscribed rectangle of the text box. In the present invention, the ordinate refers to the y value of the coordinate of the center point / vertex, and the horizontal coordinate refers to the x value of the coordinate of the center point / vertex.

[0086] In the present invention, the preset rule for determining whether the two text boxes belong to the same row is whether conditions (1) and (2) are satisfied at the same time:

[0087] (1) The difference Δy between the center points of the second minimum bounding rectangles of two adjacent text boxes is less than a spacing threshold, where the spacing threshold is defined as 0.3-0.7 times (e.g., 0.3, 0.5, or 0.7) the average height of the minimum bounding rectangles of all text boxes after the update;

[0088] (2) The ratio of the difference Δy between the center points of the second minimum circumscribed rectangles of two adjacent text boxes and the difference Δx between the center points satisfies tan -1 (Δy / Δx)<15°;

[0089] When (1) and (2) are satisfied at the same time, it is determined that the two text boxes belong to the same row. If not, the two text boxes do not belong to the same row. In order to distinguish the text boxes in different rows, a row attribute may be added to each text box.

[0090] Next, step S70 is executed to merge the text information of all text boxes according to the sorting result, and add a line break after the text information of the last text box in each line to obtain the text content of the image to be processed.

[0091] The line break is added after the text information in the last text box of each line to distinguish different text lines. Finally, the text content of the image to be processed is obtained as follows Figure 5 As shown, the text order is a composite order of each tag key-value pair in the image to be processed.

[0092] By sorting the text boxes obtained by the text detection network through the text box sorting method of the present invention, a set of text information in the image to be processed with high readability can be obtained, and then a technical means of a non-deep learning model can be used in step S80, such as regular matching to obtain information of the target label. By sorting the text boxes detected in the image, a text box sequence with a high degree of restoration of the original image information of the image to be processed can be obtained, which is convenient for subsequent text processing.

[0093] Finally, step S80 is executed to extract information of the target tag from the text content using regular rules.

[0094] Specifically, according to the extraction requirements, a regular expression set is designed and regular matching is performed line by line. If the result is satisfied, it is output to the result list; otherwise, it is discarded. Figure 1 Taking the residence permit as an example, if you want to obtain the information corresponding to the two target tags "name" and "ID number", you can set two regular expression sequences, namely the name extraction regular expression and the ID number extraction regular expression to perform regular matching line by line.

[0095] Compared with the technical means of deep learning models, this solution uses regular rules to extract information of the target label from the text content. The information extraction process has a very fast processing speed (ms level), has very low requirements for server system resources, and does not require GPU resources.

[0096] It should be noted that the image information structuring method of the card image of the present invention can also be extended to other document information extraction scenarios, such as table documents. The text in the table document is usually arranged in a grid, and the table header usually appears in the first column or the first row. In the process of information extraction / structuring, the image information structuring method of the collection image of the present application can also be referred to, and the position information of the text in the table document can be fully utilized to complete the information extraction process using a non-deep learning method.

[0097] It should be noted that in the present invention, in order to further ensure the security of the data, the data and models involved can also be deployed on the blockchain to prevent the data from being maliciously tampered with.

[0098] It should be noted that the step division of the above methods is only for clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they contain the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.

[0099] like Figure 6As shown, it is a functional module diagram of a preferred embodiment of the image information structuring device of the present invention. The image information structuring device includes: an image acquisition module 111, a detection and recognition module 112, an affine change matrix acquisition module, a correction update module 115, a text sorting module 116, a text acquisition module 117, and a label extraction module 118. The affine change matrix acquisition module includes an angle acquisition module 113 and a matrix construction module 114. The module referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and can complete fixed functions, which are stored in the memory 12.

[0100] The image acquisition module 111 is used to acquire the image to be processed, and the image to be processed is a card image or a form document image.

[0101] In this application, the card image will be used as an example for explanation. The card image has the characteristics of fixed structure and single style. Figure 2 For example, the residence permit in the example above is usually displayed in the form of key-value pairs (e.g. "name: week XX"). In general, the key-value pairs are arranged in the form of left and right or top and bottom, and have special type relationships.

[0102] It should be noted that the image to be processed in the present application is an image with a rotation angle less than 15°.

[0103] The detection and recognition module 112 is used to perform text detection and recognition on the image to be processed to obtain the minimum bounding rectangle (defined as the first minimum bounding rectangle) of each detected text box and the corresponding text information.

[0104] Specifically, when the detection and recognition module 112 performs text detection and recognition on the image to be processed to obtain the minimum bounding rectangle of each detected text box and the corresponding text information, the image to be processed is first input into a text detection network for text detection to obtain the first minimum bounding rectangle of each detected text box; then, based on the first minimum bounding rectangle of each text box, a local image corresponding to the first minimum bounding rectangle area of ​​each text box is captured from the image to be processed; finally, the local image corresponding to the first minimum bounding rectangle area of ​​each text box is input into a text recognition network for text recognition to obtain the text information corresponding to each text box.

[0105] When the detection and recognition module 112 inputs the image to be processed into the text detection network for text detection to obtain the first minimum enclosing rectangle of each detected text box, the first minimum enclosing rectangle of each text box includes parameter data such as center point coordinates, width, height, rotation angle relative to the horizontal direction, and coordinate information of four vertex corners.

[0106] In the present invention, a progressive scale expansion network (PSENET) can be used as the text detection network to perform text detection on the image to be processed to obtain the first minimum bounding rectangle of each detected text box, wherein the progressive scale expansion network is an algorithm that gradually expands the scaled text kernel into the real text. Of course, a differentiable binarization network (DBNET) or a pixel aggregation network (PANNET) can also be used as the text detection network.

[0107] When the detection and recognition module 112 extracts the local image corresponding to the first minimum bounding rectangle area of ​​each text box from the image to be processed based on the first minimum bounding rectangle of each text box, for example, it can use the Mat CutImage function of opencv to extract the local image corresponding to the first minimum bounding rectangle area of ​​each text box from the image to be processed.

[0108] In the present invention, the text recognition network can be, for example, a convolutional recurrent neural network (CRNN), which is a model for recognizing text, and is mainly used to solve image-based sequence recognition problems, especially scene text recognition problems. The entire CRNN is divided into three parts, namely, a convolutional layer, a recurrent layer, and a transcription layer, wherein the convolutional layer is used to extract a feature sequence from an input image; the recurrent layer is composed of a bidirectional LSTM recurrent neural network, which is used to predict the label distribution of the feature sequence obtained from the convolutional layer; the transcription layer is used to convert the label distribution obtained from the recurrent layer into the final recognition result through operations such as deduplication and integration.

[0109] because Figure 2 The residence permit image in the image is slightly tilted (the tilt angle is less than 15°). If the initial sequence of each text box after the text detection and recognition by the detection and recognition module 112 is followed, the result of merging and integrating the text information of all text boxes is as follows: Figure 4 As shown, the text information is disordered and the target information cannot be extracted using simple text processing methods.

[0110] In order to offset the influence of a small rotation of the image to be processed on the text merging result, the present invention provides a special text box sorting method to sort the text boxes obtained by the text detection network according to normal reading, which is achieved through an affine change matrix acquisition module, a correction update module 115, and a text sorting module 116.

[0111] The affine change matrix acquisition module is used to construct the affine change matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box, and includes an angle acquisition module 113 and a matrix construction module 114. The angle acquisition module 113 is used to select the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratio is greater than a first preset value as the image rotation angle, and the matrix construction module 114 is used to construct the affine change matrix of the image with the length and width of the image to be processed and the image rotation angle as parameters.

[0112] Since the first minimum bounding rectangle of a text box with a larger aspect ratio has a greater impact when the picture is tilted, the angle acquisition module 113 can use the median of the rotation angles of the first minimum bounding rectangles of all text boxes with an aspect ratio greater than 3 (a first preset value) as the picture rotation angle, and the picture rotation angle is used to construct the affine transformation matrix of the image of the first minimum bounding rectangle of the text box. It should be noted that the first preset value can be automatically configured according to actual needs, and the present invention does not limit it.

[0113] Selecting the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratios are greater than the first preset value as the image rotation angle can reduce the problem that when the image is tilted, the first minimum circumscribed rectangle of the text box with a larger aspect ratio is more affected.

[0114] The matrix construction module 114 can use the RotationMatrix2D function in the opencv library, for example, to construct the affine transformation matrix of the image with the length, width and rotation angle of the image to be processed as parameters. The expression of the affine transformation matrix M of the image is as follows:

[0115]

[0116] Among them, dx and dy refer to the x and y components of the scaling factor respectively.

[0117] The correction and update module 115 is used to correct and update the first minimum bounding rectangle of each text box according to the affine change matrix of the image to obtain the second minimum bounding rectangle of each text box.

[0118] Specifically, a linear transformation can be performed on each vertex of the first minimum enclosing rectangle of each text box according to the affine transformation matrix of the image to obtain the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and the first minimum enclosing rectangle of each text box can be updated according to the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and the updated first minimum enclosing rectangle of each text box is used as the second minimum enclosing rectangle of each text box.

[0119] The text sorting module 116 is used to sort all the text boxes according to the second minimum bounding rectangle of each text box in a normal reading order, wherein the normal reading order refers to an order from left to right and from top to bottom.

[0120] Specifically, firstly, the text boxes are sorted in ascending order according to the ordinate of the center point of the second minimum circumscribed rectangle of each text box; then, all the text boxes belonging to the same row are obtained according to a preset rule; finally, all the text boxes belonging to the same row are sorted in horizontal position according to the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box, wherein the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box refers to the minimum value of the horizontal coordinates of the four vertices of the second minimum circumscribed rectangle of the text box. In the present invention, the ordinate refers to the y value of the coordinate of the center point / vertex, and the horizontal coordinate refers to the x value of the coordinate of the center point / vertex.

[0121] In the present invention, the preset rule for determining whether the two text boxes belong to the same row is whether conditions (1) and (2) are satisfied at the same time:

[0122] (1) The difference Δy between the center points of the second minimum bounding rectangles of two adjacent text boxes is less than a spacing threshold, where the spacing threshold is defined as 0.3-0.7 times (e.g., 0.3, 0.5, or 0.7) the average height of the minimum bounding rectangles of all text boxes after the update;

[0123] (2) The ratio of the difference Δy between the center points of the second minimum circumscribed rectangles of two adjacent text boxes and the difference Δx between the center points satisfies tan -1 (Δy / Δx)<15°;

[0124] When (1) and (2) are satisfied at the same time, it is determined that the two text boxes belong to the same row. If not, the two text boxes do not belong to the same row. In order to distinguish the text boxes in different rows, a row attribute may be added to each text box.

[0125] The text acquisition module 117 is used to merge the text information of all text boxes according to the sorting result, and add a line break after the text information of the last text box in each line to obtain the text content of the image to be processed.

[0126] The line break is added after the text information in the last text box of each line to distinguish different text lines. Finally, the text content of the image to be processed is obtained as follows Figure 5 As shown, the text order is a composite order of each tag key-value pair in the image to be processed.

[0127] By sorting the text boxes obtained by the text detection network through the text box sorting method of the present invention, a set of text information in the image to be processed with high readability can be obtained, and then a technical means of a non-deep learning model can be used in step S80, such as regular matching to obtain information of the target label. By sorting the text boxes detected in the image, a text box sequence with a high degree of restoration of the original image information of the image to be processed can be obtained, which is convenient for subsequent text processing.

[0128] The tag extraction module 118 is used to extract target tag information from the text content using regular rules.

[0129] Specifically, according to the extraction requirements, a regular expression set is designed and regular matching is performed line by line. If the result is satisfied, it is output to the result list; otherwise, it is discarded. Figure 1 Taking the residence permit as an example, if you want to obtain the information corresponding to the two target tags "name" and "ID number", you can set two regular expression sequences, namely the name extraction regular expression and the ID number extraction regular expression to perform regular matching line by line.

[0130] Compared with the technical means of deep learning models, this solution uses regular rules to extract information of the target label from the text content. The information extraction process has a very fast processing speed (ms level), has very low requirements for server system resources, and does not require GPU resources.

[0131] It should be noted that the image information structuring device of the card image of the present invention can also be extended to other document information extraction scenarios, such as table documents. The text in the table document is usually arranged in a grid, and the table header usually appears in the first column or the first row. In the process of information extraction / structuring, the image information structuring method of the collection image of the present application can also be referred to, and the position information of the text in the table document can be fully utilized to complete the information extraction process using a non-deep learning method.

[0132] It should be noted that the picture information structuring device of this embodiment is a device corresponding to the above-mentioned picture information structuring method, and the functional modules in the picture information structuring device may correspond to the corresponding steps in the picture information structuring method. The picture information structuring device of this embodiment can be implemented in conjunction with the picture information structuring method. Accordingly, the relevant technical details mentioned in the picture information structuring device of this embodiment can also be applied to the above-mentioned picture information structuring method.

[0133] It should be noted that the above-mentioned functional modules can be fully or partially integrated into one physical entity during actual implementation, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, some or all of the steps of the above method, or the above functional modules can be completed by hardware integrated logic circuits in the processor element or instructions in software form.

[0134] like Figure 7 , which is a schematic diagram of the structure of an electronic device of a preferred embodiment of the method for structuring picture information of the present invention.

[0135] The electronic device 1 may include a memory 12 , a processor 13 , and a bus, and may also include a computer program stored in the memory 12 and executable on the processor 13 , such as a picture information structuring program.

[0136] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 12 can also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 12 can also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the electronic device 1, such as code based on a picture information structured program, etc., but can also be used to temporarily store data that has been output or is to be output.

[0137] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the electronic device 1, and uses various interfaces and lines to connect the various components of the entire electronic device 1, and executes or executes programs or modules stored in the memory 12 (for example, executing a medical examination report verification program, etc.), and calls data stored in the memory 12 to execute various functions of the electronic device 1 and process data.

[0138] The processor 13 executes the operating system of the electronic device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned various picture information structuring method embodiments, for example Figure 1 Steps shown.

[0139] Exemplarily, the computer program may be divided into one or more modules, which are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into an image acquisition module 111, a detection and recognition module 112, an angle acquisition module 113, a matrix construction module 114, a correction and update module 115, a text sorting module 116, a text acquisition module 117, and a label extraction module 118.

[0140] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, and includes a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to perform part of the functions of the image information structuring method described in each embodiment of the present invention.

[0141] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0142] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one arrow is used in the figure, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.

[0143] The image information structuring method, device, equipment and medium of the present invention can obtain a collection of text information in a highly readable image by performing special sorting on the text information detection and recognition results in the extraction and information structuring application of card image information or table document image information, and subsequently obtain the information of the target label by using technical means other than deep learning models. The image information structuring method, device, equipment and medium of the present invention can obtain a text box sequence with a high degree of restoration of the original image information by performing special sorting on the text boxes detected in the image to be processed, which is convenient for subsequent text processing. Compared with the technical means of deep learning models, the image information structuring method, device, equipment and medium of the present invention have a very fast processing speed (ms level) in the information extraction process, have a very low demand on server system resources, and do not require GPU resources.

[0144] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0145] The above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for structuring image information, It is characterized in that include: Obtaining a to-be-processed image, wherein the to-be-processed image is a card image or a form document image; Using a text recognition network and a text detection network to perform text detection and recognition on the image to be processed, so as to obtain the first minimum bounding rectangle of each detected text box and the corresponding text information; Constructing an affine transformation matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box; Correcting and updating the first minimum bounding rectangle of each of the text boxes according to the affine change matrix of the image to obtain the second minimum bounding rectangle of each of the text boxes; According to the second minimum circumscribed rectangle of each of the text boxes, sorting all the text boxes in a preset order; Merge the text information of all text boxes according to the sorting result to obtain the text content in the image to be processed; Using regular rules to extract information of the target tag from the text content; Among them, using a text recognition network and a text detection network to perform text detection and recognition on the image to be processed to obtain the first minimum bounding rectangle of each detected text box and the corresponding text information, including: Inputting the image to be processed into the text detection network to perform text detection, so as to obtain the first minimum bounding rectangle of each detected text box; According to the first minimum bounding rectangle of each of the text boxes, intercepting a partial picture corresponding to the first minimum bounding rectangle area of ​​each of the text boxes from the picture to be processed; Inputting the local image corresponding to the first minimum circumscribed rectangular area of ​​each of the text boxes into the text recognition network for text recognition to obtain text information corresponding to each of the text boxes; Constructing an affine transformation matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box, including: Selecting the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratios are greater than a first preset value as the picture rotation angle; Constructing an affine transformation matrix of the image using the length, width and rotation angle of the image to be processed as parameters; Sorting all the text boxes in a preset order according to the second minimum bounding rectangle of each text box includes: According to the ordinate of the center point of the second minimum circumscribed rectangle of each text box, sorting the text boxes in ascending order; Obtain all the text boxes belonging to the same row according to a preset rule; Sort the horizontal positions of all the text boxes belonging to the same row according to the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box; The preset rule for determining that two text boxes belong to the same row is: (1) The difference in ordinates between the center points of the second minimum circumscribed rectangles of two adjacent text boxes is smaller than a spacing threshold, wherein the spacing threshold is defined as 0.3-0.7 times the average value of the height of the second smallest circumscribed rectangle of all the text boxes; (2) The difference in ordinates between the center points of the second minimum circumscribed rectangles of two adjacent text boxes Difference between the horizontal coordinate and the center point The ratio of ; When (1) and (2) are satisfied at the same time, it is determined that the two text boxes belong to the same row.

2. The method for structuring picture information according to claim 1, It is characterized in that Inputting the image to be processed into the text detection network for text detection to obtain the first minimum bounding rectangle of each of the detected text boxes, including: The image to be processed is input into a progressive expansion network, a differentiable binarization network or a pixel aggregation network for text detection to obtain a first minimum bounding rectangle of each detected text box.

3. The method for structuring picture information according to claim 1, It is characterized in that Inputting the local image corresponding to the first minimum circumscribed rectangular area of ​​each of the text boxes into the text recognition network for text recognition to obtain text information corresponding to each of the text boxes, including: The local image corresponding to the first minimum circumscribed rectangular area of ​​each text box is input into a convolutional recurrent neural network for text recognition to obtain text information corresponding to each text box.

4. The method for structuring picture information according to claim 1, It is characterized in that Correcting and updating the first minimum bounding rectangle of each of the text boxes according to the affine change matrix of the image to obtain the second minimum bounding rectangle of each of the text boxes includes: Perform a linear transformation on each vertex of the first minimum enclosing rectangle of each text box according to the affine transformation matrix of the image to obtain the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and update the first minimum enclosing rectangle of each text box according to the corrected position of each vertex of the first minimum enclosing rectangle of each text box, and use the updated first minimum enclosing rectangle of each text box as the second minimum enclosing rectangle of each text box.

5. A device for structuring image information, It is characterized in that The image information structuring device comprises: An image acquisition module is used to acquire the image to be processed, wherein the image to be processed is a card image or a form document image; A detection and recognition module, used to perform text detection and recognition on the image to be processed using a text recognition network and a text detection network, so as to obtain a first minimum bounding rectangle of each detected text box and corresponding text information; An affine change matrix acquisition module, used to construct an affine change matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box; A correction and update module, used for correcting and updating the first minimum bounding rectangle of each of the text boxes according to the affine change matrix of the image, so as to obtain the second minimum bounding rectangle of each of the text boxes; A text sorting module, used for sorting all the text boxes in a preset order according to the second minimum circumscribed rectangle of each text box; A text acquisition module, used to merge the text information of all text boxes according to the sorting result to obtain the text content in the image to be processed; A tag extraction module, used to extract information of a target tag from the text content using regular rules; Among them, using a text recognition network and a text detection network to perform text detection and recognition on the image to be processed to obtain the first minimum bounding rectangle of each detected text box and the corresponding text information, including: Inputting the image to be processed into the text detection network to perform text detection, so as to obtain the first minimum bounding rectangle of each detected text box; According to the first minimum bounding rectangle of each of the text boxes, intercepting a partial picture corresponding to the first minimum bounding rectangle area of ​​each of the text boxes from the picture to be processed; Inputting the local image corresponding to the first minimum circumscribed rectangular area of ​​each of the text boxes into the text recognition network for text recognition to obtain text information corresponding to each of the text boxes; Constructing an affine transformation matrix of the image according to the length and width of the image to be processed and the rotation angle of the first minimum circumscribed rectangle of the text box, including: Selecting the median of the rotation angles of the first minimum circumscribed rectangles of all the text boxes whose aspect ratios are greater than a first preset value as the picture rotation angle; Constructing an affine transformation matrix of the image using the length, width and rotation angle of the image to be processed as parameters; Sorting all the text boxes in a preset order according to the second minimum bounding rectangle of each text box includes: According to the ordinate of the center point of the second minimum circumscribed rectangle of each text box, sorting the text boxes in ascending order; Obtain all the text boxes belonging to the same row according to a preset rule; Sort the horizontal positions of all the text boxes belonging to the same row according to the minimum value of the horizontal coordinate of the vertices of the second minimum circumscribed rectangle of the text box; The preset rule for determining that two text boxes belong to the same row is: (1) The difference in ordinates between the center points of the second minimum circumscribed rectangles of two adjacent text boxes is smaller than a spacing threshold, wherein the spacing threshold is defined as 0.3-0.7 times the average value of the height of the second smallest circumscribed rectangle of all the text boxes; (2) The difference in ordinates between the center points of the second minimum circumscribed rectangles of two adjacent text boxes Difference between the horizontal coordinate and the center point The ratio of ; When (1) and (2) are satisfied at the same time, it is determined that the two text boxes belong to the same row.

6. An electronic device, It is characterized in that The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.