Movatterモバイル変換


[0]ホーム

URL:


CN114239508A - Table restoration method and device, storage medium and electronic device - Google Patents

Table restoration method and device, storage medium and electronic device
Download PDF

Info

Publication number
CN114239508A
CN114239508ACN202111565617.4ACN202111565617ACN114239508ACN 114239508 ACN114239508 ACN 114239508ACN 202111565617 ACN202111565617 ACN 202111565617ACN 114239508 ACN114239508 ACN 114239508A
Authority
CN
China
Prior art keywords
line
lines
table line
candidate
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111565617.4A
Other languages
Chinese (zh)
Inventor
侯冰基
张治强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Wuhan Kingsoft Office Software Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Wuhan Kingsoft Office Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd, Wuhan Kingsoft Office Software Co LtdfiledCriticalBeijing Kingsoft Office Software Inc
Priority to CN202111565617.4ApriorityCriticalpatent/CN114239508A/en
Publication of CN114239508ApublicationCriticalpatent/CN114239508A/en
Pendinglegal-statusCriticalCurrent

Links

Images

Classifications

Landscapes

Abstract

The invention discloses a table restoration method and device, a storage medium and electronic equipment. Wherein, the method comprises the following steps: acquiring a table segmentation graph corresponding to an input picture, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with default table lines; identifying a first table line displayed on the semi-frame table from the table segmentation chart; determining a second table line based on the first table line, wherein the second table line is used for supplementing a default table line in the semi-frame table; and generating a table of the editing state according to the first table line and the second table line. Therefore, the method and the device realize automatic and accurate reduction of the table in the picture through the low cost method under the condition that the table in the input picture is in a missing line or a few lines, avoid the problem of low reduction efficiency of the table in the missing line or the few lines by using the traditional method, and realize the technical effects of improving the identification efficiency and the identification accuracy of the table.

Description

