Table generation method, device, electronic device and storage medium
Through identification model and text recognition technology, table location and text coordinates are determined, and target tables are generated using row and column thresholds, the problem of inability to generate tables in the prior art is solved, and the efficiency and accuracy of table recognition are improved.
Patent Information
- Application Number
- CN202210560927.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-20
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-05-20
AI Technical Summary
Existing table image recognition methods cannot determine the table frame in the table image to be identified, resulting in the inability to generate the table, especially when the table line is not closed or does not exist.
Determine the table position through the recognition model, perform text recognition, obtain text and text coordinates, determine the coordinates of candidate cells using row and column thresholds, and generate target tables.
It realizes automatic generation of tables without closed table lines, improving the efficiency and accuracy of table recognition.
Smart Images

Figure CN114898390B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, specifically to the field of table image recognition, and more specifically to a table generation method, device, electronic device, storage medium, and program product. Background Art
[0002] Currently, when recognizing an image to be recognized that contains a table, it is necessary to manually mark the position of the table in the image to be recognized and determine the table image to be recognized. For the table image to be recognized, the current table image recognition method first determines the text and each existing table line in the table image to be recognized. Based on each table line, the table frame is determined, and the text corresponding to each cell in the table frame is determined to generate a table corresponding to the table image to be recognized. In the case where there are no table lines in the table image to be recognized, or the existing table lines cannot form closed cells, the current table image recognition method cannot determine the table frame, resulting in the inability to generate a table corresponding to the table image to be recognized. Summary of the Invention
[0003] In view of the above problems, the present disclosure provides a table generation method, apparatus, electronic device, storage medium, and program product for improving table recognition efficiency.
[0004] According to one aspect of the present disclosure, a table generation method is provided, including: determining a target table image based on an image to be recognized; performing text recognition on the target table image to obtain at least one text and at least one text coordinate corresponding to each text; determining candidate coordinates of at least one candidate cell based on the at least one text and at least one text coordinate; and generating a target table corresponding to the target table image based on the candidate coordinates, at least one text and at least one text coordinate.
[0005] According to an embodiment of the present disclosure, determining a target table image based on an image to be identified includes: processing the image to be identified using a recognition model to obtain at least one position coordinate; acquiring a first table image in the image to be identified based on the at least one position coordinate; processing the first table image to determine a deflection angle; and deflecting the first table image based on the deflection angle to obtain a target table image.
[0006] According to an embodiment of the present disclosure, the text coordinates include a first text coordinate and a second text coordinate, and determining the candidate coordinates of at least one candidate cell based on at least one text and at least one text coordinate includes: determining a plurality of row boundary coordinates based on at least one first text coordinate and a row threshold; determining a plurality of column boundary coordinates based on the first text coordinate, the second text coordinate, a column threshold, a plurality of row boundary coordinates and at least one text; and determining the candidate coordinates of at least one candidate cell based on the plurality of row boundary coordinates and the plurality of column boundary coordinates.
[0007] According to an embodiment of the present disclosure, determining multiple row boundary coordinates based on at least one first text coordinate and a row threshold includes: determining at least one first row boundary coordinate and at least one second row boundary coordinate based on the vertical coordinate value of at least one first text coordinate, the vertical coordinate value of a second text coordinate, and the row threshold; and determining multiple row boundary coordinates based on at least one first row boundary coordinate and at least one second row boundary coordinate.
[0008] According to an embodiment of the present disclosure, determining multiple column boundary coordinates based on the first text coordinate, the second text coordinate, the column threshold, multiple row boundary coordinates and at least one text includes: determining the number of columns of the target table frame based on the multiple row boundary coordinates and at least one text; and determining multiple column boundary coordinates based on the number of columns of the target table frame, the horizontal coordinate value of the first text coordinate, the horizontal coordinate value of the second text coordinate and the column threshold.
[0009] According to an embodiment of the present disclosure, generating a target table corresponding to a target table image based on candidate coordinates, at least one text and at least one text coordinate includes: determining the target coordinates of each target cell based on the candidate coordinates and at least one text coordinate, and determining the target text corresponding to the target coordinates in at least one text; and generating a target table corresponding to the target table image based on the target coordinates and the target text.
[0010] According to an embodiment of the present disclosure, determining the target coordinates of each target cell based on candidate coordinates and at least one text coordinate, and determining the target text corresponding to the target coordinates in at least one text includes: determining a first area value of at least one candidate cell and a second area value of at least one text based on at least one candidate coordinate and at least one text coordinate; for each text, determining the matching degree of the text with each candidate cell respectively based on the second area value and at least one first area value, and obtaining at least one matching degree; in the case of determining that there is a matching degree greater than a preset first threshold in at least one matching degree, determining the candidate coordinates of the candidate cell as the target coordinates of the target cell, and taking the text as the target text corresponding to the target coordinates; and in the case of determining that there is no matching degree greater than the preset first threshold in at least one matching degree, and there are two matching degrees less than the preset second threshold, determining the target coordinates of the target cell based on the candidate coordinates of two candidate cells corresponding to the two matching degrees, and taking the text as the target text corresponding to the target coordinates.
[0011] Another aspect of the present disclosure provides a table generation device, including: a first determination module, used to determine a target table image based on an image to be recognized; an acquisition module, used to perform text recognition on the target table image to obtain at least one text and at least one text coordinate corresponding to each text; a second determination module, used to determine candidate coordinates of at least one candidate cell based on at least one text and at least one text coordinate; and a generation module, used to generate a target table corresponding to the target table image based on the candidate coordinates, at least one text and at least one text coordinate.
[0012] Another aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above table generation method.
[0013] Another aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above table generating method.
[0014] Another aspect of the present disclosure further provides a computer program product, including a computer program, which implements the above table generation method when executed by a processor.
[0015] According to the table generation method disclosed herein, a trained recognition model is used to process an image to be recognized, automatically obtaining a table image to be recognized, thereby improving the efficiency and accuracy of obtaining the table image to be recognized. Furthermore, the table generation method disclosed herein recognizes text within the table image to be recognized and determines the coordinates of the text. Based on the text and the coordinates, a target table corresponding to the table image to be recognized is generated. This enables the generation of a target table corresponding to the table image to be recognized even when table lines do not exist in the table image to be recognized, or when existing table lines do not form closed cells. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0017] Figure 1 A diagram schematically illustrates an application scenario of a table generation method, apparatus, electronic device, storage medium, and program product according to an embodiment of the present disclosure;
[0018] Figure 2 The flowchart of the table generation method according to the embodiment of the present disclosure is schematically shown;
[0019] Figure 3A-3B Schematically shows a principle diagram of a method for determining row boundary coordinates according to another embodiment of the present disclosure;
[0020] Figure 3C to Figure 3D Schematically shows a principle diagram of a method for determining column boundary coordinates according to another embodiment of the present disclosure;
[0021] Figure 3E to Figure 3F Schematically shows a principle diagram of a table generation method according to another embodiment of the present disclosure;
[0022] Figure 4 Schematically shows a structural block diagram of a table generating device according to an embodiment of the present disclosure; and
[0023] Figure 5 The block diagram schematically shows an electronic device suitable for implementing the table generating method according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0025] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise," "include," etc. used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0026] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0027] When expressions such as "at least one of A, B and C, etc." are used, they should generally be interpreted in accordance with the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0028] An embodiment of the present disclosure provides a table generation method, which determines a target table image based on an image to be recognized; performs text recognition on the target table image to obtain at least one text and at least one text coordinate corresponding to each text; determines candidate coordinates of at least one candidate cell based on the at least one text and at least one text coordinate; and generates a target table corresponding to the target table image based on the candidate coordinates, at least one text and at least one text coordinate.
[0029] Figure 1 The application scenario diagram of table generation according to an embodiment of the present disclosure is schematically shown.
[0030] like Figure 1 As shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or optical fiber cables.
[0031] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0032] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0033] The server 105 may be a server that provides various services, such as a background management server (for example only) that supports websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0034] It should be noted that the table generation method provided in the embodiments of the present disclosure can generally be executed by the server 105. Accordingly, the table generation apparatus provided in the embodiments of the present disclosure can generally be set in the server 105. The table generation method provided in the embodiments of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the table generation apparatus provided in the embodiments of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0035] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0036] The following will be based on Figure 1 The scene described by Figures 2 to 3F The table generation method of the disclosed embodiment is described in detail.
[0037] Figure 2 The flowchart of the table generation method according to the embodiment of the present disclosure is schematically shown.
[0038] like Figure 2 As shown, the table generation of this embodiment includes operations S210 to S240, and the table generation method can be executed by a server.
[0039] In operation S210 , a target table image is determined according to the image to be recognized.
[0040] According to an embodiment of the present disclosure, when a user wants to perform optical character recognition (OCR) on an image to be recognized, the user sends a character recognition request to a server through a user terminal. The character recognition request includes the image to be recognized. After receiving the image to be recognized, the server determines whether the image to be recognized includes a table. If the server determines that the image to be recognized includes a table, it determines the location information of the table in the image to be recognized. Based on the location information, the server captures the table image in the image to be recognized and uses the table image as the target table image.
[0041] According to another embodiment of the present disclosure, operation S210 also includes: processing the image to be recognized using a recognition model to obtain at least one position coordinate; obtaining a first table image in the image to be recognized based on the at least one position coordinate; processing the first table image to determine a deflection angle; and deflecting the first table image based on the deflection angle to obtain a target table image.
[0042] The recognition model includes a trained model for determining the position information of a table in an image to be recognized, such as a trained detection model (YOLO model). The determined image to be recognized is input into the recognition model to obtain at least one position coordinate, which includes any coordinates that can determine the position of the table area. For example, the at least one position coordinate can be the coordinates of the upper left corner of the table area and the coordinates of the lower right corner of the table area, and the at least one position coordinate can also be the coordinates of the center position of the table area. The at least one position coordinate is determined in the image to be recognized, and an image of the at least one position coordinate object is captured to obtain a first table image.
[0043] The first table image is binarized using an image binarization method to obtain a black and white image corresponding to the first table image. The image binarization method may include, for example, the Otsu threshold method. The black and white image is subjected to erosion and dilation using rectangles as erosion and dilation elements to obtain a simplified image. Based on the simplified image, it is determined whether there are straight lines in the first table image. If it is determined that there are straight lines in the first table, the at least one straight line is processed using a Hough transform to determine the first slope of each straight line. If it is determined that there are no straight lines in the first table, at least one text image in the first table image is extracted and the second slope of each text image is determined. A deflection angle is determined based on the first slope of each straight line or the second slope of each text image. For example, the deflection angle may be determined by taking the average of the first slopes of each straight line or the average of the second slopes of each text image. Based on the deflection angle, the first table image is deflected to obtain a target table image.
[0044] In operation S220, perform optical character recognition (OCR) on the target table image to obtain at least one text and at least one text coordinate corresponding to each text.
[0045] According to an embodiment of the present disclosure, the target table image is processed by using OCR to obtain at least one character and at least one character coordinate corresponding to each character. At least one character is spliced into at least one text according to at least one character coordinate and a text threshold. At least one text coordinate corresponding to each text is determined according to the at least one text. The character coordinate may include any coordinate that can determine the character, and the character coordinate may be the coordinate of the upper left corner of the rectangle to which the character belongs, or the coordinate of the center position of the rectangle to which the character belongs.
[0046] For each character coordinate, calculate the distance between the character coordinate and other character coordinates among the at least one character coordinate to obtain at least one distance. Compare the at least one distance with the text threshold. When it is determined that a distance is less than the text threshold, splice the character and another character corresponding to the distance to obtain a text.
[0047] For example, the character coordinates are all the coordinates of the upper left corner of the rectangle to which the character belongs. After processing the target table image by using OCR recognition, the at least one character obtained includes "position", "location", and "123", and the at least one character coordinate corresponding to the at least one character is "(1, 0)", "(1.5, 0)", and "(5, 0)". Calculate the distance between the character coordinate "(1, 0)" and "(1.5, 0)", and the distance between the character coordinate "(1, 0)" and "(5, 0)" for the character "position". The distance between the character "position" and the character "location" is 0.5, and the distance between the character "position" and the character "123" is 4. When the text threshold is 1, the distance 0.5 is less than the text threshold 1, and the character "position" and the character "location" are spliced to obtain the text "position", and the text coordinate corresponding to the text "position" is "1, 0".
[0048] In operation S230, determine the candidate coordinates of at least one candidate cell according to at least one text and at least one text coordinate.
[0049] According to an embodiment of the present disclosure, the text coordinate includes, for example, a first text coordinate and a second text coordinate. The first text coordinate may be, for example, the coordinate of the upper left corner of the rectangle to which the text belongs, and the second text coordinate may be, for example, the coordinate of the lower right corner of the rectangle to which the text belongs.
[0050] Obtain the vertical coordinate value of the first text coordinate of each text, and classify at least one text into rows. For the first text coordinate in the same row, determine the first text coordinate corresponding to the vertical coordinate value that meets the first preset condition as the row boundary coordinate. The first preset condition can be, for example, the largest vertical coordinate value among the first text coordinates in the same row, or the smallest vertical coordinate value among the first text coordinates in the same row. Obtain the horizontal coordinate value of the second text coordinate of each text, and classify at least one text into columns. For the second text coordinate in the same column, determine the second text coordinate corresponding to the horizontal coordinate value that meets the second preset condition as the column boundary coordinate. The second preset condition can be, for example, the largest horizontal coordinate value among the second text coordinates in the same column, or the smallest horizontal coordinate value among the second text coordinates in the same column. It should be noted that, for the first preset condition, the selection of the smallest vertical coordinate value or the smallest vertical coordinate value is determined by the position established by the coordinate axis.
[0051] The target table frame is determined based on the row boundary coordinates and the column boundary coordinates. For each candidate cell in the target table frame, candidate coordinates are determined, and each candidate cell has a unique corresponding candidate coordinate. The candidate coordinates may, for example, include the coordinates of the center position of the candidate cell, and the coordinates composed of the horizontal coordinates of the first text coordinate and the horizontal coordinates of the second text coordinate of the candidate cell. It is understood that the description of the candidate coordinates is only used as an example to facilitate understanding of the present disclosure, and the present disclosure does not limit this.
[0052] According to another embodiment of the present disclosure, operation S230 also includes: determining multiple row boundary coordinates based on at least one first text coordinate and a row threshold; determining multiple column boundary coordinates based on the first text coordinate, the second text coordinate, the column threshold, multiple row boundary coordinates and at least one text; and determining candidate coordinates of at least one candidate cell based on the multiple row boundary coordinates and the multiple column boundary coordinates.
[0053] The vertical coordinate values of the first text coordinate of each text are sorted, and the first difference between every two adjacent vertical coordinate values is determined to obtain at least one first difference value. For each first difference value, two texts corresponding to the first difference value whose first difference value is less than a row threshold are classified as belonging to the same row. Similarly, row classification is performed for each text, and the row corresponding to each text is determined. Based on the at least one determined row, the row boundary coordinates between every two rows are determined.
[0054] According to the determined multiple rows, determine that the multiple rows include texts respectively, and determine the number of texts included in each row to obtain at least one text number. Determine that the maximum number of texts in the at least one text number is the number of columns of the target table frame. For each two texts in the at least one text, determine whether the two texts belong to the same column based on the horizontal coordinate of the first text coordinate, the horizontal coordinate of the second text coordinate, the column threshold and the third preset condition. When it is determined that the two texts meet the third preset condition, determine that the two texts belong to the same column. Similarly, column classification is performed for each text to determine the column corresponding to each text. For the determined at least one column, determine the column boundary coordinates between every two columns. The third preset condition may, for example, include the following formulas (1) and (2):
[0055] L n ≥L0 formula (1)
[0056] L n -m≤R0 formula (2)
[0057] Among them, L n represents the abscissa of the first text coordinate of one of the two texts, L0 represents the abscissa of the first text coordinate of the other of the two texts, m represents the column threshold, and R0 represents the abscissa of the second text coordinate of the other of the two texts.
[0058] A target table frame is determined according to a plurality of row boundary coordinates and a plurality of column boundary coordinates, and then at least one candidate cell included in the target table frame and candidate coordinates corresponding to each candidate cell are determined.
[0059] In operation S240, a target table corresponding to the target table image is generated based on the candidate coordinates, the at least one text, and the at least one text coordinate.
[0060] According to an embodiment of the present disclosure, a target table frame is generated based on candidate coordinates, and based on each text coordinate, the text corresponding to the text coordinate is combined with the corresponding candidate cell in the target table frame to generate a target table.
[0061] According to another embodiment of the present disclosure, operation S240 also includes: determining the target coordinates of each target cell based on the candidate coordinates and at least one text coordinate, and determining the target text corresponding to the target coordinates in at least one text; and generating a target table corresponding to the target table image based on the target coordinates and the target text.
[0062] For each text, the correlation between the text coordinates and each candidate coordinate is calculated respectively, the candidate coordinate corresponding to the maximum correlation is determined as the target coordinate of the target cell, the text is determined to be the target text corresponding to the target coordinate, and the target coordinate is associated with the target text.
[0063] A target table frame is generated based on the target coordinates. For each target cell in the target table frame, a target text associated with the target coordinates is determined, and the target text is combined with the target cell to generate a target table.
[0064] Figure 3A-3B The following schematically shows a principle diagram of a method for determining row boundary coordinates according to another embodiment of the present disclosure.
[0065] According to an embodiment of the present disclosure, at least one first row boundary coordinate and at least one second row boundary coordinate are determined based on the vertical coordinate value of at least one first text coordinate, the vertical coordinate value of the second text coordinate, and a row threshold; and a plurality of row boundary coordinates are determined based on the at least one first row boundary coordinate and the at least one second row boundary coordinate. The first text coordinate may, for example, include the coordinates of the upper left corner of the rectangle of each text. The second text coordinate may, for example, include the coordinates of the lower right corner of the rectangle to which the text belongs. The first row boundary coordinate may, for example, include the coordinates corresponding to the upper boundary of each row, and the second row boundary coordinate may, for example, include the coordinates corresponding to the lower boundary of each row.
[0066] like Figure 3A As shown, the at least one text includes a first text 311 , a second text 312 , a third text 313 , a fourth text 321 , a fifth text 322 , a sixth text 331 and a seventh text 332 .
[0067] For example, the upper left corner coordinates of the first text 311, the second text 312, the third text 313, the fourth text 321, the fifth text 322, the sixth text 331 and the seventh text 332 are (a1, b1), (c1, d1), (e1, f1), (g1, h1), (i1, j1), (k1, l1) and (m1, n1) respectively, and the lower right corner coordinates of the first text 311, the second text 312, the third text 313, the fourth text 321, the fifth text 322, the sixth text 331 and the seventh text 332 are (a2, b2), (c2, d2), (e2, f2), (g2, h2), (i2, j2), (k2, l2) and (m2, n2) respectively.
[0068] Sort b1, d1, f1, h1, j1, l1, and n1 from small to large, and determine the coordinates of the upper boundary of the first row corresponding to the upper boundary of the first row based on the smallest value. Thus, when b1, d1, and f1 are equal, and b1, d1, and f1 are the smallest among b1, d1, f1, h1, j1, l1, and n1, determine the coordinates corresponding to the upper boundary 314 of the first row based on b1, d1, or f1. Calculate the difference between h1, j1, l1, and n1 and b1, respectively, to obtain at least one difference. If a first difference value among the at least one difference value is less than or equal to the row threshold, determine that the text corresponding to the first difference value belongs to the first row. If each of the difference values is greater than the row threshold, determine that the text corresponding to the difference value does not belong to the first row. Because at least one of the differences is greater than the row threshold, the text in the first row is determined to include first text 311, second text 312, and third text 313. The largest value among b2, d2, and f2 is determined to be b2. Based on b2, the coordinates corresponding to lower boundary 315 of the first row are determined. Similarly, the coordinates corresponding to upper boundary 323, lower boundary 324, upper boundary 333, and lower boundary 334 of the second row are determined.
[0069] The coordinates corresponding to the upper boundary of each row may, for example, include the current row number as the horizontal coordinate and the minimum value among the horizontal coordinates of the upper left corner coordinates of at least one text included in the current row as the vertical coordinate. For example, the coordinates corresponding to the upper boundary 314 of the first row are (1, b1). The coordinates corresponding to the lower boundary of each row may, for example, include the current row number as the horizontal coordinate and the maximum value among the horizontal coordinates of the lower right corner coordinates of at least one text included in the current row as the vertical coordinate. For example, the coordinates corresponding to the lower boundary of the first row are (1, b2). Based on this, the coordinates corresponding to the upper boundary 323 of the second row, the lower boundary 324 of the second row, the upper boundary 333 of the third row, and the lower boundary 334 of the third row are determined, respectively.
[0070] The coordinates corresponding to the upper boundary of the first row and the lower boundary of the last row are determined as row boundary coordinates. For each row, it is determined whether the coordinates corresponding to the lower boundary of the row and the upper boundary of the next row are the same. If the coordinates corresponding to the lower boundary of the row and the upper boundary of the next row are the same, the coordinates corresponding to the lower boundary of the row are used as row boundary coordinates. If the coordinates corresponding to the lower boundary of the row and the upper boundary of the next row are different, the row boundary coordinates are determined based on the coordinates corresponding to the lower boundary of the row and the upper boundary of the next row.
[0071] like Figure 3BAs shown, if the ordinate (b1) of the coordinate corresponding to the lower boundary 315 of the first row and the ordinate (h2) of the coordinate corresponding to the upper boundary 323 of the second row are different, the average of the two ordinates is calculated. The coordinate consisting of 1 as the abscissa and the average value as the ordinate is used as the coordinate corresponding to the row boundary 316 of the first row. Similarly, the coordinate corresponding to the row boundary 325 of the second row is determined. The coordinates corresponding to the upper boundary 314 of the first row, the row boundary 316 of the first row, the row boundary 325 of the second row, and the lower boundary 334 of the third row are respectively determined as row boundary coordinates.
[0072] Those skilled in the art will appreciate that the above embodiments are merely illustrative, and the specific number of lines and text in the present invention is not limited thereto. Furthermore, the configuration of the line boundary coordinates and the coordinates corresponding to the left and right boundaries of each line are merely illustrative to facilitate understanding of the present disclosure and are not intended to limit the present disclosure.
[0073] Figure 3C to Figure 3D The following schematically shows a principle diagram of a method for determining column boundary coordinates according to another embodiment of the present disclosure.
[0074] According to an embodiment of the present disclosure, the number of columns of the target table frame is determined based on multiple row boundary coordinates and at least one text; and multiple column boundary coordinates are determined based on the number of columns of the target table frame, the horizontal coordinate value of the first text coordinate, the horizontal coordinate value of the second text coordinate and a column threshold.
[0075] In the case that the target table frame consists of three rows, determine the number of texts included in each row. Figure 3C It can be seen that the number of texts in the first row is 3, the number of texts in the second row is 2, and the number of texts in the third row is 2. The maximum number of texts is determined to be the number of columns of the target table frame, that is, the number of columns of the target table frame is 3, and then the column boundary coordinates of each of the 3 columns are determined. According to the horizontal coordinate value of the first text coordinate, the horizontal coordinate value of the second text coordinate and the column threshold, the coordinates corresponding to the left boundary and the right boundary of each column are determined, and multiple column boundary coordinates are determined based on the coordinates corresponding to the left boundary and the right boundary of each column.
[0076] Sort the horizontal coordinates of the upper left corner coordinates of the first text 311, the second text 312, and the third text 313 in the first row from small to large, and determine the text belonging to the same column as each text in turn. When it is determined that the horizontal coordinate of the upper left corner coordinate of the first text 311 is the smallest, for the first text 311, calculate whether the fourth text 321, the fifth text 322, the sixth text 331, and the seventh text 332 meet the third preset condition with the first text 311. When the third preset condition is met, determine that the text is in the same column as the first text 311. When it is determined that the first text 311, the fourth text 321, and the sixth text 331 are in the same column, determine that the smallest value among a1, g1, and k1 is a1, and based on a1, determine the coordinate corresponding to the left boundary 301 of the first column. Determine that the largest value among a2, g2, and k2 is k2, and based on k2, determine the coordinate corresponding to the right boundary of the first column. Similarly, the coordinates corresponding to the left boundary 303 of the second column, the right boundary 304 of the second column, the left boundary 305 of the third column, and the right boundary 306 of the third column are determined.
[0077] For each column, determine whether the right boundary coordinate of the column is between the left boundary coordinates of the next column and the right boundary coordinates of the next column. If the right boundary coordinate of the column is determined to be between the left boundary coordinates of the next column and the right boundary coordinates of the next column, determine the horizontal coordinate of the lower right corner coordinate of the text in the column, sort the horizontal coordinates from small to large, and determine the coordinate corresponding to the right boundary of the column based on the second-to-last horizontal coordinate.
[0078] For example, for the first column, the largest value among a2, g2, and k2 is k2. Based on k2, the coordinate corresponding to the right boundary of the first column is determined to be between the coordinates corresponding to the left boundary 303 and the right boundary 304 of the second column. Therefore, k2 is discarded from determining the coordinate corresponding to the right boundary of the first column. Next, the second-to-last largest value among a2, g2, and k2 is determined to be g2. Based on g2, the coordinate corresponding to the right boundary 302 of the first column is determined not to be between the coordinates corresponding to the left boundary 303 and the right boundary 304 of the second column. Therefore, in this case, the coordinate corresponding to the right boundary 302 of the first column is determined to be the final coordinate corresponding to the right boundary of the first column.
[0079] The coordinates corresponding to the left boundary of each column may, for example, include the current column number as the horizontal coordinate and the minimum value of the vertical coordinate of the coordinate of the upper left corner of at least one text included in the current column as the horizontal coordinate. For example, the coordinates corresponding to the left boundary 301 of the first column are (1, a1). The coordinates corresponding to the right boundary of each column may, for example, include the current column number as the horizontal coordinate and the maximum value of the vertical coordinate of the coordinate of the lower right corner of at least one text included in the current column as the vertical coordinate. For example, the coordinates corresponding to the right boundary 302 of the first row are (1, g2). Based on this, the coordinates corresponding to the second column left boundary 303, the second column right boundary 304, the third column left boundary 305 and the third column right boundary 306 are determined respectively.
[0080] The coordinates corresponding to the left boundary of the first column and the right boundary of the last column are determined as column boundary coordinates. For each column, determine whether the coordinates corresponding to the right boundary of the column and the left boundary of the next column are the same. If the coordinates corresponding to the right boundary of the column and the left boundary of the next column are the same, the coordinates corresponding to the right boundary of the column are used as column boundary coordinates. If the coordinates corresponding to the right boundary of the column and the left boundary of the next column are different, the column boundary coordinates are determined based on the coordinates corresponding to the right boundary of the column and the left boundary of the next column.
[0081] If the abscissa (g2) of the coordinate corresponding to the right boundary 302 of the first column and the abscissa (c1) of the coordinate corresponding to the left boundary 303 of the second column are different, the average of the two abscissas is calculated. The coordinate consisting of the average value as the abscissa and 1 as the ordinate is used as the coordinate corresponding to the column boundary 307 of the first column. Similarly, the coordinate corresponding to the column boundary 308 of the second column is determined. The coordinates corresponding to the left boundary 301 of the first column, the column boundary 307 of the first column, the column boundary 308 of the second column, and the right boundary 306 of the third column are respectively determined as column boundary coordinates.
[0082] Those skilled in the art will appreciate that the above embodiments are merely illustrative, and the specific number of columns and texts in the present invention is not limited thereto. Furthermore, the configuration of the column boundary coordinates and the coordinates corresponding to the left and right boundaries of each column are merely illustrative to facilitate understanding of the present disclosure and are not intended to limit the present disclosure.
[0083] Figure 3E to Figure 3F Schematic diagram showing a method for generating a table according to another embodiment of the present disclosure
[0084] According to an embodiment of the present disclosure, a first area value of at least one candidate cell and a second area value of at least one text are determined based on at least one candidate coordinate and at least one text coordinate; for each text, a matching degree of the text with each candidate cell is determined based on the second area value and at least one first area value to obtain at least one matching degree; in the case where it is determined that there is a matching degree greater than a preset first threshold value in at least one matching degree, the candidate coordinates of the candidate cell are determined as the target coordinates of the target cell, and the text is used as the target text corresponding to the target coordinates; and in the case where it is determined that there is no matching degree greater than the preset first threshold value in at least one matching degree, and there are two matching degrees less than the preset second threshold value, the target coordinates of the target cell are determined based on the candidate coordinates of the two candidate cells corresponding to the two matching degrees, and the text is used as the target text corresponding to the target coordinates.
[0085] The target table frame is determined by the row boundary of each row and the column boundary of each column, and the target table frame includes at least one candidate cell. Figure 3E As shown, the at least one candidate cell includes a first candidate cell 317 , a second candidate cell 318 , a third candidate cell 319 , a fourth candidate cell 326 , a fifth candidate cell 327 , a sixth candidate cell 328 , a seventh candidate cell 335 , an eighth candidate cell 336 and a ninth candidate cell 337 .
[0086] For example, the first areas of the first candidate cell 317, the second candidate cell 318, the third candidate cell 319, the fourth candidate cell 326, the fifth candidate cell 327, the sixth candidate cell 328, the seventh candidate cell 335, the eighth candidate cell 336, and the ninth candidate cell 337 are A1, B1, C1, D1, E1, F1, G1, H1, and I, respectively. The second areas corresponding to the first text 311, the second text 312, the third text 313, the fourth text 321, the fifth text 322, the sixth text 331, and the seventh text 332 are A2, B2, C2, D2, E2, I2, and H2, respectively.
[0087] Using formula (3), determine the matching degree between each text and each candidate cell.
[0088]
[0089] Among them, M represents the matching degree, S table represents the first area of the candidate cell, S text Indicates the second area of the text, S table ∩S text The intersection of the first area of the candidate cell and the second area of the text may include, for example, the overlapping area of the first area and the second area.
[0090] For the first text 311, the matching degrees of A1, B1, C1, D1, E1, F1, G1, H1 and A2 are calculated respectively. It is determined that only the matching degree of A1 and A2 is greater than a preset first threshold. The first text 311 is determined as the target text associated with the first candidate cell 317, and the candidate coordinates of the first candidate cell 317 are determined and determined as the target coordinates of the target cell. Similarly, the second text 312, the third text 313, the fourth text 321, the fifth text 322, and the seventh text 332 are respectively determined as the target text associated with the second candidate cell 318, the third candidate cell 319, the fourth candidate cell 326, the fifth candidate cell 322, and the ninth candidate cell 337. The candidate coordinates of the second candidate cell 318, the third candidate cell 319, the fourth candidate cell 326, the fifth candidate cell 327, the sixth candidate cell 328, and the ninth candidate cell 337 are respectively determined as the target coordinates of the target cell.
[0091] For the sixth text 331, if it is determined that there is no unique first area with a matching degree greater than the first threshold value and that there are matching degrees between F1 and G1 and I2 less than the second threshold value, the column boundary 3073 between the seventh candidate cell 335 and the eighth candidate cell 336 is removed to obtain the target cell 338. The target coordinates corresponding to the target cell 338 are determined based on the candidate coordinates corresponding to the seventh candidate cell 335 and the candidate coordinates corresponding to the eighth candidate cell 336.
[0092] According to the target coordinates and target text, a target table corresponding to the target table image is generated. The target table can be Figure 3F shown.
[0093] Those skilled in the art will appreciate that the above embodiments are merely examples, and the specific number of rows, columns, and texts in the present invention are not limited thereto.
[0094] The network routing graph to be predicted includes, but is not limited to, the number of communication nodes and the connection relationship between every two communication nodes.
[0095] Based on the above table generation method, the present disclosure also provides a table generation device. Figure 4 The device is described in detail.
[0096] Figure 4 The structural block diagram of the table generating device according to an embodiment of the present disclosure is schematically shown.
[0097] like Figure 4As shown, the table generating device 400 of this embodiment includes a first determining module 410 , an obtaining module 420 , a second determining module 430 and a generating module 440 .
[0098] The first determination module 410 is used to determine the target table image according to the image to be recognized. In one embodiment, the first determination module 410 can be used to perform the operation S210 described above, which will not be repeated here.
[0099] According to an embodiment of the present disclosure, the first determination module 410 is also used to process the image to be identified using a recognition model to obtain at least one position coordinate; obtain a first table image in the image to be identified based on the at least one position coordinate; process the first table image to determine the deflection angle; and deflect the first table image based on the deflection angle to obtain a target table image.
[0100] The obtaining module 420 is used to perform text recognition on the target table image to obtain at least one text and at least one text coordinate corresponding to each text. In one embodiment, the obtaining module 420 can be used to perform the operation S220 described above, which will not be repeated here.
[0101] The second determining module 430 is used to determine the candidate coordinates of at least one candidate cell according to at least one text and at least one text coordinate. In one embodiment, the second determining module 430 can be used to perform the operation S230 described above, which will not be repeated here.
[0102] According to an embodiment of the present disclosure, the second determination module 430 is also used to determine multiple row boundary coordinates based on at least one first text coordinate and a row threshold; determine multiple column boundary coordinates based on the first text coordinate, the second text coordinate, the column threshold, multiple row boundary coordinates and at least one text; and determine the candidate coordinates of at least one candidate cell based on the multiple row boundary coordinates and the multiple column boundary coordinates.
[0103] According to an embodiment of the present disclosure, the second determination module 430 is also used to determine at least one first row boundary coordinate and at least one second row boundary coordinate based on the vertical coordinate value of at least one first text coordinate, the vertical coordinate value of the second text coordinate and the row threshold; and to determine multiple row boundary coordinates based on at least one first row boundary coordinate and at least one second row boundary coordinate.
[0104] According to an embodiment of the present disclosure, the second determination module 430 is also used to determine the number of columns of the target table frame based on multiple row boundary coordinates and at least one text; and to determine multiple column boundary coordinates based on the number of columns of the target table frame, the horizontal coordinate value of the first text coordinate, the horizontal coordinate value of the second text coordinate and the column threshold.
[0105] The generating module 440 is used to generate a target table corresponding to the target table image according to the candidate coordinates, at least one text and at least one text coordinate. In one embodiment, the generating module 440 can be used to perform the operation S240 described above, which will not be repeated here.
[0106] According to an embodiment of the present disclosure, the generation module 440 is also used to determine the target coordinates of each target cell based on the candidate coordinates and at least one text coordinate, and determine the target text corresponding to the target coordinates in at least one text; and generate a target table corresponding to the target table image based on the target coordinates and the target text.
[0107] According to an embodiment of the present disclosure, the generation module 440 is also used to determine the first area value of at least one candidate cell and the second area value of at least one text based on at least one candidate coordinate and at least one text coordinate; for each text, determine the matching degree of the text with each candidate cell respectively based on the second area value and at least one first area value, and obtain at least one matching degree; when it is determined that there is a matching degree greater than a preset first threshold in at least one matching degree, determine the candidate coordinates of the candidate cell as the target coordinates of the target cell, and use the text as the target text corresponding to the target coordinates; and when it is determined that there is no matching degree greater than the preset first threshold in at least one matching degree, and there are two matching degrees less than the preset second threshold, determine the target coordinates of the target cell based on the candidate coordinates of the two candidate cells corresponding to the two matching degrees, and use the text as the target text corresponding to the target coordinates.
[0108] According to an embodiment of the present disclosure, any multiple modules among the first determination module 410, the obtaining module 420, the second determination module 430 and the generation module 440 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the first determination module 410, the obtaining module 420, the second determination module 430 and the generation module 440 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the first determining module 410 , the obtaining module 420 , the second determining module 430 and the generating module 440 may be at least partially implemented as a computer program module, which may perform corresponding functions when executed.
[0109] Figure 5 The block diagram schematically shows an electronic device suitable for implementing the table generating method according to an embodiment of the present disclosure.
[0110] like Figure 5 As shown, the electronic device 500 according to an embodiment of the present disclosure includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0111] Various programs and data required for the operation of the electronic device 500 are stored in the RAM 503. The processor 501, ROM 502, and RAM 503 are connected to each other via a bus 504. The processor 501 performs various operations of the method flow according to the embodiment of the present disclosure by executing the programs in the ROM 502 and / or RAM 503. It should be noted that the programs may also be stored in one or more memories other than the ROM 502 and the RAM 503. The processor 501 may also perform various operations of the method flow according to the embodiment of the present disclosure by executing the programs stored in one or more memories.
[0112] According to an embodiment of the present disclosure, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the I / O interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage portion 508 including a hard disk; and a communication portion 509 including a network interface card such as a LAN card or a modem. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in the drive 510 as needed, so that a computer program read therefrom can be installed into the storage portion 508 as needed.
[0113] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when executed, implements the method according to the embodiments of the present disclosure.
[0114] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM502 and / or RAM503 described above and / or one or more memories other than ROM502 and RAM503.
[0115] The embodiments of the present disclosure also include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is executed in a computer system, the program code is used to cause the computer system to implement the item recommendation method provided by the embodiments of the present disclosure.
[0116] The computer program executes the above functions defined in the system / device of the embodiment of the present disclosure when the computer program is executed by the processor 501. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0117] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 509, and / or installed from a removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0118] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 509, and / or installed from a removable medium 511. When the computer program is executed by the processor 501, the above-described functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.
[0119] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).
[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0121] Those skilled in the art will appreciate that various combinations and / or combinations of features described in the various embodiments and / or claims of this disclosure may be made, even if such combinations or combinations are not explicitly described in this disclosure. In particular, various combinations and / or combinations of features described in the various embodiments and / or claims of this disclosure may be made, without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.
[0122] The embodiments of the present disclosure are described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be used in combination to advantage. The scope of the present disclosure is defined by the appended claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A table generation method, comprising: Determine the target table image according to the image to be recognized; Performing text recognition on the target table image to obtain at least one text and at least one text coordinate corresponding to each text; Determining candidate coordinates of at least one candidate cell according to the at least one text and the at least one text coordinate; as well as generating a target table corresponding to the target table image according to the candidate coordinates, the at least one text and the at least one text coordinates; Wherein, determining the target table image according to the image to be recognized includes: Processing the image to be recognized using the recognition model to obtain at least one position coordinate, wherein the position coordinate includes any coordinate capable of determining the position of the table area; Acquire a first table image in the image to be recognized according to the at least one position coordinate; processing the first table image to determine a deflection angle; and Deflect the first table image according to the deflection angle to obtain a target table image, The processing of the first table image to determine the deflection angle includes: performing a binarization process on the first table image using an image binarization process method to obtain a black and white image corresponding to the first table image; Performing erosion and dilation processing on the black and white image using a rectangle as an erosion and dilation element to obtain a simplified image; Based on the simplified image, determining whether there is a straight line in the first table image; When it is determined that there are straight lines in the first table, processing at least one straight line using a Hough transform to determine a first slope of each straight line; extracting at least one text image from the first table image and determining a second slope of each text image when it is determined that no straight line exists in the first table image; A deflection angle is determined according to the first slope of each straight line or the second slope of each text image.
2. The method according to claim 1, wherein The text coordinates include a first text coordinate and a second text coordinate, and determining candidate coordinates of at least one candidate cell according to the at least one text and the at least one text coordinate includes: determining a plurality of row boundary coordinates based on at least one first text coordinate and a row threshold; determining a plurality of column boundary coordinates according to the first text coordinate, the second text coordinate, a column threshold, the plurality of row boundary coordinates, and the at least one text; and Determine candidate coordinates of at least one candidate cell according to the plurality of row boundary coordinates and the plurality of column boundary coordinates.
3. The method according to claim 2, wherein: The determining of a plurality of row boundary coordinates according to the at least one first text coordinate and the row threshold comprises: Determining at least one first row boundary coordinate and at least one second row boundary coordinate according to the ordinate value of the at least one first text coordinate, the ordinate value of the second text coordinate, and the row threshold; and A plurality of row boundary coordinates are determined according to the at least one first row boundary coordinate and the at least one second row boundary coordinate.
4. The method according to claim 2, wherein: The determining of a plurality of column boundary coordinates according to the first text coordinate, the second text coordinate, the column threshold, the plurality of row boundary coordinates, and the at least one text comprises: determining the number of columns of the target table frame according to the plurality of row boundary coordinates and the at least one text; and A plurality of column boundary coordinates are determined according to the number of columns of the target table frame, the horizontal coordinate value of the first text coordinate, the horizontal coordinate value of the second text coordinate, and a column threshold.
5. The method according to claim 1, wherein Generating a target table corresponding to the target table image according to the candidate coordinates, the at least one text, and the at least one text coordinate comprises: Determine target coordinates of each target cell according to the candidate coordinates and the at least one text coordinate, and determine target text corresponding to the target coordinates in the at least one text; and A target table corresponding to the target table image is generated according to the target coordinates and the target text.
6. The method according to claim 5, wherein: Determining the target coordinates of each target cell according to the candidate coordinates and the at least one text coordinate, and determining the target text corresponding to the target coordinates in the at least one text comprises: Determining a first area value of the at least one candidate cell and a second area value of the at least one text according to the at least one candidate coordinate and the at least one text coordinate; For each text, determining a matching degree between the text and each candidate cell according to the second area value and the at least one first area value, to obtain at least one matching degree; In a case where it is determined that one of the at least one matching degrees has a matching degree greater than a preset first threshold, determining the candidate coordinates of the candidate cell as target coordinates of the target cell, and using the text as target text corresponding to the target coordinates; and When it is determined that there is no matching degree greater than a preset first threshold value in the at least one matching degree, and there are two matching degrees less than a preset second threshold value, the target coordinates of the target cell are determined based on the candidate coordinates of the two candidate cells corresponding to the two matching degrees, and the text is used as the target text corresponding to the target coordinates.
7. A table generating device comprising: A first determining module is used to determine a target table image according to the image to be identified; an obtaining module, configured to perform text recognition on the target table image to obtain at least one text and at least one text coordinate corresponding to each text; a second determining module, configured to determine candidate coordinates of at least one candidate cell according to the at least one text and the at least one text coordinate; as well as a generating module, configured to generate a target table corresponding to the target table image according to the candidate coordinates, the at least one text, and the at least one text coordinates; Wherein, determining the target table image according to the image to be recognized includes: Processing the image to be recognized using the recognition model to obtain at least one position coordinate, wherein the position coordinate includes any coordinate capable of determining the position of the table area; Acquire a first table image in the image to be recognized according to the at least one position coordinate; processing the first table image to determine a deflection angle; and Deflect the first table image according to the deflection angle to obtain a target table image, The processing of the first table image to determine the deflection angle includes: performing a binarization process on the first table image using an image binarization process method to obtain a black and white image corresponding to the first table image; Performing erosion and dilation processing on the black and white image using a rectangle as an erosion and dilation element to obtain a simplified image; Based on the simplified image, determining whether there is a straight line in the first table image; When it is determined that there are straight lines in the first table, processing at least one straight line using a Hough transform to determine a first slope of each straight line; extracting at least one text image from the first table image and determining a second slope of each text image when it is determined that no straight line exists in the first table image; A deflection angle is determined according to the first slope of each straight line or the second slope of each text image.
8. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to perform the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Table identification method, device and equipment, and readable storage medium
CN112329641A