Table identification method and device
By performing line segment detection and projection information processing on the table image, a target table is generated, which solves the problem of low accuracy in wired table recognition under limited graphics card resources and achieves efficient table recognition and cell positioning.
Patent Information
- Application Number
- CN202511776043.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-03-03
AI Technical Summary
With limited graphics card resources, existing technologies struggle to accurately identify wired tables, especially tilted and deformed tables, resulting in low recognition accuracy.
By performing line segment detection on the table image to obtain horizontal and vertical line segments, and using the horizontal and vertical projection information to divide the cells, the target table is generated based on the intersection point, avoiding the processing of a large amount of labeled data.
Despite limited graphics card resources, the accuracy of table recognition has been improved, cells have been effectively located, and line segments that do not exist in the table have been avoided, thus enhancing the accuracy of recognition.
Smart Images

Figure CN121600535A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to a method and apparatus for table recognition. Background Technology
[0002] In document image processing, tabular documents are abundant, and line tables are an important target for information extraction due to their clear structure and strong regularity.
[0003] Currently, methods for wired table recognition mainly fall into two categories: deep learning model recognition and traditional methods. Deep learning model recognition requires a large amount of labeled data, thus consuming significant graphics card resources, making it unsuitable when graphics card resources are limited. Traditional methods primarily locate tables through contour detection or line detection. These methods are susceptible to noise interference and struggle to accurately recognize tilted or deformed tables, resulting in low accuracy.
[0004] Therefore, given the limited resources of graphics cards, how to identify wired tables in order to improve the accuracy of identification is a problem that needs to be solved. Summary of the Invention
[0005] Therefore, it is necessary to provide a table recognition method and apparatus to address the aforementioned technical problems, so as to improve the accuracy of table recognition under the condition of limited graphics card resources.
[0006] Firstly, this application provides a table recognition method, including:
[0007] Obtain the image of the table to be recognized;
[0008] Line segment detection is performed on the table image to obtain multiple horizontal line segments and multiple vertical line segments;
[0009] Based on the lateral projection information of each of the multiple horizontal line segments, a set of multiple cell horizontal line segments in different vertical position ranges is determined from the multiple horizontal line segments. Each set of cell horizontal line segments includes at least one horizontal line segment in the same vertical position range.
[0010] Based on the longitudinal projection information of each of the multiple vertical line segments, a set of multiple cell vertical line segments in different horizontal position ranges is determined from the multiple vertical line segments. Each set of cell vertical line segments includes at least one vertical line segment in the same horizontal position range.
[0011] The target table is generated based on the intersection point of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs.
[0012] In one embodiment, the line segment detection of the table image to obtain multiple horizontal line segments and multiple vertical line segments includes:
[0013] Line segment detection is performed on the table image to obtain multiple initial horizontal line segments and multiple initial vertical line segments;
[0014] Traverse and determine the total number of intersections between any of the multiple initial horizontal line segments and other line segments;
[0015] Line segments with fewer than a preset number of intersections with other line segments are deleted to obtain the plurality of horizontal line segments and the plurality of vertical line segments.
[0016] In one embodiment, determining a set of multiple cell horizontal line segments located in different vertical position ranges from the plurality of horizontal line segments based on the lateral projection information of each horizontal line segment includes:
[0017] By performing a horizontal projection on each of the plurality of horizontal line segments, the horizontal projection curve corresponding to each horizontal line segment is obtained.
[0018] The horizontal line segments whose heights are within the same vertical position range are divided into a set of horizontal line segments in a single cell, thus obtaining multiple sets of horizontal line segments in different vertical position ranges.
[0019] In one embodiment, dividing the horizontal line segments whose heights are within the same vertical position range into a set of cell line segments to obtain multiple sets of cell line segments in different vertical position ranges includes:
[0020] The horizontal line segments whose heights are within the same vertical position range of the horizontal projection curve are divided into a first set of horizontal line segments, and the first set of horizontal line segments includes multiple first horizontal line segments.
[0021] The first horizontal line segment whose peak of the horizontal projection curve of the first horizontal line segment set is greater than the first preset value is divided into the second horizontal line segment set, and the second horizontal line segment set includes at least one second horizontal line segment.
[0022] The first horizontal line segment whose peak value is less than or equal to the first preset value is divided into the third horizontal line segment set, and the third horizontal line segment set includes at least one third horizontal line segment.
[0023] The minimum distance between each of the third horizontal line segments and the plurality of second horizontal line segments is determined by traversing the network.
[0024] The third horizontal line segment corresponding to the minimum distance value being less than the first preset distance value is divided into the second horizontal line segment set, until all third horizontal line segments in the third horizontal line segment set have been traversed;
[0025] The second set of horizontal line segments is defined as the set of horizontal line segments of cells within the same vertical position range;
[0026] The multiple sets of horizontal line segments in different vertical positions are determined based on the multiple sets of the second horizontal line.
[0027] In one embodiment, determining a set of multiple cell vertical line segments located in different horizontal position ranges from the plurality of vertical line segments based on the longitudinal projection information of each vertical line segment includes:
[0028] Each of the plurality of vertical line segments is projected longitudinally to obtain the longitudinal projection curve corresponding to each vertical line segment;
[0029] The vertical line segments whose widths are within the same horizontal position range are divided into a set of vertical line segments in a single cell, thus obtaining multiple sets of vertical line segments in different horizontal position ranges.
[0030] In one embodiment, dividing the vertical line segments whose widths of the longitudinal projection curves are within the same horizontal position range into a set of vertical line segments in a single cell, thereby obtaining multiple sets of vertical line segments in different horizontal position ranges, includes:
[0031] The vertical line segments whose widths are within the same horizontal position range are divided into a first set of vertical line segments, and the first set of vertical line segments includes multiple first vertical line segments.
[0032] Vertical segments whose peaks in the longitudinal projection curves of the first set of vertical segments are greater than a second preset value are assigned to a second set of vertical segments, and the second set of vertical segments includes at least one second vertical segment.
[0033] Vertical segments whose peaks in the longitudinal projection curves of the first set of vertical segments are less than or equal to the second preset value are assigned to a third set of vertical segments, wherein the third set of vertical segments includes at least one third vertical segment.
[0034] The minimum distance between each of the third vertical line segments and the plurality of second vertical line segments is determined by traversing the network.
[0035] The third vertical line segment corresponding to the minimum distance value being less than the second preset distance value is assigned to the second vertical line segment set until all third vertical line segments in the third vertical line segment set have been traversed.
[0036] The second set of vertical line segments is defined as the set of vertical line segments of cells within the same horizontal position range;
[0037] The set of multiple cell vertical line segments located in different horizontal positions is determined based on multiple sets of the second vertical line.
[0038] In one embodiment, generating a target table based on the intersection points of each horizontal line segment in the plurality of cell horizontal line segment sets and each vertical line segment in the plurality of cell vertical line segment sets, and the horizontal and vertical line segments to which each intersection point belongs, includes:
[0039] Determine the location of the intersection point between each horizontal line segment and each vertical line segment;
[0040] A cell is formed by all the intersection points and the horizontal and vertical line segments that form the corresponding intersection points;
[0041] The target table is determined based on all cells.
[0042] In one embodiment, determining the target table based on all cells includes:
[0043] The first table is determined based on all cells;
[0044] By projecting the intersection points of all cells horizontally, a horizontal projection line is obtained;
[0045] Projecting the intersection points of all cells vertically, we obtain the vertical projection line;
[0046] A second table is generated based on the horizontal projection lines and the vertical projection lines;
[0047] The target table is generated based on the first table and the second table.
[0048] In one embodiment, the method further includes:
[0049] Identify all text regions in the table image;
[0050] Each text region is subjected to horizontal and vertical projections to obtain the horizontal and vertical text projection results for each text region.
[0051] The orientation of the table image is determined based on the number of horizontal jump points in the horizontal text projection results of all text regions and the number of vertical jump points in the corresponding vertical text projection results.
[0052] Secondly, this application also provides a form recognition device, which includes:
[0053] The image acquisition module is used to acquire the table image to be recognized;
[0054] The line segment detection module is used to perform line segment detection on the table image to obtain multiple horizontal line segments and multiple vertical line segments;
[0055] The horizontal line segment set determination module is used to determine multiple cell horizontal line segment sets in different vertical position ranges from the multiple horizontal line segments based on the horizontal projection information of each horizontal line segment in the multiple horizontal line segments. Each cell horizontal line segment set includes at least one horizontal line segment in the same vertical position range.
[0056] The vertical line segment set determination module is used to determine multiple cell vertical line segment sets located in different horizontal position ranges from the multiple vertical line segments based on the longitudinal projection information of each vertical line segment in the multiple vertical line segments. Each cell vertical line segment set includes at least one vertical line segment located in the same horizontal position range.
[0057] The table generation module is used to generate a target table based on the intersection point of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs.
[0058] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the table recognition method in any of the above embodiments.
[0059] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the table recognition method in any of the above embodiments.
[0060] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the table recognition method in any of the above embodiments.
[0061] In the above implementation process, line segment detection is performed on the table image to be recognized, resulting in multiple horizontal and vertical line segments. Further, horizontal projection is performed on the multiple horizontal line segments to obtain horizontal projection information, which allows for accurate division of the vertical position range of the horizontal line segments. Similarly, vertical projection is performed on the multiple vertical line segments to obtain vertical projection information, which allows for accurate division of the horizontal position range of the vertical line segments. Finally, cells are generated based on the intersection points of each horizontal line segment in the cell's horizontal line segment set and each vertical line segment in the cell's vertical line segment set, as well as the horizontal and vertical line segments constituting each intersection point, ultimately yielding the target table. This process eliminates the need to process large amounts of labeled data, enabling table recognition even with limited graphics card resources. Furthermore, by using the intersection points of horizontal and vertical line segments and the corresponding line segments to form cells, cell positioning is effectively achieved, improving the accuracy of table generation. Moreover, by avoiding the reconstruction of line segments from arbitrary pairwise intersection points, line segments not present in the table are not generated, enabling the generation of merged cell types of tables, further enhancing the accuracy of table recognition. Attached Figure Description
[0062] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0063] Figure 1 This is a schematic diagram illustrating the application environment of a table recognition method provided in an embodiment of this application;
[0064] Figure 2 This is a flowchart of a table recognition method provided in an embodiment of this application;
[0065] Figure 3 This is a table image to be identified after edge detection, provided in an embodiment of this application;
[0066] Figure 4 This is a schematic diagram of a line segment detection result provided in an embodiment of this application;
[0067] Figure 5 This is a schematic diagram of a target table provided in an embodiment of this application;
[0068] Figure 6 This is a schematic diagram of a first table provided in an embodiment of this application;
[0069] Figure 7 This is a schematic diagram of a second table provided in an embodiment of this application;
[0070] Figure 8 This is a schematic diagram of the text projection result when the text direction has not been rotated, provided in an embodiment of this application;
[0071] Figure 9 This is a schematic diagram of the text projection result when the text direction is rotated, provided in an embodiment of this application;
[0072] Figure 10 This is a schematic diagram of the structure of a table recognition device provided in an embodiment of this application;
[0073] Figure 11 This is an internal structural diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0074] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0075] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0076] The table recognition method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, Figure 1This is a schematic diagram illustrating an application environment for a table recognition method provided in this application embodiment. The terminal 102 communicates with the server 104 via a network. A data storage system can store the data that the server 104 needs to process. The data storage system can be integrated onto the server 104 or placed in the cloud or on another network server. The terminal 102 can process the table text to be recognized by scanning or taking a picture to obtain a table image, and then transmit the table image to the server 104. The server 104 executes the table recognition method of this application based on the received table image. The terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server that provides cloud computing services.
[0077] In one exemplary embodiment, a table recognition method is provided, which is applied to... Figure 1 Taking server 104 as an example, this will be explained. Figure 2 This is a flowchart of a table recognition method provided in an embodiment of this application, such as... Figure 2 As shown, the method may include the following steps:
[0078] Step 201: Obtain the table image to be recognized.
[0079] Step 202: Perform line segment detection on the table image to obtain multiple horizontal line segments and multiple vertical line segments.
[0080] Step 203: Based on the horizontal projection information of each horizontal line segment in the multiple horizontal line segments, determine the set of multiple cell horizontal line segments in different vertical position ranges from the multiple horizontal line segments.
[0081] Each cell's set of horizontal line segments includes at least one horizontal line segment within the same vertical position range.
[0082] Step 204: Based on the longitudinal projection information of each vertical line segment in the multiple vertical line segments, determine the set of multiple cell vertical line segments in different horizontal position ranges from the multiple vertical line segments.
[0083] Each cell's vertical line segment set includes at least one vertical line segment within the same horizontal position range.
[0084] Step 205: Generate the target table based on the intersection point of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs.
[0085] For example, server 104 can obtain the table image to be identified from terminal 102 and preprocess the table image. Specifically, the obtained original table image can be converted into a grayscale image, and bilateral filtering can be used to remove noise, retain edge information, and an adaptive threshold can be applied to generate a binary image. Furthermore, abnormal border processing can be performed on the preprocessed image. Specifically, some table images are pasted images, which will exhibit obvious tortuosity after preprocessing, interfering with the detection of table structures. Therefore, by obtaining the largest bounding box on the binary image, the true region of the pasted image can be obtained. The average pixel value within the largest bounding box and the average pixel value outside the largest bounding box can be obtained, and the difference in average pixels between the inner and outer regions can be used to determine whether it is a pasted image. If the average pixel difference between the inner and outer regions is greater than a preset difference, the obtained table image to be identified can be considered a pasted image, and the image within the largest bounding box is used as the ROI of the table image to be identified, which is then further processed.
[0086] Specifically, structured edge detection can be performed on the ROI of the table image to be recognized. As an example, a horizontal kernel can be used for horizontal edge detection to enhance horizontal line features, for example, the kernel function `cv2.getStructuringElement(cv2.MORPH_RECT, (1,30))`. A vertical kernel can be used for vertical edge detection to enhance vertical line features, for example, the kernel function `cv2.getStructuringElement(cv2.MORPH_RECT,(30,1))`, thus obtaining the edge-detected table image to be recognized. Figure 3 As shown, Figure 3 This is a table image to be identified after edge detection, provided in an embodiment of this application.
[0087] Furthermore, line segment detection is performed on the edge-detected table image to be identified, resulting in multiple horizontal and vertical line segments. Specifically, contour detection and line fitting can be used to extract line segments from the edge-detected table image, and the angles of the extracted line segments are calculated. Horizontal line angle deviations are kept to be ≤±5° and vertical line angle deviations are kept to be ≤±85°, thereby removing interference lines.
[0088] Each line segment is a component of a corresponding cell in the table. In actual text tables, most of the line segments are straight lines. Therefore, the vertical positions of multiple horizontal line segments in multiple cells at the same horizontal position are the same. However, since this application obtains a table image, the vertical positions of multiple horizontal line segments in multiple cells at the same horizontal position obtained from the table image may have some deviation. Therefore, multiple horizontal line segments that are roughly at the same vertical position can be divided into the same set of horizontal line segments based on the horizontal projection information of each horizontal line segment.
[0089] Specifically, each of the multiple horizontal line segments is projected horizontally to obtain the horizontal projection curve of each horizontal line segment. Based on each horizontal projection curve, multiple cell horizontal line segment sets located in different vertical position ranges are determined from the multiple horizontal line segments, so that all horizontal line segments in each cell horizontal line segment set are in the same vertical position range, and each cell horizontal line segment set includes at least one horizontal line segment.
[0090] Correspondingly, based on the longitudinal projection information of each vertical line segment, multiple vertical line segments roughly at the same horizontal position can be grouped into the same set of vertical line segments. Specifically, longitudinal projection is performed on each of the multiple vertical line segments to obtain the longitudinal projection curve of each vertical line segment. Based on each longitudinal projection curve, multiple sets of cell vertical line segments at different horizontal position ranges are determined from the multiple vertical line segments. This ensures that all vertical line segments in each cell set are within the same horizontal position range, and each cell set includes at least one vertical line segment.
[0091] Furthermore, the intersection points of each horizontal line segment in each cell's horizontal line segment set and each vertical line segment in each cell's vertical line segment set are determined, and a target table is generated based on these intersection points. Specifically, it is sequentially determined whether each horizontal line segment in each cell's horizontal line segment set intersects with each vertical line segment in each cell's vertical line segment set. If an intersection point exists, the intersection point position and the line segments forming the corresponding intersection point are recorded. Finally, all the cells in the table are constructed based on all the intersection point positions and the line segments forming the corresponding intersection points, ultimately forming the target table corresponding to the image to be recognized.
[0092] In the above implementation process, line segment detection is performed on the table image to be recognized, resulting in multiple horizontal and vertical line segments. Further, horizontal projection is performed on the multiple horizontal line segments to obtain horizontal projection information, which allows for accurate division of the vertical position range of the horizontal line segments. Similarly, vertical projection is performed on the multiple vertical line segments to obtain vertical projection information, which allows for accurate division of the horizontal position range of the vertical line segments. Finally, cells are generated based on the intersection points of each horizontal line segment in the cell's horizontal line segment set and each vertical line segment in the cell's vertical line segment set, as well as the horizontal and vertical line segments constituting each intersection point, ultimately yielding the target table. This process eliminates the need to process large amounts of labeled data, enabling table recognition even with limited graphics card resources. Furthermore, by using the intersection points of horizontal and vertical line segments and the corresponding line segments to form cells, cell positioning is effectively achieved, improving the accuracy of table generation. Moreover, by avoiding the reconstruction of line segments from arbitrary pairwise intersection points, line segments not present in the table are not generated, enabling the generation of merged cell types of tables, further enhancing the accuracy of table recognition.
[0093] In one embodiment, performing line segment detection on the table image to obtain multiple horizontal line segments and multiple vertical line segments may include the following steps:
[0094] Step 1: Perform line segment detection on the table image to obtain multiple initial horizontal line segments and multiple initial vertical line segments.
[0095] Step 2: Traverse and determine the total number of intersections between any of the initial horizontal and vertical line segments and other line segments.
[0096] Step 3: Delete line segments whose total number of intersections with other line segments is less than the preset number, resulting in multiple horizontal line segments and multiple vertical line segments.
[0097] For example, after performing line segment detection on the table image, multiple initial horizontal line segments and multiple initial vertical line segments can be obtained. Figure 4 This is a schematic diagram of a line segment detection result provided in an embodiment of this application. For example... Figure 4 In the line segment detection results shown, there may be interfering line segments among the multiple initial horizontal and vertical line segments. Furthermore, interfering line segments can be eliminated based on the total number of intersections between any two line segments.
[0098] Specifically, the total number of intersections between any one of the initial horizontal and vertical line segments and other line segments can be determined by iterating through the data. If the total number of intersections between the first line segment and other line segments is less than a preset number, the first line segment is deleted. The first line segment is any one of the initial horizontal and vertical line segments. As an example, the preset number can be 2. By deleting all interfering line segments from the initial horizontal and vertical line segments in this way, multiple horizontal and vertical line segments are obtained after removing the interfering line segments.
[0099] In the above implementation process, by traversing and determining the total number of intersection points between any two pairs of initial horizontal and vertical line segments after line segment detection, the interfering line segments obtained by line segment detection can be effectively eliminated, which facilitates the improvement of the accuracy of subsequent table generation.
[0100] In one embodiment, determining a set of multiple cell line segments within different vertical position ranges from multiple line segments based on the lateral projection information of each line segment can include the following steps:
[0101] Step 1: Perform a horizontal projection on each of the multiple horizontal line segments to obtain the horizontal projection curve corresponding to each horizontal line segment.
[0102] Step 2: Divide the horizontal line segments whose heights are within the same vertical position range into a set of horizontal line segments in a single cell, resulting in multiple sets of horizontal line segments in different vertical position ranges.
[0103] For example, each of the multiple horizontal line segments is projected horizontally to obtain the horizontal projection curve corresponding to each horizontal line segment. Further, horizontal line segments whose heights fall within the same vertical position range are grouped into a single cell set of horizontal line segments. By iterating through this set and determining the vertical position range to which each horizontal projection curve belongs, multiple horizontal line segments can be grouped into multiple cell sets of horizontal line segments corresponding to different vertical position ranges, thus achieving clustering of cell sets of horizontal line segments within the same vertical position range.
[0104] In the above implementation process, multiple horizontal line segments are clustered by the vertical position range of the height of the projection curve of each horizontal line segment, which effectively realizes the division of horizontal line segments corresponding to different rows in the table, and facilitates the accurate generation of subsequent tables.
[0105] In one embodiment, dividing the horizontal line segments whose heights are within the same vertical position range into a set of cell line segments to obtain multiple sets of cell line segments in different vertical position ranges may include the following steps:
[0106] Step 1: Divide the horizontal line segments whose heights are within the same vertical position range of the horizontal projection curve into a first horizontal line segment set. The first horizontal line segment set includes multiple first horizontal line segments.
[0107] Step 2: Divide the first horizontal line segment whose peak of the horizontal projection curve of the first horizontal line segment set is greater than the first preset value into the second horizontal line segment set. The second horizontal line segment set includes at least one second horizontal line segment.
[0108] Step 3: Divide the first horizontal line segments whose peaks in the horizontal projection curves of the first horizontal line segment set are less than or equal to the first preset value into the third horizontal line segment set. The third horizontal line segment set includes at least one third horizontal line segment.
[0109] Step 4: Traverse and determine the minimum distance between each third horizontal line segment and multiple second horizontal line segments.
[0110] Step 5: Divide the third horizontal line segments whose minimum distance is less than the first preset distance value into the second horizontal line segment set, until all third horizontal line segments in the third horizontal line segment set have been traversed.
[0111] Step 6: Determine the second set of horizontal line segments as the set of horizontal line segments of cells within the same vertical position range.
[0112] Step 7: Determine multiple sets of cell line segments in different vertical position ranges based on multiple sets of second horizontal lines.
[0113] For example, the horizontal line segments whose heights are within the same vertical position range of the horizontal projection curve are divided into a first set of horizontal line segments, and the first set of horizontal line segments includes at least one first horizontal line segment.
[0114] During the generation of a table image, cell lines may intersect with text. In this case, the intersecting lines belong to the table, and pixel accumulation occurs in the corresponding areas. Therefore, to further confirm that the line segments in the line segment set belong to the table and not outside the table, the peak value of the line segment projection curve can be used for determination.
[0115] Specifically, in the first set of horizontal line segments, the first horizontal line segments whose peaks in the horizontal projection curves are greater than the first preset value are assigned to the second set of horizontal line segments, and the first horizontal line segments whose peaks in the horizontal projection curves are less than or equal to the first preset value are assigned to the third set of horizontal line segments, thereby dividing the first set of horizontal line segments into the second set of horizontal line segments and the third set of horizontal line segments.
[0116] Thus, the first preset value is used to divide the first horizontal line segment into line segments that are intersected by text and line segments that are not intersected by text.
[0117] It should be noted that the first preset value can be half the image width or other values, and there are no restrictions here.
[0118] However, some line segments in the table are not intersected by text, but they are still line segments in the table. In order to avoid missing any line segments in the table, we can further divide them according to the distance between the confirmed line segments and the unconfirmed line segments.
[0119] Specifically, any segment in the set of third horizontal line segments is identified as the target third horizontal line segment, and the distance between the target third horizontal line segment and each second horizontal line segment is calculated. The minimum distance is selected. Further, the minimum distance is compared to a first preset distance value. If the minimum distance is less than the first preset distance value, it indicates that the target third horizontal line segment is very close to a second horizontal line segment in the set of second horizontal line segments. In this case, the target third horizontal line segment is determined to belong to the horizontal line segments in the table, and is assigned to the second horizontal line segment set. If the minimum distance is greater than or equal to the first preset distance value, it indicates that the target third horizontal line segment is an interfering segment outside the table, and is not assigned to the second horizontal line segment set. This process is used to iterate and determine whether all third horizontal line segments in the set of third horizontal line segments need to be assigned to the second horizontal line segment set. Finally, the segments in the assigned second horizontal line segment set are those belonging to the same vertical position range and are horizontal line segments belonging to cells in the table. In other words, the assigned second horizontal line segment set is determined as the set of cell horizontal line segments within the same vertical position range.
[0120] By iterating through the steps described above to obtain a set of horizontal line segments in cells within the same vertical position range, multiple sets of second horizontal line segments in different vertical position ranges can be obtained, which are multiple sets of horizontal line segments in cells within different vertical position ranges.
[0121] In the above implementation process, based on the magnitude between the peak value of the horizontal projection curve of the horizontal line segment and the first preset threshold, the horizontal line segment is divided into horizontal line segments intersected by text and horizontal line segments not intersected by text. Based on the distance between the horizontal line segments not intersected by text and the horizontal line segments intersected by text, the horizontal line segments belonging to the table are effectively filtered, and the horizontal line segments outside the table are removed, which further improves the accuracy of the subsequent table generation.
[0122] In one embodiment, determining a set of multiple cell vertical line segments within different horizontal position ranges based on the longitudinal projection information of each vertical line segment can include the following steps:
[0123] Step 1: Perform a longitudinal projection on each of the multiple vertical line segments to obtain the longitudinal projection curve corresponding to each vertical line segment.
[0124] Step 2: Divide the vertical line segments whose widths are within the same horizontal position range into a set of vertical line segments in a single cell, resulting in multiple sets of vertical line segments in different horizontal position ranges.
[0125] For example, each of the multiple vertical line segments is projected longitudinally to obtain the longitudinal projection curve corresponding to each vertical line segment. Further, vertical line segments whose widths fall within the same horizontal position range are grouped into a single cell vertical line segment set. By traversing and determining the horizontal position range to which each longitudinal projection curve belongs, multiple vertical line segments can be grouped into multiple cell vertical line segment sets corresponding to multiple horizontal position ranges, thus achieving clustering of cell vertical line segments within the same horizontal position range.
[0126] In the above implementation process, multiple vertical line segments are clustered by the horizontal position range of the width of the longitudinal projection curve of each vertical line segment, which effectively realizes the division of vertical line segments corresponding to different columns in the table, and facilitates the accurate generation of subsequent tables.
[0127] In one embodiment, dividing the vertical line segments whose widths are within the same horizontal position range into a set of vertical line segments in a cell, resulting in multiple sets of vertical line segments in different horizontal position ranges, may include the following steps:
[0128] Step 1: Divide the vertical line segments whose widths are within the same horizontal position range of the longitudinal projection curve into the first vertical line segment set. The first vertical line segment set includes multiple first vertical line segments.
[0129] Step 2: The vertical line segments whose peaks in the longitudinal projection curve of the first vertical line segment set are greater than the second preset value are assigned to the second vertical line segment set. The second vertical line segment set includes at least one second vertical line segment.
[0130] Step 3: Divide the vertical line segments whose peaks in the longitudinal projection curves of the first vertical line segment set are less than or equal to the second preset value into the third vertical line segment set. The third vertical line segment set includes at least one third vertical line segment.
[0131] Step 4: Iterate through the data to determine the minimum distance between each third vertical line segment and multiple second vertical line segments.
[0132] Step 5: Divide the third vertical line segments whose minimum distance is less than the second preset distance value into the second vertical line segment set, until all third vertical line segments in the third vertical line segment set have been traversed.
[0133] Step 6: Determine the second set of vertical line segments as the set of vertical line segments of cells within the same horizontal position range.
[0134] Step 7: Determine multiple cell vertical line segment sets located in different horizontal position ranges based on multiple second vertical line sets.
[0135] For example, the vertical line segments whose widths are within the same horizontal position range of the longitudinal projection curve are divided into a first set of vertical line segments, the first set of vertical line segments including at least one first vertical line segment.
[0136] Similar to horizontal line segments, during the generation of table images, cell line segments may intersect with text. In this case, the intersecting line segments belong to the table, and the area corresponding to the intersecting line segments will experience pixel accumulation. Therefore, to further determine whether the line segments in the line segment set belong to the table and not to those outside the table, the peak value of the line segment projection curve can be used for identification.
[0137] Specifically, in the first set of vertical line segments, the first vertical line segments whose peaks in the longitudinal projection curves are greater than the second preset value are assigned to the second set of vertical line segments, and the first vertical line segments whose peaks in the longitudinal projection curves are less than or equal to the second preset value are assigned to the third set of horizontal line segments, thereby dividing the first set of vertical line segments into the second set of vertical line segments and the third set of vertical line segments.
[0138] Thus, the second preset value is used to divide the first vertical line segment into line segments that are intersected by text and line segments that are not intersected by text.
[0139] It should be noted that the second preset value can be half the image width or other values. The first preset value and the second preset value can be the same or different, and there are no restrictions here.
[0140] However, some line segments in the table are not intersected by text, but they are still line segments in the table. In order to avoid missing any line segments in the table, we can further divide them according to the distance between the confirmed line segments and the unconfirmed line segments.
[0141] Specifically, any segment in the set of third vertical segments is identified as the target third vertical segment, and the distance between the target third vertical segment and each second vertical segment is calculated, with the minimum distance being selected. Further, the minimum distance is compared to a second preset distance value. If the minimum distance is less than the second preset distance value, it indicates that the target third vertical segment is very close to a second vertical segment in the set of second vertical segments, and thus the target third vertical segment is determined to belong to the vertical segments in the table, i.e., it is assigned to the second vertical segment set. If the minimum distance is greater than or equal to the second preset distance value, it indicates that the target third vertical segment is an interfering segment outside the table, and thus it is not assigned to the second vertical segment set. This process is used to iterate and determine whether all third vertical segments in the set of third vertical segments need to be assigned to the second vertical segment set. Finally, the segments in the assigned second vertical segment set are those belonging to the same horizontal position range and are cells in the table, i.e., the assigned second vertical segment set is determined as the set of cell vertical segments within the same horizontal position range.
[0142] By iterating through the steps described above to obtain a set of vertical line segments in cells with the same horizontal position range, we can obtain multiple sets of second vertical line segments in different horizontal position ranges, which are multiple sets of vertical line segments in cells with different horizontal position ranges.
[0143] In the above implementation process, based on the difference between the peak value of the vertical projection curve of the vertical line segment and the second preset threshold, the vertical line segment is divided into vertical line segments intersected by text and vertical line segments not intersected by text. Based on the distance between the vertical line segments not intersected by text and the vertical line segments intersected by text, the vertical line segments belonging to the table are effectively filtered out, and the vertical line segments outside the table are removed, which further improves the accuracy of the subsequent table generation.
[0144] In one embodiment, generating a target table based on the intersection points of each horizontal line segment in a set of multiple cell horizontal line segments and each vertical line segment in a set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs, may include the following steps:
[0145] Step 1: Determine the intersection points of each horizontal and vertical line segment.
[0146] Step 2: Based on all the intersection points and the horizontal and vertical line segments that form the corresponding intersection points, a cell is formed.
[0147] Step 3: Determine the target table based on all cells.
[0148] For example, the intersection point between each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments is determined, and the horizontal and vertical line segments to which the corresponding intersection point belongs are formed.
[0149] Furthermore, based on all the intersection points and the horizontal and vertical line segments corresponding to each intersection point, corresponding cells are formed, and all cells are combined into the target table corresponding to the table image to be recognized. Figure 5 This is a schematic diagram of a target table provided in an embodiment of this application. Figure 5 The target table shown is formed by combining multiple cells.
[0150] In the above implementation process, cells are formed based on the intersection points of horizontal and vertical line segments and the corresponding horizontal and vertical line segments. The target table is then composed of all the cells, rather than reconstructing the table based on any two pairs of intersection points. This avoids the generation of line segments without any points in the table, effectively improving the accuracy of the generated table. Furthermore, generating cells by intersection points and then combining all the cells to obtain the target cell effectively avoids the problem of text being truncated in the cells caused by connecting the vertices on the outer edge of the table.
[0151] In one embodiment, determining the target table based on all cells may include the following steps:
[0152] Step 1: Determine the first table based on all cells.
[0153] Step 2: Project the intersection points of all cells horizontally to obtain the horizontal projection line.
[0154] Step 3: Project the intersection points of all cells vertically to obtain the vertical projection line.
[0155] Step 4: Generate a second table based on the horizontal and vertical projection lines.
[0156] Step 5: Generate the target table based on the first table and the second table.
[0157] For example, in order to determine the original structure of a table of merged cell types before merging, the table consisting of all cells can also be defined as the first table. Figure 6 This is a schematic diagram of a first table provided in an embodiment of this application, such as... Figure 6 As shown, the first table is the table after merging the cells.
[0158] Furthermore, the intersection points of all cells in the first table are projected horizontally and vertically to obtain horizontal and vertical projection lines. All horizontal and vertical projection lines are then combined to obtain the second table. Figure 7 This is a schematic diagram of a second table provided in an embodiment of this application, such as... Figure 7 As shown, the second table is... Figure 6 Merged cells are in the table before the merge.
[0159] Furthermore, the first table and the second table are overlapped to obtain the target table corresponding to the image to be identified. Additionally, the table before or after cell merging can be displayed as needed.
[0160] In the above implementation process, a second table is generated based on the horizontal and vertical projection curves obtained from the horizontal and vertical projections of the intersection points of all cells. This effectively realizes the generation of the original table before cell merging. Finally, a target table is generated based on the tables before and after cell merging, which makes it easier to distinguish and display the merged cell type table from the target table, thus improving the application scope and robustness of the table recognition method.
[0161] In one embodiment, the method may further include the following steps:
[0162] Step 1: Identify all text regions in the table image.
[0163] Step 2: Perform horizontal and vertical projections on each text region separately to obtain the horizontal and vertical text projection results for each text region.
[0164] Step 3: Determine the orientation of the table image based on the number of horizontal jump points in the horizontal text projection results of all text regions and the number of vertical jump points in the corresponding vertical text projection results.
[0165] For example, in a table document, there may be a phenomenon where the table orientation is rotated. For instance, when the table width is large, in order to display all the table content in the document, the table may be rotated 90 degrees. To identify the table orientation, the text areas of all cells in the table image can be determined. Furthermore, each text area is subjected to horizontal and vertical projections respectively, thereby obtaining the horizontal and vertical text projection results corresponding to each text area.
[0166] When projecting a text area, the number of jump points obtained from a projection direction parallel to the text direction is usually greater than the number obtained from a projection direction perpendicular to the text direction. Therefore, the number of jump points in the horizontal and vertical text projection results can be used to determine whether the text has been rotated, and further, whether the table has been rotated. It should be noted that when the height difference between adjacent projections in the projection result is greater than the text line height, it is recorded as one jump point.
[0167] Figure 8 This is a schematic diagram illustrating the text projection result when the text direction has not been rotated, as provided in an embodiment of this application. Figure 8 As shown, when the text direction is not rotated, the number of horizontal jump points in the projection result is less than the number of vertical jump points. Figure 9 This is a schematic diagram illustrating the text projection result when the text direction is rotated, as provided in an embodiment of this application. Figure 9 As shown, when the text direction is rotated 90 degrees, the number of horizontal jump points is greater than the number of vertical jump points.
[0168] Therefore, the number of horizontal jump points appearing in the horizontal text projection result corresponding to each text region, and the number of vertical jump points appearing in the vertical text projection result corresponding to each text region can be determined.
[0169] Determine the total number of horizontal jump points corresponding to all text regions, and the total number of vertical jump points corresponding to all text regions. If the total number of horizontal jump points is greater than the total number of vertical jump points, the table in the table image has been rotated 90 degrees; if the total number of horizontal jump points is less than the total number of vertical jump points, the table in the table image has not been rotated 90 degrees. This determines the orientation of the table in the table image.
[0170] In the above implementation process, by determining the number of horizontal jump points in the horizontal text projection result of the text area and the number of vertical jump points in the corresponding vertical text projection result, the orientation of the table can be accurately determined based on the total number of horizontal jump points and the total number of vertical jump points.
[0171] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0172] Based on the same inventive concept, this application also provides a table recognition device for implementing the table recognition method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more table recognition device embodiments provided below can be found in the limitations of the table recognition method described above, and will not be repeated here.
[0173] In one exemplary embodiment, Figure 10 This is a schematic diagram of the structure of a table recognition device provided in an embodiment of this application, such as... Figure 10 As shown, the device includes:
[0174] Image acquisition module 110 is used to acquire the image of the table to be recognized;
[0175] The line segment detection module 120 is used to perform line segment detection on the table image to obtain multiple horizontal line segments and multiple vertical line segments;
[0176] The horizontal line segment set determination module 130 is used to determine multiple cell horizontal line segment sets in different vertical position ranges from multiple horizontal line segments based on the horizontal projection information of each horizontal line segment in multiple horizontal line segments. Each cell horizontal line segment set includes at least one horizontal line segment in the same vertical position range.
[0177] The vertical line segment set determination module 140 is used to determine multiple cell vertical line segment sets in different horizontal position ranges from multiple vertical line segments based on the longitudinal projection information of each vertical line segment in multiple vertical line segments. Each cell vertical line segment set includes at least one vertical line segment in the same horizontal position range.
[0178] The table generation module 150 is used to generate a target table based on the intersection point of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs.
[0179] In one embodiment, the line segment detection module 120 is specifically used for:
[0180] Line segment detection is performed on the table image to obtain multiple initial horizontal line segments and multiple initial vertical line segments;
[0181] Traverse and determine the total number of intersections between any of the multiple initial horizontal line segments and other line segments;
[0182] Delete line segments whose number of intersections with other line segments is less than a preset number, resulting in multiple horizontal line segments and multiple vertical line segments.
[0183] In one embodiment, the horizontal line segment set determination module 130 is specifically used for:
[0184] By performing a horizontal projection on each of the multiple horizontal line segments, the horizontal projection curve corresponding to each horizontal line segment is obtained.
[0185] By dividing the horizontal line segments whose heights are within the same vertical position range into a single cell line segment set, multiple cell line segment sets with different vertical position ranges are obtained.
[0186] In one embodiment, the horizontal line segment set determination module 130 is specifically used for:
[0187] The horizontal line segments whose heights are within the same vertical position range are divided into a first horizontal line segment set, which includes multiple first horizontal line segments.
[0188] The first horizontal line segment whose peak in the horizontal projection curve of the first horizontal line segment set is greater than the first preset value is divided into the second horizontal line segment set, and the second horizontal line segment set includes at least one second horizontal line segment.
[0189] The first horizontal line segment whose peak value is less than or equal to the first preset value is divided into the third horizontal line segment set, and the third horizontal line segment set includes at least one third horizontal line segment.
[0190] Iterate through the data to determine the minimum distance between each third horizontal line segment and multiple second horizontal line segments;
[0191] The third horizontal line segment whose minimum distance is less than the first preset distance value is assigned to the second horizontal line segment set until all third horizontal line segments in the third horizontal line segment set have been traversed.
[0192] Define the second set of horizontal line segments as the set of horizontal line segments of cells within the same vertical position range;
[0193] Based on multiple sets of second horizontal lines, determine multiple sets of cell horizontal line segments located in different vertical position ranges.
[0194] In one embodiment, the vertical line segment set determination module 140 is specifically used for:
[0195] By projecting each of the multiple vertical line segments longitudinally, the longitudinal projection curve corresponding to each vertical line segment is obtained.
[0196] The vertical line segments whose widths are within the same horizontal position range are divided into a set of vertical line segments in a single cell, resulting in multiple sets of vertical line segments in different horizontal position ranges.
[0197] In one embodiment, the vertical line segment set determination module 140 is specifically used for:
[0198] The vertical line segments whose widths are within the same horizontal position range are divided into a first set of vertical line segments, and the first set of vertical line segments includes multiple first vertical line segments.
[0199] Vertical segments whose peaks in the longitudinal projection curve of the first vertical segment set are greater than the second preset value are assigned to the second vertical segment set, and the second vertical segment set includes at least one second vertical segment.
[0200] Vertical segments whose peaks in the longitudinal projection curves of the first set of vertical segments are less than or equal to the second preset value are assigned to the third set of vertical segments. The third set of vertical segments includes at least one third vertical segment.
[0201] Iterate through the data to determine the minimum distance between each third vertical line segment and multiple second vertical line segments;
[0202] The third vertical line segment whose minimum distance is less than the second preset distance value is assigned to the second vertical line segment set, until all third vertical line segments in the third vertical line segment set have been traversed;
[0203] Define the second set of vertical line segments as the set of vertical line segments of cells within the same horizontal position range;
[0204] Based on multiple sets of second vertical lines, determine multiple sets of cell vertical line segments located in different horizontal positions.
[0205] In one embodiment, the table generation module 150 is specifically used for:
[0206] Determine the location of the intersection points between each horizontal and vertical line segment;
[0207] A cell is formed by all the intersection points and the horizontal and vertical line segments that form the corresponding intersection points;
[0208] The target table is determined based on all cells.
[0209] In one embodiment, the table generation module 150 is specifically used for:
[0210] The first table is determined based on all cells;
[0211] By projecting the intersection points of all cells horizontally, a horizontal projection line is obtained;
[0212] Projecting the intersection points of all cells vertically, we obtain the vertical projection line;
[0213] A second table is generated based on the horizontal and vertical projection lines;
[0214] Generate the target table based on the first table and the second table.
[0215] In one embodiment, the table generation module 150 is specifically used for:
[0216] Identify all text regions in the table image;
[0217] Perform horizontal and vertical projections on each text region separately to obtain the horizontal and vertical text projection results for each text region.
[0218] The orientation of the table image is determined based on the number of horizontal jump points in the horizontal text projection results of all text regions and the number of vertical jump points in the corresponding vertical text projection results.
[0219] Each module in the aforementioned table recognition device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0220] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11 As shown, Figure 11 This is an internal structural diagram of a computer device provided in an embodiment of this application. The computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database stores image data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a table recognition method.
[0221] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0222] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the table recognition method in any of the above embodiments.
[0223] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the table recognition method in any of the above embodiments.
[0224] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0225] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0226] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0227] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A table recognition method, characterized in that, The method includes: Obtain the image of the table to be recognized; Line segment detection is performed on the table image to obtain multiple horizontal line segments and multiple vertical line segments; Based on the lateral projection information of each of the multiple horizontal line segments, a set of multiple cell horizontal line segments in different vertical position ranges is determined from the multiple horizontal line segments. Each set of cell horizontal line segments includes at least one horizontal line segment in the same vertical position range. Based on the longitudinal projection information of each of the multiple vertical line segments, a set of multiple cell vertical line segments in different horizontal position ranges is determined from the multiple vertical line segments. Each set of cell vertical line segments includes at least one vertical line segment in the same horizontal position range. The target table is generated based on the intersection point of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs.
2. The method according to claim 1, characterized in that, The step of performing line segment detection on the table image to obtain multiple horizontal line segments and multiple vertical line segments includes: Line segment detection is performed on the table image to obtain multiple initial horizontal line segments and multiple initial vertical line segments; Traverse and determine the total number of intersections between any of the multiple initial horizontal line segments and other line segments; Line segments with fewer than a preset number of intersections with other line segments are deleted to obtain the plurality of horizontal line segments and the plurality of vertical line segments.
3. The method according to claim 1, characterized in that, The step of determining multiple sets of cell horizontal line segments within different vertical position ranges from the multiple horizontal line segments based on the lateral projection information of each horizontal line segment includes: By performing a horizontal projection on each of the plurality of horizontal line segments, the horizontal projection curve corresponding to each horizontal line segment is obtained. The horizontal line segments whose heights are within the same vertical position range are divided into a set of horizontal line segments in a single cell, thus obtaining multiple sets of horizontal line segments in different vertical position ranges.
4. The method according to claim 3, characterized in that, The step of dividing the horizontal line segments whose heights are within the same vertical position range into a set of cell line segments to obtain multiple sets of cell line segments in different vertical position ranges includes: The horizontal line segments whose heights are within the same vertical position range of the horizontal projection curve are divided into a first set of horizontal line segments, and the first set of horizontal line segments includes multiple first horizontal line segments. The first horizontal line segment whose peak of the horizontal projection curve of the first horizontal line segment set is greater than the first preset value is divided into the second horizontal line segment set, and the second horizontal line segment set includes at least one second horizontal line segment. The first horizontal line segment whose peak value is less than or equal to the first preset value is divided into the third horizontal line segment set, and the third horizontal line segment set includes at least one third horizontal line segment. The minimum distance between each of the third horizontal line segments and the plurality of second horizontal line segments is determined by traversing the network. The third horizontal line segment corresponding to the minimum distance value being less than the first preset distance value is divided into the second horizontal line segment set, until all third horizontal line segments in the third horizontal line segment set have been traversed; The second set of horizontal line segments is defined as the set of horizontal line segments of cells within the same vertical position range; The multiple sets of horizontal line segments in different vertical positions are determined based on the multiple sets of the second horizontal line.
5. The method according to claim 1, characterized in that, The step of determining multiple sets of cell vertical line segments in different horizontal position ranges from the multiple vertical line segments based on the longitudinal projection information of each vertical line segment includes: Each of the plurality of vertical line segments is projected longitudinally to obtain the longitudinal projection curve corresponding to each vertical line segment; The vertical line segments whose widths are within the same horizontal position range are divided into a set of vertical line segments in a single cell, thus obtaining multiple sets of vertical line segments in different horizontal position ranges.
6. The method according to claim 5, characterized in that, The step of dividing the vertical line segments whose widths of the longitudinal projection curves are within the same horizontal position range into a set of vertical line segments in a single cell, thereby obtaining multiple sets of vertical line segments in different horizontal position ranges, includes: The vertical line segments whose widths are within the same horizontal position range are divided into a first set of vertical line segments, and the first set of vertical line segments includes multiple first vertical line segments. Vertical segments whose peaks in the longitudinal projection curves of the first set of vertical segments are greater than a second preset value are assigned to a second set of vertical segments, and the second set of vertical segments includes at least one second vertical segment. Vertical segments whose peaks in the longitudinal projection curves of the first set of vertical segments are less than or equal to the second preset value are assigned to a third set of vertical segments, wherein the third set of vertical segments includes at least one third vertical segment. The minimum distance between each of the third vertical line segments and the plurality of second vertical line segments is determined by traversing the network. The third vertical line segment corresponding to the minimum distance value being less than the second preset distance value is assigned to the second vertical line segment set until all third vertical line segments in the third vertical line segment set have been traversed. The second set of vertical line segments is defined as the set of vertical line segments of cells within the same horizontal position range; The set of multiple cell vertical line segments located in different horizontal positions is determined based on multiple sets of the second vertical line.
7. The method according to claim 1, characterized in that, The step of generating a target table based on the intersection points of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, and the horizontal and vertical line segments to which each intersection point belongs, includes: Determine the location of the intersection point between each horizontal line segment and each vertical line segment; A cell is formed by all the intersection points and the horizontal and vertical line segments that form the corresponding intersection points; The target table is determined based on all cells.
8. The method according to claim 7, characterized in that, Determining the target table based on all cells includes: The first table is determined based on all cells; By projecting the intersection points of all cells horizontally, a horizontal projection line is obtained; Projecting the intersection points of all cells vertically, we obtain the vertical projection line; A second table is generated based on the horizontal projection lines and the vertical projection lines; The target table is generated based on the first table and the second table.
9. The method according to claim 1, characterized in that, The method further includes: Identify all text regions in the table image; Each text region is subjected to horizontal and vertical projections to obtain the horizontal and vertical text projection results for each text region. The orientation of the table image is determined based on the number of horizontal jump points in the horizontal text projection results of all text regions and the number of vertical jump points in the corresponding vertical text projection results.
10. A form recognition device, characterized in that, The device includes: The image acquisition module is used to acquire the table image to be recognized; The line segment detection module is used to perform line segment detection on the table image to obtain multiple horizontal line segments and multiple vertical line segments; The horizontal line segment set determination module is used to determine multiple cell horizontal line segment sets in different vertical position ranges from the multiple horizontal line segments based on the horizontal projection information of each horizontal line segment in the multiple horizontal line segments. Each cell horizontal line segment set includes at least one horizontal line segment in the same vertical position range. The vertical line segment set determination module is used to determine multiple cell vertical line segment sets located in different horizontal position ranges from the multiple vertical line segments based on the longitudinal projection information of each vertical line segment in the multiple vertical line segments. Each cell vertical line segment set includes at least one vertical line segment located in the same horizontal position range. The table generation module is used to generate a target table based on the intersection point of each horizontal line segment in the set of multiple cell horizontal line segments and each vertical line segment in the set of multiple cell vertical line segments, as well as the horizontal and vertical line segments to which each intersection point belongs.