Form restoration method and device, storage medium and electronic equipment
Technical Field
The invention relates to the field of computers, in particular to a table restoring method and device, a storage medium and electronic equipment.
Background
In daily office and study scenes, people usually record key information by taking pictures in order to quickly record the key information on paper documents. However, after recording information by pictures, converting the information in the pictures into editable electronic documents becomes a cumbersome task.
The existing picture identification technology can already identify the text content in the picture into editable text content under the condition of ensuring certain accuracy, but the existing technology cannot accurately identify the picture under the condition that both the text content and the table lines exist in the picture to be identified. Therefore, when the table lines exist in the picture, people can only manually create a new table according to the table lines and the contents in the picture, and fill the contents (characters) recognized by naked eyes into the manually created table. The table obtained by manual reduction is easy to have errors with the table in the picture due to human errors, and meanwhile, the technical problems of low efficiency and high error rate of table reduction in a large number of pictures are caused. That is to say, the existing method has the technical problems of low efficiency and low accuracy of table reduction.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a table reduction method and device, a storage medium and electronic equipment, and aims to at least solve the technical problems of low accuracy and low efficiency of table reduction in the prior art.
According to an aspect of an embodiment of the present invention, there is provided a table restoring method, including:
obtaining a table segmentation graph corresponding to an input picture, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with default table lines;
identifying a first table line displayed on the semi-border table from the table segmentation graph;
determining a second table line based on the first table line, wherein the second table line is used to supplement a default table line in the semi-bounding table;
and generating the table in an editing state according to the first table line and the second table line.
Optionally, the determining a second table line based on the first table line comprises:
supplementing a detection line between two adjacent first table lines, wherein the detection line and the two adjacent first table lines form a closed frame, and each detection line is respectively provided with a number;
the second table line is determined from the probe lines.
Optionally, the supplementing a probe line between two adjacent first table lines includes:
acquiring a reference slope for supplementing the default table line from two adjacent first table lines;
and drawing the detection line according to the reference slope between two adjacent first table lines.
Optionally, the determining the second table line from the probe lines comprises:
determining a text box of text content in the half-frame table;
obtaining candidate table lines which are not intersected with the text box in the detection lines;
selecting at least one of the candidate table lines as the second table line.
Optionally, the obtaining of candidate table lines in the probe line that are not intersected with the text box includes:
sequentially acquiring the intersection state between each detection line and each edge of the text box;
deleting the detection line if the detection line intersects at least one edge of the text box;
if the detection line does not intersect with each edge of the text box, retaining the detection line;
determining the remaining probe lines as the candidate table lines.
Optionally, the selecting at least one of the candidate table lines as the second table line comprises:
determining a number for each of the candidate table line configurations;
determining a plurality of candidate table lines with continuous numbers as a group of table line segments;
and determining a candidate table line from each group of the table line segments as a second table line.
Optionally, the determining the candidate table lines with consecutive numbers as a group of table line segments includes:
controlling the first pointer and the second pointer to move at a first speed respectively according to a target direction;
controlling the second pointer to stop moving and the first pointer to move at a second speed in the case that the first pointer and the second pointer detect a first candidate table line which does not intersect with the text box;
determining the first candidate table line which is not intersected with the text box and the reference table line as a group of table line segments under the condition that the first pointer detects the reference table line.
Optionally, the determining a candidate table line from each group of table line segments as a second table line includes:
traversing the table line segment;
and determining the weight of the candidate table line of the table line segment, and taking the candidate table line with the larger weight as a second table line.
Optionally, after the determining a second table line based on the first table line, further comprising:
acquiring the display forms of the first table line and the second table line;
inputting the image carrying the first table line and the second table line into a calculation module to obtain a calculation result under the condition that the display forms of the first table line and the second table line are not table lines meeting the display condition;
and reconstructing the first table line and the second table line which meet the display condition according to the calculation result.
Optionally, the inputting the image carrying the first table line and the second table line into a calculation module to obtain a calculation result, and reconstructing the first table line and the second table line meeting the display condition according to the calculation result includes:
in the calculation module, calculating coordinate information of an original cell formed between the first table line and the second table line according to a connected domain between the first table line and the second table line, wherein the coordinate information includes: the coordinates of the starting point of the original cell, the coordinates of the gravity center of the original cell and the coordinates of the end point of the original cell;
determining each cell edge line of the original cell according to the coordinate information, and deleting each cell edge line;
and drawing a new cell meeting the display condition based on the coordinate information.
Optionally, after the identifying the first table line displayed on the semi-border table from the table segmentation map, the method further includes:
determining a first table line of a first length as a reference table line;
determining second lengths of other first table lines than the reference table line, and adjusting the second lengths of the other first table lines to be consistent with the first lengths.
According to another aspect of the embodiments of the present invention, there is also provided a table restoring apparatus, including:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a table segmentation chart corresponding to an input picture, the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with a default table line;
the identification unit is used for identifying a first table line displayed on the semi-frame table from the table segmentation chart;
a determining unit, configured to determine a second table line based on the first table line, where the second table line is used to supplement a default table line in the semi-border table;
and the restoring unit is used for generating the table in an editing state according to the first table line and the second table line.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the above table restoring method when running.
According to still another aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory and a processor, where the memory stores a computer program, and the processor is configured to execute the above table restoring method through the computer program.
In the embodiment of the invention, a table segmentation graph corresponding to an input picture is obtained, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with a default table line; identifying a first table line displayed on the semi-frame table from the table segmentation chart; determining a second table line based on the first table line, wherein the second table line is used for supplementing a default table line in the semi-frame table; and generating a table of the editing state according to the first table line and the second table line. Therefore, the method and the device realize automatic and accurate reduction of the table in the picture through the low cost method under the condition that the table in the input picture is in a missing line or a few lines, avoid the problem of low reduction efficiency of the table in the missing line or the few lines by using the traditional method, and realize the technical effects of improving the identification efficiency and the identification accuracy of the table.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic diagram of a table restore system in a hardware environment, according to an embodiment of the invention;
FIG. 2 is a flow diagram of an alternative form reduction method according to an embodiment of the invention;
FIG. 3 is a schematic flow chart of a process for restoring a table according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of another embodiment of a process for restoring a table;
FIG. 5 is an exemplary diagram of a text box restore in a table according to an embodiment of the invention;
FIG. 6 is a schematic diagram of another embodiment of performing a reduction process on a table in accordance with the present invention;
FIG. 7 is an exemplary diagram of a form graph according to an embodiment of the invention;
FIG. 8 is a schematic diagram of a form graph reduction process according to an embodiment of the present invention;
FIG. 9 is a diagram illustrating another example of performing a restore process on a table picture according to an embodiment of the present invention;
FIG. 10 is a schematic illustration of yet another exemplary reduction process for a form graph in accordance with an embodiment of the invention;
FIG. 11 is a table illustrating an edit status of the table after the table is restored according to an embodiment of the invention;
FIG. 12 is a diagram illustrating another example of performing a restore process on a table picture according to an embodiment of the present invention;
FIG. 13 is a diagram illustrating another example of performing a restore process on a table picture according to an embodiment of the present invention;
FIG. 14 is a diagram illustrating another example of performing a restore process on a table picture according to an embodiment of the present invention;
FIG. 15 is a schematic diagram of another embodiment of a table picture restoration process according to the present invention;
FIG. 16 is a table illustrating an edit status of the table after the table is restored according to an embodiment of the invention;
FIG. 17 is a schematic diagram of an alternative table recovery apparatus according to an embodiment of the present invention;
fig. 18 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the terms "horizontal direction" and "lateral direction" in the specification and claims of the present invention and the above-mentioned drawings refer to a direction parallel to the upper and lower boundary lines of the page of the paper document or the electronic document, and it is understood that the direction is a direction in which the user normally browses. The terms "vertical direction" and "longitudinal direction" in the present invention refer to a direction parallel to the left and right boundary lines of a paper document or an electronic document page, corresponding to the "horizontal direction". It is to be understood that the "vertical direction" is perpendicular to the "horizontal direction" in the present invention.
According to an aspect of the embodiments of the present invention, a table restoring method is provided, and optionally, as an optional implementation manner, the table restoring method may be, but is not limited to, applied to a table restoring system in a hardware environment as shown in fig. 1. The table recovery system may include, but is not limited to, aterminal device 102, a network 104, aserver 106, and a database 108. A target client (as shown in fig. 1, the target client may be a client for OCR recognition, which is used to restore a picture file to a table file in an edited state) runs in theterminal device 102. Theterminal device 102 includes a human-computer interaction screen, a processor and a memory. The human-computer interaction screen is used for displaying an operation interface of the OCR recognition client; and the system is also used for providing a man-machine interaction interface to receive the input picture to be identified for uploading by the user. The processor is configured to generate an interaction instruction in response to the human-computer interaction operation, and send the interaction instruction to theserver 106. The memory is used for storing relevant attribute data, such as OCR recognition parameter data, recognition algorithm data, intermediate data in the recognition process and the like.
The specific process comprises the following steps: in step S102, an input picture to be recognized is obtained from a client running in theterminal device 102, where a picture file to be input includes form image information to be restored; in step S104, theterminal device 102 sends the picture to be recognized to theserver 106 through the network 104. Theserver 106 executes steps S106-S114, and step S106, acquires a table segmentation chart corresponding to the input picture; step S108, identifying a first table line displayed on the semi-frame table from the table segmentation graph; step S110, determining a second table line based on the first table line, wherein the second table line is used for supplementing a default table line in the semi-frame table; in step S112, a table of the edit status is generated based on the first table line and the second table line. Then, theserver 106 transmits the table of the editing status to theterminal device 102 through the network 104 as by step S114, and finally displays the table of the editing status on theterminal device 102 as by step S116.
As another alternative, when theterminal device 102 has a relatively large computing processing capability, the steps S106 to S112 may also be performed by theterminal device 102. Here, this is an example, and this is not limited in this embodiment.
Optionally, in this embodiment, the terminal device may be a terminal device configured with a target client, and may include, but is not limited to, at least one of the following: mobile phones (such as Android phones, iOS phones, etc.), notebook computers, tablet computers, palm computers, MID (Mobile Internet Devices), PAD, desktop computers, smart televisions, etc. The target client may be a video client, an instant messaging client, a browser client, an educational client, etc. Such networks may include, but are not limited to: a wired network, a wireless network, wherein the wired network comprises: a local area network, a metropolitan area network, and a wide area network, the wireless network comprising: bluetooth, WIFI, and other networks that enable wireless communication. The server may be a single server, a server cluster composed of a plurality of servers, or a cloud server. The above is merely an example, and this is not limited in this embodiment.
As an alternative implementation, as shown in fig. 2, the table restoring method includes:
s202, obtaining a table segmentation graph corresponding to an input picture, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with default table lines;
s204, identifying a first table line displayed on the semi-frame table from the table segmentation graph;
s206, determining a second table line based on the first table line, wherein the second table line is used for supplementing a default table line in the semi-frame table;
s208, generating a table of the editing state according to the first table line and the second table line.
It is understood that the input picture may be a picture to be recognized received by the client, and the picture includes a form image that needs to be recognized and restored. And obtaining the table segmentation image after carrying out image segmentation processing on the table image in the picture to be identified. The image segmentation method may be a threshold segmentation method, a region segmentation method, an edge segmentation method, or a histogram method. In an alternative mode, the identification can be performed along with the picture to be identified based on the neural network model, so as to obtain the position information of the table line. In this embodiment, the method of performing the image segmentation processing operation on the picture to be recognized is not limited.
Meanwhile, it should be understood that after the image segmentation operation is performed on the input image, binarization processing is further performed to obtain a binary image in which the gray values of all the pixel points are set to 0 or 1. Fig. 3 (b) is a schematic diagram of a binary image, that is, both the text portion and the blank portion are displayed in pure black, and only the table line displayed in white is retained. By carrying out segmentation operation and binarization processing on the image, the obtained image data volume is reduced, and the outline and the line of the target image can be highlighted so as to improve the efficiency of the subsequent table restoration operation.
Further, the above-described half-frame table is explained. Tables can be divided into three categories according to the number of lines: wireless meters, half-frame meters, and full-frame meters. A wireless table, i.e. a table without any lines; a half-frame table, i.e. a table lacking a part of the lines, is not enough to form a full enclosure structure, e.g. a table containing only two horizontal lines; the horizontal and vertical lines of the full-frame table are clear, and each cell has four complete edges. All three types of tables need to be stored in a full-frame mode in the process of restoring, otherwise, the computer cannot store the line information of the tables. The half-frame table in this embodiment is a table of default table lines, that is, a table formed by table lines with less than 4 sides, and may refer to a table only containing table lines in a horizontal direction or a table only containing incomplete table lines in a horizontal direction, for example; or may refer to a table containing only vertical direction table lines or a table containing only incomplete vertical direction table lines. The half-frame table is reduced to a full-frame table including both the horizontal direction table lines and the vertical direction table lines through the above embodiment, and the diagram (a) in fig. 3 is an example of a half-frame table, that is, only a plurality of horizontal direction table lines exist, but no vertical direction table line exists, and a full-enclosure structure cannot be formed at the same time.
In this embodiment, the first table line and the second table line may be either the horizontal table line or the vertical table line. For example, when the first table line is a horizontal table line, the second table line is a vertical table line; when the first table line is a vertical table line, the second table line is a horizontal table line.
Specifically, the first table line and the second table line may be determined by existing table lines of the identified half-frame table. In an optional manner, in a case that the identified semi-frame table only includes a horizontal table line, the first table line is a horizontal table line, and a vertical second table line may be determined according to the horizontal first table line.
Further, after the first table line and the second table line are determined, the first table line and the second table line may be drawn in a form of a cell, and then the cell may be entered into the client. In the client, the cells in the entered table file may be further edited, including but not limited to editing the table lines in a manner of deleting, moving, and the like, and filling text content in the cells, or editing text content in the cells that have been identified. It is understood that the editable form file may be a half-frame form identified and determined to be the same as the form in the input picture, or may be a full-frame form determined based on the input picture.
It is understood that after supplementing the default second table line, the table can be further processed to obtain a table of the edit status, including but not limited to a rule algorithm and a graph neural network algorithm, and the embodiment does not limit the algorithm for implementing the final restore operation. Further, after the first table line and the second table line are determined, the first table line and the second table line may be drawn in a form of a cell, and then the cell may be entered into the client. In the client, the cells in the entered table file may be further edited, including but not limited to editing the table lines in a manner of deleting, moving, and the like, and filling text content in the cells, or editing text content in the cells that have been identified. It is understood that the editable form file may be a half-frame form identified and determined to be the same as the form in the input picture, or may be a full-frame form determined based on the input picture. The edit status refers to that the table can be subjected to an edit process, such as entering text content in the table, modifying text content, inserting pictures, adding attachments, and the like.
The method of dividing the table corresponding to the input picture is described with reference to the schematic diagram shown in fig. 3. As shown in fig. 3 (a), the picture is an input picture to be recognized received by the client, and the picture includes a table with only horizontal table lines. After the image segmentation processing is performed on the input picture, a table segmentation map as shown in (b) of fig. 3 can be obtained. As shown in fig. 3 (b), the text information in the original table is hidden, and only the horizontal table lines in the original input picture are retained. Meanwhile, since the graph (b) in fig. 3 is obtained from the original input picture through image segmentation processing, and the original input picture has distortion of the table lines due to the angle problem, the horizontal table lines in the area indicated by the arrow in the table segmentation graph also have the line distortion problem. After the table segmentation graph is further processed, and the text information in the original input picture is filled into the table, the restored table shown in (c) of fig. 3 can be obtained, that is, as shown in (c) of fig. 3, through the steps S204 to S206, the twisted transverse table lines are restored into the horizontal table lines, and meanwhile, the appropriate vertical table lines are supplemented.
In the embodiment of the invention, a table segmentation graph corresponding to an input picture is obtained, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with a default table line; identifying a first table line displayed on the semi-frame table from the table segmentation chart; determining a second table line based on the first table line, wherein the second table line is used for supplementing a default table line in the semi-frame table; the table in the editing state is generated according to the first table line and the second table line, so that the table in the picture is automatically and accurately restored through the low cost method under the condition that the table in the input picture is in line missing or line lacking, the problem that the restoring efficiency of the table in the line missing or line lacking is low through the traditional method is solved, and the technical effects of improving the table recognition efficiency and recognition accuracy are achieved.
As an alternative implementation, the determining the second table line based on the first table line includes:
s1, supplementing a detection line between two adjacent first table lines, wherein the detection line and the two adjacent first table lines form a closed frame, and each detection line is respectively provided with a number;
s2, determining a second table line from the detection lines;
two alternative embodiments of the above method are described in detail below with reference to fig. 4. As shown in fig. 4, (b) in fig. 4 is a table division diagram of a half-frame table, and as shown in (a) and (c) in fig. 4, a partial enlarged view of the (b) in fig. 4 with a second table line added thereto is shown.
In an alternative, as in (a) of fig. 4, a total of four first table lines are shown. The probe lines may be added by complementing the probe lines between two adjacent first table lines, such as between a first and a second, between a second and a third and between a third and a fourth, respectively. As shown in the figure, 8 detection lines are supplemented between every two adjacent first table lines, and 24 detection lines are supplemented in total, so that the two adjacent first table lines form a closed frame, and further, a second table line is determined from the added 24 detection lines;
in another alternative, as shown in (c) of the figure, a total of four first table lines are shown, in this way, the detection lines are directly supplemented between the first line and the fourth line which are farthest away, a total of 7 detection lines are provided, and two adjacent first table lines form a closed frame through the 7 detection lines. Further, a second table line is determined from the added 7 detection lines;
in yet another alternative, in the case that the obtained first table line already includes the outline frame table line, a detection line may be supplemented between the two adjacent end points corresponding to the outline frame line to form a closed frame with two adjacent first table lines, and then a second table line may be determined from the detection lines determined according to the outline frame line.
Through this embodiment, adopt and supply the gauge line between two adjacent first table lines, wherein, the gauge line will form closed frame with two adjacent first table lines, every gauge line disposes the serial number respectively, determine second table line from the gauge line again, thereby realized supplementing the gauge line according to current table line, and further determine the effect of suitable second table line in the detection line that supplyes, and then realize that the preliminary table of obtaining the completion line more laminates the display effect of the table in the input picture, reach the technological effect that improves the accuracy that the table was restoreed.
The adjacent lines may be closest table lines to each other in terms of distance, may also be farthest table lines to each other in terms of distance, or may also be adjacent table lines of the outer frame. The probe line is used to draw a plurality of line segments (i.e., probe lines) crossing the first table line at equal or unequal intervals on the first table line with reference to the line direction of the first table line, and the plurality of line segments are arranged in parallel. In an alternative embodiment of the invention, the probe lines are drawn at equal intervals in the first table line in units of every 7 pixels. The number refers to a mark for identifying the detection lines, and the initial numbers of each detection line may be identical, for example, 1; the initial number of each detection line may also be increased by 1 one by one in ascending order along the horizontal direction or the vertical direction, for example, the initial number of the first detection line is 1, the initial number of the second detection line is 2, the initial number of the third detection line is 3, and so on.
As an alternative embodiment, the supplementing the probe line between two adjacent first table lines includes:
s1, acquiring a reference slope for supplementing the default table line from two adjacent first table lines;
and S2, drawing a detection line according to the reference slope between two adjacent first table lines.
It is understood that the above method of obtaining the reference slope may specifically be: calculating the slope of a certain line segment of the first table line, and taking the slope as a first slope; the slope of the complete line of the first table line can be calculated and used as the first slope; the first table line may be divided into a plurality of line segments, the slope of each line segment is calculated, and the average value of the slope is taken as the first slope.
Taking the calculation of the slope of the complete line of the first form line as an example, the specific calculation method is to obtain the coordinate value (X) of the starting point of the first form line1,Y1) And coordinate values (X) of the end point of the first table line are acquired2,Y2) By | Y2-Y1|/|X2-X1And | calculating formula, and taking the calculated value as the first slope.
Further, after the first slope is obtained by the method, a reference slope related to the first slope is determined. It is to be understood that the reference slope is used for determining the slope of a probe line perpendicular to the first table line and located between the current first table line and the next first table line, and therefore, it is assumed that the first slope value k is obtained by the above method1Then a reference slope corresponding to the first slope described above
Figure BDA0003421870450000091
Thereby determining a reference slope k of the probe line associated with the current first table line2
In another alternative, the first slope may also be obtained by obtaining coordinates of a start point and an end point of the first table line, calculating a slope of a straight line between the two points according to the coordinate information of the start point and the end point, and using the slope as the first slope of the first table line. It is to be understood that after the reference slope is obtained according to the above method, the probe lines may be additionally drawn between the adjacent first table lines in an equally spaced manner. In another embodiment, after the reference slope is obtained, the probe lines may be drawn according to actual requirements, for example, a fixed number of probe lines may be additionally drawn between adjacent first table lines according to actual requirements, or the probe lines may be additionally drawn between adjacent first table lines in a non-equal interval manner, where a specific manner of drawing the probe lines is not limited herein. The above embodiment will be specifically described below with reference to fig. 4 and 5. Fig. 4 (b) is a table division diagram of a half-frame table, and fig. 4 (a) is a partially enlarged view of fig. 4 (b) with a probe line added thereto. Taking the first table line in the diagram (a) in fig. 4 as an example, the first table line is first divided into two line segments (divided by the position of an inflection point), the slope of each line segment is obtained, the average value is obtained according to the slopes of the two line segments, the formula is (the slope of the first line segment + the slope of the second line segment)/2, and the calculation result is taken as the first slope.
It is to be understood that, since the graph (a) in fig. 4 is a table segmentation graph, each point herein may be each pixel point on the first table line;
under the condition that a first slope corresponding to the first table line is determined, a reference slope value, namely the slope value of the detection line associated with the first table line of the current table, is determined according to a negative inverse value of the first slope;
and then starting from the initial coordinate point at the leftmost end of the first table line, determining the detection lines between the first table line and the second first table line at equal intervals according to the reference slope value, and drawing one detection line at the same interval, namely drawing to obtain all the detection lines between the first table line and the second first table line. According to the above method, the probe line corresponding to the second first table line is continuously plotted for the second first table line, so as to obtain the table segmentation map after the probe line is supplemented as shown in (a) of fig. 4.
Alternatively, if the table division diagram in fig. 4 is a 768-resolution picture, and the line width of the first table line is 3 pixels, the interval of the above-mentioned detection lines may be set to 7 pixels, it can be understood that the relationship between the above-mentioned line width and the interval length of the detection lines may be set according to actual needs, and the relationship between the line width and the interval length of the detection lines shown in the diagram (a) in fig. 4 is only an example, and the above-mentioned method of the present solution is not limited at all.
In another alternative, in the case that all the probe lines corresponding to each first table line are determined, the probe lines may not be drawn in the table segmentation map at all, and the candidate segments may be stored in the pixel point array of each first table line in the form of a pixel point value group, so as to facilitate subsequent numerical value calculation.
In the embodiment of the invention, the reference slope for supplementing the default table line is obtained from two adjacent first table lines; and drawing a detection line between two adjacent first table lines according to the reference slope, thereby realizing automatic probe line supplement, avoiding adopting a method of manually creating a new table, and realizing the technical effect of improving the table recovery efficiency.
As an alternative embodiment, the determining the second table line from the probe lines includes:
s1, determining a text box of the text content in the semi-border table;
s2, obtaining candidate table lines which are not intersected with the text box in the detection lines;
and S3, selecting at least one candidate table line as a second table line.
It is to be understood that the text box is a virtual edge that is circumscribed to pixels indicating text content, as shown in fig. 5, and in the case where only a few text contents of "positioning conditions" are shown in the input picture, the text box corresponding to the text contents of "positioning conditions" is a frame as shown in the right drawing in fig. 5.
As shown in fig. 6 (a), a text box between a probe line and a form line is shown. As shown in the figure, the first probe line 601 intersects the text box 602, and thus the above-described first probe line 601 is not determined as a candidate table line. Similarly, each of the detection lines is determined whether to intersect with the text box, and finally, the remaining detection lines shown in (b) of fig. 6 are determined as candidate table lines.
After the candidate table lines are determined, at least one of the candidate table lines is selected as a second table line. Alternatively, only probe lines that intersect the first table line starting point and ending point may be determined as candidate table lines. Therefore, a full-frame table is formed by the supplemented candidate table lines and the original first table line, and the full-frame table can be stored as an editable file to be stored and edited in a computer.
In the embodiment, by determining the text box of the text content in the semi-frame table, then obtaining candidate table lines in the detection line, which are not intersected with the text box, and selecting at least one candidate table line from the candidate table lines as the second table line, automatic selection of the second table line is realized, manual table reconstruction is avoided, and the table reduction efficiency is improved.
As an optional implementation, the obtaining of candidate table lines in the probe line that do not intersect with the text box includes:
s1, sequentially acquiring the intersection state between each detection line and each edge of the text box;
s2, deleting the detection line under the condition that the detection line is intersected with at least one edge of the text box;
s3, under the condition that the detection line and each edge of the text box are not intersected, the detection line is reserved;
s4, the reserved detection line is determined as a candidate table line.
Specifically, the manner of obtaining the candidate table line that does not intersect with the text box in the above-mentioned detection line may be: and after determining the edge vectors corresponding to the detection lines and the text box, determining whether the detection lines intersect with the text box according to the cross product result of the detection lines and the edge vectors of the text box. In an alternative embodiment, the determination may be made by using a cross-over test method, that is, after two specific vectors are given, the results of cross multiplication and the position relationship of the two vectors are combined to determine whether the two line segments represented by the two vectors intersect.
The following describes the above method with reference to fig. 6, as shown in fig. 6, in the diagram (a) in fig. 6, a text box inserted between a line segment of a detection line and a table line is shown, taking the first detection line 601 and the first text box 602 pointed by arrows as an example, a first vector group is determined according to the position information of the first and last pixel points of the first detection line 601, a second vector group is determined according to the position information of the first and last pixel points of the top line of the first text box 602, and the intersection of the first detection line 601 and the top line of the first text box 602 can be determined according to the cross product of the first vector group and the second vector group, so as to delete the detection line. And traversing each detection line according to the method, deleting the corresponding detection line under the condition that the table frame line segment is judged to be intersected with the text frame line segment, and keeping the detection line as a candidate table line under the condition that the detection line is judged not to be intersected with the text frame line segment. Further, a table segmentation map as shown in (b) of fig. 6 can be obtained, that is, only the detection lines that do not intersect any text box are retained. It can be understood that, for the above algorithm for sequentially judging whether the detection line intersects with the text box through traversal judgment, the computation complexity can be reduced by introducing a pruning algorithm, and the judgment efficiency is further improved. The pruning algorithm is not limited herein.
The judgment of the intersection condition between the detection line and the text box can delete or retain the detection line after the intersection judgment between the detection line and the text box is carried out once; or after the intersection judgment between each detection line and all text boxes is carried out, deleting or retaining operation of each detection line can be carried out. The specific execution order, the method is not limited.
By the embodiment, the intersection state between each detection line and each edge of the text box is sequentially obtained; deleting the detection line under the condition that the detection line is intersected with at least one edge of the text box; under the condition that the detection line is not intersected with each edge of the text box, the detection line is reserved; the reserved detection lines are determined as the candidate form lines, so that the phenomenon that detection lines which are not needed and intersect with the text are added in the half-frame reduction process is avoided, the form reduction cost is reduced through the method, and the technical effect of improving the accuracy of the form reduction is achieved.
In an optional aspect, the selecting at least one of the candidate table lines as the second table line includes:
s1, determining the number of each candidate table line configuration;
s2, determining a plurality of candidate table lines with continuous numbers as a group of table line segments;
s3, a candidate table line is determined from each group of table line segments as a second table line.
The above-described scheme is explained with reference to fig. 6. As shown in fig. 6 (a), 8 probe lines are shared between the first and second first table lines, and are numbered from left to right, for example, in the order of 1 to 8, and similarly, probe lines between the second and third first table lines and probe lines between the third and fourth first table lines may be numbered. As shown in fig. 6 (b), after the probe line intersecting the text box is deleted to obtain the candidate table lines, for the candidate table line segments between the first table line and the second first table line segment, the middle three candidate table line segments, i.e., candidate table lines No. 4, 5, and 6, may be divided into a first group of table line segments, and the rightmost candidate table line segment, i.e., table line No. 8, may be divided into a second group of table line segments; for candidate table line segments between the second first table line and the third first table line segment, the middle 2 continuous candidate table line segments, i.e., candidate table lines No. 5 and 6, may be divided into a third group of table line segments; for candidate table line segments between the third and fourth first table lines, the middle 2 consecutive candidate table line segments, i.e., candidate table lines No. 4 and 5, may be divided into a fourth set of table line segments.
Furthermore, in this embodiment, after a plurality of sets of table line segment segments are determined, one candidate table line is determined from each set of table line segments as the second table line, so that the supplemented second table line is automatically determined, and the table reduction efficiency is improved.
The number of candidate table line configurations may follow the initial number of the corresponding probe line. The consecutive numbers indicate that the numbers of the candidate table lines belonging to the same two first table lines are adjacent, for example, if the number of one candidate table line is 2, the numbers of the candidate table lines are 1 and 3, and so on, and thus the description is omitted.
Further, the determining the plurality of candidate table lines with consecutive numbers as a group of table line segments includes: controlling the first pointer and the second pointer to move at a first speed respectively according to a target direction; and in the case that the first pointer and the second pointer detect a first candidate table line which is not intersected with the text box, controlling the second pointer to stop moving, and controlling the first pointer to move at a second speed, and in the case that the first pointer detects a reference table line, determining the first candidate table line and the reference table line which are not intersected with the text box as a group of table line segments.
The first pointer and the second pointer respectively form a line segment, the extension direction of the line segment is consistent with the direction of the second table line, and the line segment moves between every two adjacent first table lines. The target direction coincides with the line direction of the first table line. For example, in the case where the first table line is a table line in the horizontal direction, the target direction is also the horizontal direction; in the case where the first form line is a form line in the vertical direction, the target direction is also the vertical direction. The first speed may be a speed set by a user or may be a system default speed, for example, 3 pixels/second; 6 pixels/second, etc. The second speed is greater than or equal to the first speed.
The above method is explained by taking fig. 6 as an example. As shown in (b) of fig. 6, from the start positions of the first table line and the second first table line, the first pointer and the second pointer are set between the first table line and the second first table line, and the first pointer and the second pointer move between the first table line and the second first table line. The starting moving speeds of the first pointer and the second pointer are the first speed, namely the starting speeds of the first pointer and the second pointer are consistent, and the first pointer and the second pointer judge whether the first pointer and the second pointer intersect with the text box between the first table line and the second first table line or not according to the cross product judgment result of the first pointer and the second pointer and the text box. And in the case that the first pointer and the second pointer detect a first candidate table line which is not intersected with the text box between the first table line and the second first table line, controlling the second pointer to stay at the first candidate table line which is not intersected with the text box, identifying the first candidate table line which is not intersected with the text box by the second pointer, and controlling the first pointer to move at a second speed.
In the case where the first pointer detects a reference form line, the first candidate form line and the reference form line that do not intersect the text box are determined as a set of form line segments. Wherein the reference table line is the last candidate table line which is not intersected with the text box and is consecutive to the first candidate table line which is not intersected with the text box in number. The last candidate table line which is not intersected with the text box is obtained by the implementation mode that the first pointer is used for detecting the candidate table line which is intersected with the text box again after moving through the first candidate table line which is not intersected with the text box, and the last candidate table line which is detected the candidate table line which is intersected with the text box again serves as the reference table line. The last one refers to the candidate form line through which the first pointer moved before "the candidate form line intersecting the text box is detected again".
After determining a group of table line segments, the first pointer and the second pointer continue to repeat the deletion detection step by taking the position of the candidate table line intersected with the text box detected again as the respective detection starting position, and further determining a new group of table line segments until the first pointer and the second pointer move to the ending positions of the first table line and the second first table line, and the detection is finished.
As an alternative, the information about the candidate table lines and the first table line is stored in the form of an array in the background.
The above method will be described by taking fig. 6 as an example. As shown in fig. 6 (b), first, the first pointer and the second pointer are controlled to move between the first table line and the second first table line along the starting positions of the first pointer and the second pointer along the first table line and the second first table line, and in the case where the first pointer and the second pointer are moved to the candidate table line with the sequence number "4", the second pointer stays at the candidate table line position with the sequence number "4", and then the first pointer sequentially traverses the subsequent table lines. In the case of moving to the candidate table line with the sequence number "7", since the candidate table line with the sequence number "7" is the first candidate table line intersecting the text box after the candidate table line with the sequence number "4" (the first candidate table line not intersecting the text box) is traversed again, the candidate table line "6" is determined as the reference table line. The candidate table line with sequence number "4" to the candidate table line with sequence number "6" are determined as a set of table line segments.
Then, the above-described flow is repeatedly executed. And moving the second pointer to the candidate table line with the sequence number of 7, wherein the first pointer and the second pointer move at a first speed, and when a first candidate table line which does not intersect with the text box, namely the candidate table line with the sequence number of 8, is detected, the second pointer is controlled to stop moving and stay at the position of the candidate table line with the sequence number of 8, and the first pointer is controlled to continue moving at a second speed until the first pointer moves to the termination positions of the first table line and the second first table line, and a new candidate table line which does not intersect with the text box is not detected, so that the candidate table line with the sequence number of 8 is determined as a group of table line segments.
Further, table line segments with numbers of "5" and "6" in the candidate table line segments between the second first table line and the third first table line can be determined as a set of line segment segments. Table line segments with numbers of "4" and "5" in the candidate table line segments between the third first table line and the fourth first table line can also be determined as a group of line segment segments.
The determining a candidate table line from each group of table line segments as a second table line includes: passing through the table line segments; the weights of the candidate table lines of the table line segment are determined, and the candidate table line with the larger weight is used as the second table line.
The above method will be described by taking fig. 6 as an example. In particular, the remaining second table line may be determined by voting. As shown in fig. 6 (b), since four candidate table line segments with numbers "4", "5", "6", and "8" exist for the candidate table line segment between the first table line and the second first table line, the numbers "4", "5", "6", and "8" each get a vote after the first round of voting;
aiming at candidate table line segments in the middle of the second first table line and the third first table line, two candidate table line segments with the sequence numbers of 5 and 6 exist, and then a ticket is respectively cast for the table line segments with the sequence numbers of 5 and 6;
for candidate table line segments in the middle of the third first table line and the fourth first table line, two candidate table line segments with the sequence numbers of 4 and 5 exist, and then a ticket is respectively cast for the table line segments with the sequence numbers of 4 and 5;
so far, the line segment of the candidate table No. 5 has the highest vote, and the line segments of the candidate table No. 5 exist between every two rows, and can be continuously formed into a whole longitudinal table line segment, so that the longitudinal table line segment formed by connecting the three line segments of the candidate table No. 5 is confirmed to be the second table line, that is, as shown in (c) of fig. 6.
It can be understood that, in the case that there are a plurality of second table lines which have the same winning vote and are longitudinally connected to form a group that passes through the first table line and the fourth first table line, one of the second table lines may be selected as a second table line according to needs, for example, one of the leftmost positions in a group of adjacent longitudinal table line groups having the same length may be selected as the second table line, or one of the central positions in a group of adjacent longitudinal table line groups having the same length may be selected as the second table line, or the same group of longitudinal table lines may be retained, and a subsequent deletion operation may be performed according to actual needs.
By the embodiment of the application, after the pointer allocation sequence number and the voting counting method are adopted, the vertical form line with the highest vote is determined, so that the supplement of the vertical form line is completed, the automatic alignment of the form line segments between the form rows is realized, and a full-frame form is obtained by supplementing. That is, according to the embodiments of the present application, accurate table reduction is achieved at a simple computational cost, and a technical effect of improving table reduction efficiency and accuracy is achieved.
In an optional embodiment, after determining the second table line based on the first table line, the method further includes:
s1, acquiring the display forms of the first table line and the second table line;
s2, inputting the images carrying the first table line and the second table line into a calculation module to obtain a calculation result under the condition that the display forms of the first table line and the second table line are not table lines meeting the display condition;
s3, the first and second table lines satisfying the display condition are reconstructed based on the calculation result.
It should be understood that, as shown in (c) of fig. 6, the table file obtained in the above manner is merely supplemented with the second table line on the basis of the first table line, but there still exists a table formed by the first table line and the second table line which is not formed by horizontal and vertical lines, that is, the first table line is not horizontal or vertical; the case where the second form line is not vertical or horizontal, as in the case where there is a twist in the four first form lines shown in fig. 6(c), the second form line corresponding to the supplement of the first form line is also deviated from the vertical direction. That is, the first table line and the second table line determined by the above method are table lines corresponding to the positional relationship therebetween, but do not necessarily satisfy the condition of matching with the horizontal direction or the vertical direction, and therefore, it is necessary to redraw the first table line and the second table line satisfying the display condition based on the relationship between the original first table line and the second table line.
Further, after the graph (c) in fig. 6 is recognized, the display forms of the first table line and the second table line are further acquired. It is understood that the display form indicates the degree of coincidence of the form line with the horizontal direction or the vertical direction.
In a case where it is determined that the first table line and the second table line do not satisfy the display condition, the image including the first table line and the second table line is input to a calculation module to obtain a table line that matches the horizontal direction or the vertical direction.
Optionally, the inputting the image carrying the first table line and the second table line into a calculation module to obtain a calculation result, and reconstructing the first table line and the second table line meeting the display condition according to the calculation result includes:
s1, in the calculating module, calculating coordinate information of an original cell formed between the first table line and the second table line according to a connected domain between the first table line and the second table line, where the coordinate information includes: the coordinates of the starting point of the original cell, the coordinates of the gravity center of the original cell and the coordinates of the end point of the original cell;
s2, determining each cell edge line of the original cell according to the coordinate information, and deleting each cell edge line;
s3, new cells satisfying the display condition are drawn based on the coordinate information.
As an optional mode, specifically, row lines and column lines of the curved table can be segmented through a deep learning segmentation model, intersection points of the row lines and the column lines are used as potential cell vertexes, cells are searched according to a preset searching mode, and cell detection of the table is completed; counting the distances between the row lines and the column lines of all the tables which can form the unit cells, and correcting the bending table according to the relative distances; and mapping the text to the corrected table by using the relative position to complete table reconstruction.
A specific implementation of the above-described embodiment will be described below.
S1, dividing the row line and the column line of the bending table respectively by using the deep learning model as shown in FIG. 12;
s2, as shown in fig. 13, denoising the curved table lines obtained in step S1, removing short-length line segments, and numbering the pixels of each table line using connected domains;
s3, as shown in fig. 14, traverse the row line and column line graphs, find the pixels belonging to both the row line and the column line, and number all the potential vertices as potential cell vertices, where the numbering format is (row connected domain sequence number, column connected domain sequence number);
and S4, searching all possible cells in the cell vertex set in S3 according to a preset search strategy to obtain the structure of the table. The search strategy is as follows: searching according to the sequence of the upper left corner, the upper right corner, the lower right corner and the lower left corner, and after searching, the searched cells are as shown in FIG. 15:
and S5, matching the detected text with the cell. Calculating whether the center of the text falls into the area of a certain cell to match the text with the cell;
s6, the curved form lines are corrected and the position of the text is adjusted, and the two are combined to obtain the final result, as shown in fig. 16.
In this embodiment, in the calculation module, the coordinate information of the original cell formed between the first table line and the second table line is calculated according to the connected domain between the first table line and the second table line, where the coordinate information includes: the coordinates of the starting point of the original cell, the coordinates of the gravity center of the original cell and the coordinates of the end point of the original cell; determining each cell edge line of the original cell according to the coordinate information, and deleting each cell edge line; and drawing a new cell meeting the display condition based on the coordinate information, thereby realizing reconstruction of the table with the distorted table lines, avoiding artificially newly building the table and filling text contents, and improving the efficiency of restoring the table.
In an optional embodiment, after identifying the first table line displayed on the semi-frame table from the table segmentation map, the method further includes:
s1, determining a first table line with a first length as a reference table line;
s2, determining the second lengths of the first table lines other than the reference table line, and adjusting the second lengths of the first table lines to be consistent with the first lengths.
It is understood that, according to the above method, in the case where there are first table lines having different lengths in the weak table segmentation chart after the table segmentation chart is acquired, other first table lines may be filled to the same length with reference to one first table line of the first length (i.e., the longest first table line).
In addition to this, the first length may be indicated as the length of the first table line having the largest number of lengths, and the second lengths of the other first table lines may be adjusted to the first length. The adjustment may be understood as lengthening the length of the first form line or shortening the length of the first form line.
According to the embodiment, one first table line with the longest length is determined to serve as a reference table line, and then the lengths of other first table lines are filled according to the length of the reference table line to obtain the updated first table line, so that the technical effect of restoring an incomplete table image is achieved.
In an optional embodiment, the filling the text content to the position of the text box, restoring to obtain a table in an editing state, and filling the text content into the text box to obtain the restored table further includes: and hiding the table line segment which is still in the display state currently in the plurality of drawn candidate table line segments.
It can be understood that after the first table line and the second table line in the table segmentation graph are supplemented by the method and the text content is filled in, the editing options can be continuously provided, so that the hidden editing of the supplemented table lines is realized according to the actual needs of the user.
Through the embodiment, after the form filling is completed, the editing operation on the form lines is further provided, so that the free selection and the secondary editing of the filled form lines are realized, the form is restored more accurately, and the accuracy of the form restoration is improved.
The following describes a specific embodiment of the present application with reference to specific embodiments shown in fig. 7 to 11 and a flowchart shown in fig. 2.
As shown in fig. 2, step S202 is performed, and then step S204 is performed;
as shown in fig. 7, a semi-frame table not including the vertical table line is displayed in the input picture, and the binarized image shown in fig. 8 is obtained by performing picture segmentation and binarization processing on the input picture. In the image shown in fig. 8, three horizontal table lines already included in the original input map, and equally spaced vertical table candidate line segments corresponding to the slopes of the three horizontal table lines, respectively, are shown. Taking the 768-resolution picture shown in fig. 8 as an example, the line width of three horizontal table lines is 3 pixels, and the interval between vertical lines is set to a fixed value of 7 pixels. Also shown in FIG. 8 are several text box line segments corresponding to the text content in FIG. 7.
Then, step S206 is executed;
as shown in fig. 9, two end points of each longitudinal candidate table line segment and two end points of each side of the text box are respectively configured into two respective vectors, and by using methods such as cross product determination, it is possible to determine whether the line segment intersects the text box, and delete the longitudinal candidate table line segment intersecting the text box, so as to obtain the binary image shown in fig. 9.
Then as step S208;
it will be appreciated that the fast and slow pointer (i.e., the first and second pointers mentioned above) methods may be utilized herein to find consecutive candidate table segments. Meanwhile, the columns where the reserved vertical lines are located can be counted, each line segment is added, the column where the line segment is located is voted, each continuous segment has a column with the highest vote number, and the candidate table line segment of the column is reserved. At this point, the supplemented vertical table segments between rows have been automatically aligned to obtain the binary map shown in fig. 10.
And finally, filling the text content to the position of the text box, and restoring to obtain the table in the editing state.
After the vertical table lines are supplemented, a full-frame table corresponding to the input picture shown in fig. 7 can be obtained as the final restoration result shown in fig. 11 according to a rule algorithm or through a neural network. Finally, the supplemented vertical table segments can be hidden or displayed as desired.
And the step of synchronously closing and adjusting the eyes of the virtual animal according to the adjusted monocular closing characteristic value. The obtained anchor object and the virtual animal face key points can be used for constructing a grid, and the key point data is used as texture coordinates of the graphic rendering. And then calculating the offset by using the positions of key points of the front frame and the rear frame of the anchor face. And then updating the positions of the key points of the pet face, and taking the updated key point data as the vertex coordinates of the graph rendering. And finally calling a multimedia programming interface, such as an API of DirectX or OpenGL, to generate a rendered picture.
In the embodiment of the invention, the table segmentation graph corresponding to the input picture is obtained, the first table line displayed on the semi-frame table and the text box of the text content displayed in the cells in the semi-frame table are identified from the table segmentation graph, then the line segment fragments which are not intersected with the text box are obtained from a plurality of candidate table line segments drawn based on the first table line, then the second table line is determined by using the target table line segment selected from the line segment fragments to restore the default table line in the semi-frame table, finally the text content is filled to the position in the text box to restore the table restored in the editing state, thereby realizing the accurate restoration of the table in the picture by the low-cost method under the condition that the table in the input picture is lack of lines or has few lines, and avoiding the problem that the traditional method is used for restoring and outputting the table with the lack of lines or few lines, the technical effect of improving the table identification accuracy is achieved, and the technical problems of low accuracy and low efficiency of table reduction in the prior art are solved.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
According to another aspect of the embodiment of the invention, a form restoring device for implementing the form restoring method is further provided. As shown in fig. 17, the apparatus includes:
an obtaining unit 1202, configured to obtain a table segmentation map corresponding to an input picture, where the input picture includes a half-frame table to be restored, and the half-frame table is a table of a default table line;
an identifying unit 1204, configured to identify a first table line displayed on the semi-frame table from the table segmentation map;
a determining unit 1206, configured to determine a second table line based on the first table line, where the second table line is used to supplement a default table line in the semi-frame table;
the restoring unit 1208 is configured to generate a table of the editing state according to the first table line and the second table line.
As an optional mode, the determining unit includes:
the device comprises a supplementing module, a detecting module and a judging module, wherein the supplementing module is used for supplementing a detecting line between two adjacent first table lines, the detecting line and the two adjacent first table lines form a closed frame, and each detecting line is respectively provided with a number;
a determining module for determining a second table line from the probe lines.
As an optional mode, the supplementary module further includes:
the first supplementing submodule is used for acquiring a reference slope for supplementing the default table line from two adjacent first table lines;
and the second supplementary submodule is used for drawing a detection line between two adjacent first table lines according to the reference slope.
As an optional mode, the determining module further includes:
the first determining submodule is used for determining a text box of the text content in the half-frame table;
the second determining submodule is used for acquiring candidate table lines which are not intersected with the text box in the detection lines;
and a third determining submodule for selecting at least one of the candidate table lines as a second table line.
As an optional mode, the second determining submodule is further configured to:
sequentially acquiring the intersection state between each detection line and each edge of the text box;
deleting the detection line under the condition that the detection line is intersected with at least one edge of the text box;
under the condition that the detection line is not intersected with each edge of the text box, the detection line is reserved;
the remaining probe lines are determined as candidate table lines.
As an optional mode, the determining module is further configured to:
determining the number of each candidate table line configuration;
determining a plurality of candidate table lines with continuous numbers as a group of table line segments;
a candidate table line is determined from each set of table line segments as a second table line.
As an optional manner, the determining module is further configured to:
controlling the first pointer and the second pointer to move at a first speed respectively according to a target direction; in the case that the first pointer and the second pointer detect a first candidate table line which is not intersected with the text box, controlling the second pointer to stop moving, and controlling the first pointer to move at a second speed; in the case where the first pointer detects a reference form line, the first candidate form line and the reference form line that do not intersect the text box are determined as a set of form line segments.
As an optional manner, the determining module is further configured to:
passing through the table line segments; the weights of the candidate table lines of the table line segment are determined, and the candidate table line with the larger weight is used as the second table line.
As an optional mode, the table restoring apparatus further includes:
a second obtaining unit configured to obtain a display form of the first table line and the second table line;
the calculation unit is used for inputting the images carrying the first table line and the second table line into the calculation module to obtain a calculation result under the condition that the display forms of the first table line and the second table line are not table lines meeting the display condition;
and a reconstruction unit for reconstructing the first table line and the second table line satisfying the display condition according to the calculation result.
As an optional mode, the computing unit further includes:
the calculation module is used for calculating the coordinate information of the original cell formed between the first table line and the second table line according to the connected domain between the first table line and the second table line, wherein the coordinate information comprises: the coordinates of the starting point of the original cell, the coordinates of the gravity center of the original cell and the coordinates of the end point of the original cell;
the deleting module is used for determining each cell edge line of the original cell according to the coordinate information and deleting each cell edge line;
and the display module is used for drawing the new cell meeting the display condition based on the coordinate information.
As an optional mode, the identification unit is further configured to:
determining a first table line of a first length as a reference table line;
the second lengths of the other first table lines except the reference table line are determined, and the second lengths of the other first table lines are adjusted to be consistent with the first lengths.
Optionally, in this embodiment, reference may be made to the above-mentioned method embodiments for implementing the above-mentioned unit modules, which are not described herein again.
According to another aspect of the embodiment of the present invention, there is also provided an electronic device for implementing the above table restoring method, where the electronic device may be the terminal device or the server shown in fig. 1. The present embodiment takes the electronic device as a terminal device as an example for explanation. As shown in fig. 18, the electronic device includes adisplay 1302, atransmission device 1306, aprocessor 1304 and amemory 1310, wherein thememory 1310 stores computer programs, and theprocessor 1304 is configured to execute the steps in the above-mentioned table restoring method embodiment through the computer programs.
Optionally, in this embodiment, the electronic device may be located in at least one network device of a plurality of network devices of a computer network.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
s1, obtaining a table segmentation graph corresponding to the input picture, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with default table lines;
s2, identifying a first table line displayed on the semi-frame table from the table segmentation graph;
s3, determining a second table line based on the first table line, wherein the second table line is used for supplementing the default table line in the semi-frame table;
s4, a table of the edit status is generated based on the first table line and the second table line.
Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 18 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 18 is a diagram illustrating a structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 18, or have a different configuration than shown in FIG. 18.
Thememory 1310 may be configured to store software programs and modules, such as program instructions/modules corresponding to the table restoring method and apparatus in the embodiments of the present invention, and theprocessor 1304 executes various functional applications and data processing by running the software programs and modules stored in thememory 1310, that is, the table restoring method is implemented. Thememory 1310 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, thememory 1310 may further include memory located remotely from theprocessor 1304, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. As an example, as shown in fig. 18, thememory 1310 may include, but is not limited to, an obtaining unit 1202, an identifying unit 1204, a determining unit 1206, and a restoring unit 1208 in the table restoring apparatus. In addition, the table may further include, but is not limited to, other module units in the table restoration apparatus, which is not described in detail in this example.
Optionally, thetransmitting device 1306 is used for receiving or sending data via a network. Examples of the network may include a wired network and a wireless network. In one example, thetransmission device 1306 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices to communicate with the internet or a local area Network. In one example, thetransmitting device 1306 is a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In addition, the electronic device further includes: adisplay 1302 for displaying an input picture and a table of which restoration is completed, wherein the target picture displays a face of a virtual animal subject; and aconnection bus 1308 for connecting the respective module parts in the above-described electronic apparatus.
In other embodiments, the terminal device or the server may be a node in a distributed system, where the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting a plurality of nodes through a network communication. Nodes can form a Peer-To-Peer (P2P, Peer To Peer) network, and any type of computing device, such as a server, a terminal, and other electronic devices, can become a node in the blockchain system by joining the Peer-To-Peer network.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
According to an aspect of the application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is arranged to perform the steps of the table recovery method when running. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to cause the computer device to execute the table restoring method.
Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the above methods according to the embodiments of the present invention.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the above-described division of the units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (14)

1. A method for restoring a table, comprising:
obtaining a table segmentation graph corresponding to an input picture, wherein the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with default table lines;
identifying a first table line displayed on the semi-border table from the table segmentation graph;
determining a second table line based on the first table line, wherein the second table line is used to supplement a default table line in the semi-bounding table;
and generating the table in an editing state according to the first table line and the second table line.
2. The method of claim 1, wherein determining a second table line based on the first table line comprises:
supplementing a detection line between two adjacent first table lines, wherein the detection line and the two adjacent first table lines form a closed frame, and each detection line is respectively provided with a number;
the second table line is determined from the probe lines.
3. The method of claim 2, wherein the supplementing a probe line between two adjacent first table lines comprises:
acquiring a reference slope for supplementing the default table line from two adjacent first table lines;
and drawing the detection line according to the reference slope between two adjacent first table lines.
4. The method of claim 2, wherein said determining the second table line from the probe lines comprises:
determining a text box of text content in the half-frame table;
obtaining candidate table lines which are not intersected with the text box in the detection lines;
selecting at least one of the candidate table lines as the second table line.
5. The method of claim 4, wherein the obtaining candidate table lines of the probe line that are disjoint from the text box comprises:
sequentially acquiring the intersection state between each detection line and each edge of the text box;
deleting the detection line if the detection line intersects at least one edge of the text box;
if the detection line does not intersect with each edge of the text box, retaining the detection line;
determining the remaining probe lines as the candidate table lines.
6. The method of claim 4, wherein said selecting at least one of said candidate table lines as said second table line comprises:
determining a number for each of the candidate table line configurations;
determining a plurality of candidate table lines with continuous numbers as a group of table line segments;
and determining a candidate table line from each group of the table line segments as a second table line.
7. The method of claim 6, wherein determining the plurality of candidate table lines with consecutive numbers as a set of table line segments comprises:
controlling the first pointer and the second pointer to move at a first speed respectively according to a target direction;
controlling the second pointer to stop moving and the first pointer to move at a second speed in the case that the first pointer and the second pointer detect a first candidate table line which does not intersect with the text box;
determining the first candidate table line which is not intersected with the text box and the reference table line as a group of table line segments under the condition that the first pointer detects the reference table line.
8. The method of claim 6, wherein determining a candidate table line from each set of table line segments as a second table line comprises:
traversing the table line segment;
and determining the weight of the candidate table line of the table line segment, and taking the candidate table line with the larger weight as a second table line.
9. The method of claim 1, further comprising, after said determining a second table line based on said first table line:
acquiring the display forms of the first table line and the second table line;
inputting the image carrying the first table line and the second table line into a calculation module to obtain a calculation result under the condition that the display forms of the first table line and the second table line are not table lines meeting the display condition;
and reconstructing the first table line and the second table line which meet the display condition according to the calculation result.
10. The method of claim 9, wherein inputting the image carrying the first and second form lines into a computation module to obtain a computation result, and reconstructing the first and second form lines satisfying a display condition according to the computation result comprises:
in the calculation module, calculating coordinate information of an original cell formed between the first table line and the second table line according to a connected domain between the first table line and the second table line, wherein the coordinate information includes: the coordinates of the starting point of the original cell, the coordinates of the gravity center of the original cell and the coordinates of the end point of the original cell;
determining each cell edge line of the original cell according to the coordinate information, and deleting each cell edge line;
and drawing a new cell meeting the display condition based on the coordinate information.
11. The method of any of claims 1 to 10, further comprising, after said identifying a first table line displayed on the semi-bounding table from the table segmentation graph:
determining a first table line of a first length as a reference table line;
determining second lengths of other first table lines than the reference table line, and adjusting the second lengths of the other first table lines to be consistent with the first lengths.
12. A form restoration apparatus, comprising:
the device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a table segmentation chart corresponding to an input picture, the input picture comprises a semi-frame table to be restored, and the semi-frame table is a table with a default table line;
the identification unit is used for identifying a first table line displayed on the semi-frame table from the table segmentation chart;
a determining unit, configured to determine a second table line based on the first table line, where the second table line is used to supplement a default table line in the semi-border table;
and the restoring unit is used for generating the table in an editing state according to the first table line and the second table line.
13. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to carry out the method of any one of claims 1 to 11 when executed.
14. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 11 by means of the computer program.
CN202111565617.4A2021-12-202021-12-20 Table restoration method and device, storage medium and electronic devicePendingCN114239508A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202111565617.4ACN114239508A (en)2021-12-202021-12-20 Table restoration method and device, storage medium and electronic device

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202111565617.4ACN114239508A (en)2021-12-202021-12-20 Table restoration method and device, storage medium and electronic device

Publications (1)

Publication NumberPublication Date
CN114239508Atrue CN114239508A (en)2022-03-25

Family

ID=80759683

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202111565617.4APendingCN114239508A (en)2021-12-202021-12-20 Table restoration method and device, storage medium and electronic device

Country Status (1)

CountryLink
CN (1)CN114239508A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116343247A (en)*2023-05-242023-06-27荣耀终端有限公司Form image correction method, device and equipment
CN117475459A (en)*2023-12-282024-01-30杭州恒生聚源信息技术有限公司Table information processing method and device, electronic equipment and storage medium
CN117523592A (en)*2024-01-042024-02-06南昌航空大学Seal area form line detection method

Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110598196A (en)*2019-09-162019-12-20腾讯科技(深圳)有限公司 A method, device and storage medium for extracting tabular data without outer frame
CN112528863A (en)*2020-12-142021-03-19中国平安人寿保险股份有限公司Identification method and device of table structure, electronic equipment and storage medium
CN113283355A (en)*2021-05-312021-08-20平安国际智慧城市科技股份有限公司Form image recognition method and device, computer equipment and storage medium
CN113627143A (en)*2020-05-092021-11-09北京金山数字娱乐科技有限公司Table creation method and device, electronic equipment and storage medium
WO2021237909A1 (en)*2020-05-292021-12-02深圳壹账通智能科技有限公司Table restoration method and apparatus, device, and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110598196A (en)*2019-09-162019-12-20腾讯科技(深圳)有限公司 A method, device and storage medium for extracting tabular data without outer frame
CN113627143A (en)*2020-05-092021-11-09北京金山数字娱乐科技有限公司Table creation method and device, electronic equipment and storage medium
WO2021237909A1 (en)*2020-05-292021-12-02深圳壹账通智能科技有限公司Table restoration method and apparatus, device, and storage medium
CN112528863A (en)*2020-12-142021-03-19中国平安人寿保险股份有限公司Identification method and device of table structure, electronic equipment and storage medium
CN113283355A (en)*2021-05-312021-08-20平安国际智慧城市科技股份有限公司Form image recognition method and device, computer equipment and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN116343247A (en)*2023-05-242023-06-27荣耀终端有限公司Form image correction method, device and equipment
CN116343247B (en)*2023-05-242023-10-20荣耀终端有限公司 Table image correction methods, devices and equipment
CN117475459A (en)*2023-12-282024-01-30杭州恒生聚源信息技术有限公司Table information processing method and device, electronic equipment and storage medium
CN117475459B (en)*2023-12-282024-04-09杭州恒生聚源信息技术有限公司Table information processing method and device, electronic equipment and storage medium
CN117523592A (en)*2024-01-042024-02-06南昌航空大学Seal area form line detection method
CN117523592B (en)*2024-01-042024-04-02南昌航空大学 A method for detecting form lines in seal areas

Similar Documents

PublicationPublication DateTitle
CN110874618B (en)OCR template learning method and device based on small sample, electronic equipment and medium
CN110796031B (en)Table identification method and device based on artificial intelligence and electronic equipment
CN114239508A (en) Table restoration method and device, storage medium and electronic device
US8712566B1 (en)Segmentation of a product markup image based on color and color differences
CN112052839A (en)Image data processing method, apparatus, device and medium
CN112101344B (en)Video text tracking method and device
CN109583509B (en)Data generation method and device and electronic equipment
CN111640130A (en)Table reduction method and device
WO2020060632A1 (en)Converting an image into a structured table
CN111738280A (en) An image recognition method, apparatus, device and readable storage medium
CN110309835A (en) A method and device for extracting local features of an image
CN111626919B (en)Image synthesis method and device, electronic equipment and computer readable storage medium
CN112785492A (en)Image processing method, image processing device, electronic equipment and storage medium
CN110517334A (en) Method and device for acquiring vector map data
CN115131803A (en) Document font size identification method, device, computer equipment and storage medium
CN111854683A (en) Method, device and device for elevation sampling of three-dimensional spatial data
CN116259064B (en) Table structure recognition method, table structure recognition model training method and device
WO2025050831A1 (en)Building group rendering method and apparatus, computer device, and storage medium
CN111724441B (en) Image annotation method and device, electronic device and storage medium
CN114565917A (en)Building group modeling method and device
CN114241378A (en)Method and device for generating transition video, electronic equipment and storage medium
CN111666735A (en)Image text label display method and device and storage medium
CN114037909B (en)Automatic video labeling method and system for ship name identification characters
CN108268533B (en)Image feature matching method for image retrieval
CN115115399A (en)Object recommendation method, device, equipment, medium and computer program product

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination

[8]ページ先頭

©2009-2025 Movatter.jp