Method, device, equipment, storage medium and program product for extracting engineering drawing name

By combining PDF parsing and OCR recognition with RTree search tree, the problem of poor accuracy in extracting architectural drawing titles was solved, achieving more efficient drawing title recognition and extraction.

CN122493475APending Publication Date: 2026-07-31QINGDA ORIENTAL INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
QINGDA ORIENTAL INTELLIGENT TECHNOLOGY CO LTD
Filing Date
2026-04-30
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In existing technologies, the extraction of drawing titles from architectural engineering drawings suffers from missing characters, resulting in poor extraction accuracy.

Method used

By parsing the architectural drawings using PDF and performing OCR recognition, text tags are obtained and an RTree search tree is constructed. After initial matching using coarse matching regular expressions, the data is expanded. Combined with the RTree search tree, tags that may contain the same text are found, forming a fused text set. Finally, fine matching regular expressions are used to determine the drawing name.

Benefits of technology

It improves the accuracy of drawing title extraction, reduces interference caused by missing characters and diverse text labels, and ensures the reliability of drawing title extraction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122493475A_ABST
    Figure CN122493475A_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, device, storage medium, and program product for extracting the name of an engineering drawing, relating to the field of image processing technology. The method includes: acquiring PDF parsing text tags and OCR recognition text tags of a target architectural engineering drawing to obtain text tags for the target architectural engineering drawing, and constructing a first RTree search tree; matching the text in the text tags based on a first regular expression to determine the target text tags; expanding the bounding box of the target text tags by a preset multiple, and searching for text tags that intersect with the expanded bounding box of the target text tags based on the first RTree search tree to form a fused text set; fusing the text tags in this set with the target text tags to generate fused text tags; and matching the fused text tags based on a second regular expression to determine the name of the target architectural engineering drawing. This method aims to improve the accuracy of extracting the name of the engineering drawing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing, and more particularly to a method, apparatus, device, storage medium, and program product for extracting the names of engineering drawings. Background Technology

[0002] Before construction begins, a rigorous fire safety review of the architectural drawings is necessary to identify and correct any unreasonable fire safety design flaws as early as possible. Prior to the fire safety review, the drawing title can be used to determine the professional category, number of floors, and type of the drawing, allowing the automated review system to select the correct review branch. Therefore, it is essential to be able to automatically extract the drawing title from the architectural drawings.

[0003] In existing technologies, when extracting the title of an architectural engineering drawing, there may be missing characters, resulting in poor accuracy in extracting the title. Summary of the Invention

[0004] This application provides a method, apparatus, device, storage medium, and program product for extracting engineering drawing names, which aims to improve the accuracy of engineering drawing name extraction.

[0005] In a first aspect, embodiments of this application provide a method for extracting drawing names from engineering drawings, including:

[0006] Obtain the PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and OCR recognition text tags, wherein the text tags include at least text text and bounding boxes;

[0007] Based on the text labels, a first RTree search tree is constructed, wherein the first RTree search tree contains leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text in the text label and the bounding box, and the index of a non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0008] Based on the first regular expression, the text in the text tag is matched, and based on the first matching result, the target text tag is determined;

[0009] The bounding box of the target text tag is expanded by a preset multiple, and based on the first RTree search tree, text tags that intersect with the expanded bounding box of the target text tag are searched to form a fused text set;

[0010] The text tags in the merged text set are merged with the target text tags to generate merged text tags;

[0011] Based on the second regular expression, the merged text in the merged text tag is matched, and based on the second matching result, the engineering drawing name of the target architectural engineering drawing is determined.

[0012] In one possible implementation, text tags in the fused text set are merged to generate fused text tags, including:

[0013] By iterating through the text, the relative positional relationship between any text tag in the fused text set and the target text tag is determined sequentially.

[0014] Based on the relative positional relationship, determine whether the projection of any text label and the target text label on the corresponding coordinate axis overlaps;

[0015] If yes, determine the center point line connecting the bounding box of any text tag and the bounding box of the target text tag; if no, select the next text tag in the merged text set.

[0016] Determine whether the number of pixels with gray values ​​less than the gray threshold on the line connecting the center points is less than a preset number threshold. If so, merge the corresponding text label with the target text label based on the preset merging rules to generate a merged text label. If not, discard the corresponding text label and select the next text label in the merged text set.

[0017] In one possible implementation, based on the second matching result, determining the drawing name of the target architectural drawing includes:

[0018] According to the preset order, the target architectural engineering drawing is divided into regions, and the text labels in any region are matched based on the third regular expression. The geometric center coordinates of the bounding box of the matched text labels are determined and recorded as the reference coordinates.

[0019] Based on the second matching result of the second regular expression, determine the title level of all merged text within any region;

[0020] When the title level of any merged text meets the preset level conditions, and the number of merged text in the corresponding title level is 1, the corresponding merged text is recorded as the engineering drawing title.

[0021] When the title level of any merged text meets the preset level conditions, and the number of merged texts in the corresponding title level is greater than or equal to 2, determine whether there is an inclusion relationship between the text content of any two merged texts with the same title level. If so, compare the number of characters in the two corresponding merged texts, and record the merged text with the larger number of characters as the title of the engineering drawing.

[0022] If not, calculate the distance between the geometric center point of the bounding box of the two corresponding merged texts and the reference coordinates, compare the distances, and record the merged text with the smaller distance as the drawing name.

[0023] In one possible implementation, the method further includes:

[0024] The bounding box of the text label is expanded according to a preset step size;

[0025] When it is determined that the bounding boxes of any two text labels overlap after expansion, the corresponding two text labels are clustered and merged according to preset rules, and the text labels are updated based on the clustering and fusion results.

[0026] In one possible implementation, the method further includes:

[0027] Determine the label direction of the target text label and any text label in the merged text set, and record the text labels in the merged text set with the same label direction as the target text label as the first candidate labels;

[0028] Calculate the ratio of the shorter side length of any first candidate tag to the shorter side length of the target text tag;

[0029] Select the first candidate label whose ratio falls within the preset ratio range and update the merged text set.

[0030] In one possible implementation, obtaining PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawings includes:

[0031] Obtain the PDF parsing text tags of the target architectural engineering drawings, and recognize the text within the PDF parsing text tags;

[0032] Based on the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing. The first preset condition is that the number of PDF parsing text tags in the preset area is less than the first quantity threshold, and the number of PDF parsing text tags containing preset characters is less than the second quantity threshold.

[0033] If so, perform OCR recognition on the target architectural drawings to obtain OCR-recognized text tags.

[0034] In one possible implementation, before determining whether to perform OCR recognition on the target architectural drawing based on a first preset condition, the method further includes:

[0035] Obtain the PDF file size and image file size of the target architectural engineering drawings;

[0036] Based on the PDF file size and image file size, coordinate transformation is performed on the bounding boxes in the parsed text tags of the PDF.

[0037] Based on the PDF parsing text tags after bounding box coordinate transformation and the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing.

[0038] In one possible implementation, the text tags of the target architectural drawing are determined based on PDF parsing and OCR recognition of text tags, including:

[0039] Based on the PDF parsing text tags, a second RTree search tree is constructed. The second RTree search tree contains leaf nodes and non-leaf nodes. The index of the leaf node is determined by the text and bounding box in the PDF parsing text tags. The index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0040] Based on the second RTree search tree, PDF parsing text tags that intersect with the bounding boxes of OCR-recognized text tags are sequentially searched and recorded as candidate text tags;

[0041] Calculate the area ratio of the bounding box of the candidate text label to the bounding box of the corresponding OCR-recognized text label in sequence;

[0042] When the area ratio is less than or equal to the preset ratio threshold, the candidate text labels and the corresponding OCR-recognized text labels are recorded as the text labels of the target architectural engineering drawing;

[0043] When the area ratio is greater than the preset ratio threshold, determine the longest common subsequence between the text content in the candidate text label and the text content in the corresponding OCR-recognized text label;

[0044] Determine the length of the longest common subsequence and its proportion to the length of the text content in the OCR-recognized text labels;

[0045] Determine if the length ratio is less than the preset ratio threshold. If not, record the candidate text label as the text label of the target architectural drawing.

[0046] If so, when the second preset condition is met, the OCR-recognized text label is recorded as the text label of the target architectural drawing; otherwise, the candidate text label is recorded as the text label of the target architectural drawing. The second preset condition is that the characters in the text content of the candidate text label are non-Chinese characters, and the character length in the text content of the candidate text label is less than a preset length threshold.

[0047] Secondly, embodiments of this application provide an apparatus for extracting the names of engineering drawings, comprising:

[0048] The acquisition module is used to acquire PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and to determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and OCR recognition text tags, wherein the text tags include at least text text and bounding boxes;

[0049] The building module is used to construct a first RTree search tree based on text labels. The first RTree search tree contains leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text text in the text label and the bounding box. The index of a non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0050] The first matching module is used to match the text in the text tag based on the first regular expression, and to determine the target text tag based on the first matching result;

[0051] The search module is used to expand the bounding box of the target text tag by a preset multiple, and based on the first RTree search tree, search for text tags that have an intersection with the expanded bounding box of the target text tag to form a fused text set.

[0052] The fusion module is used to merge text tags in the fusion text set with target text tags to generate fused text tags;

[0053] The second matching module is used to match the fused text in the fused text tag based on the second regular expression, and to determine the engineering drawing name of the target architectural engineering drawing based on the second matching result.

[0054] In one possible implementation, text tags in the fused text set are merged to generate fused text tags, including:

[0055] By iterating through the text, the relative positional relationship between any text tag in the fused text set and the target text tag is determined sequentially.

[0056] Based on the relative positional relationship, determine whether the projection of any text label and the target text label on the corresponding coordinate axis overlaps;

[0057] If yes, determine the center point line connecting the bounding box of any text tag and the bounding box of the target text tag; if no, select the next text tag in the merged text set.

[0058] Determine whether the number of pixels with gray values ​​less than the gray threshold on the line connecting the center points is less than a preset number threshold. If so, merge the corresponding text label with the target text label based on the preset merging rules to generate a merged text label. If not, discard the corresponding text label and select the next text label in the merged text set.

[0059] In one possible implementation, based on the second matching result, determining the drawing name of the target architectural drawing includes:

[0060] According to the preset order, the target architectural engineering drawing is divided into regions, and the text labels in any region are matched based on the third regular expression. The geometric center coordinates of the bounding box of the matched text labels are determined and recorded as the reference coordinates.

[0061] Based on the second matching result of the second regular expression, determine the title level of all merged text within any region;

[0062] When the title level of any merged text meets the preset level conditions, and the number of merged text in the corresponding title level is 1, the corresponding merged text is recorded as the engineering drawing title.

[0063] When the title level of any merged text meets the preset level conditions, and the number of merged texts in the corresponding title level is greater than or equal to 2, determine whether there is an inclusion relationship between the text content of any two merged texts with the same title level. If so, compare the number of characters in the two corresponding merged texts, and record the merged text with the larger number of characters as the title of the engineering drawing.

[0064] If not, calculate the distance between the geometric center point of the bounding box of the two corresponding merged texts and the reference coordinates, compare the distances, and record the merged text with the smaller distance as the drawing name.

[0065] In one possible implementation, the device further includes:

[0066] The expansion module is used to expand the bounding box of text tags according to a preset step size;

[0067] The label update module is used to cluster and merge the corresponding two text labels according to preset rules when it is determined that the bounding boxes of any two text labels overlap after expansion, and update the text labels based on the clustering and fusion results.

[0068] In one possible implementation, the device further includes:

[0069] The direction determination module is used to determine the label direction of the target text label and any text label in the fused text set, and to record the text labels in the fused text set that have the same label direction as the target text label as the first candidate label;

[0070] The ratio calculation module is used to calculate the ratio of the short side length of any first candidate tag to the short side length of the target text tag;

[0071] The set update module is used to select the first candidate label whose ratio falls within a preset ratio range and update the fused text set.

[0072] In one possible implementation, obtaining PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawings includes:

[0073] Obtain the PDF parsing text tags of the target architectural engineering drawings, and recognize the text within the PDF parsing text tags;

[0074] Based on the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing. The first preset condition is that the number of PDF parsing text tags in the preset area is less than the first quantity threshold, and the number of PDF parsing text tags containing preset characters is less than the second quantity threshold.

[0075] If so, perform OCR recognition on the target architectural drawings to obtain OCR-recognized text tags.

[0076] In one possible implementation, before determining whether to perform OCR recognition on the target architectural drawing based on a first preset condition, the method further includes:

[0077] Obtain the PDF file size and image file size of the target architectural engineering drawings;

[0078] Based on the PDF file size and image file size, coordinate transformation is performed on the bounding boxes in the parsed text tags of the PDF.

[0079] Based on the PDF parsing text tags after bounding box coordinate transformation and the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing.

[0080] In one possible implementation, the text tags of the target architectural drawing are determined based on PDF parsing and OCR recognition of text tags, including:

[0081] Based on the PDF parsing text tags, a second RTree search tree is constructed. The second RTree search tree contains leaf nodes and non-leaf nodes. The index of the leaf node is determined by the text and bounding box in the PDF parsing text tags. The index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0082] Based on the second RTree search tree, PDF parsing text tags that intersect with the bounding boxes of OCR-recognized text tags are sequentially searched and recorded as candidate text tags;

[0083] Calculate the area ratio of the bounding box of the candidate text label to the bounding box of the corresponding OCR-recognized text label in sequence;

[0084] When the area ratio is less than or equal to the preset ratio threshold, the candidate text labels and the corresponding OCR-recognized text labels are recorded as the text labels of the target architectural engineering drawing;

[0085] When the area ratio is greater than the preset ratio threshold, determine the longest common subsequence between the text content in the candidate text label and the text content in the corresponding OCR-recognized text label;

[0086] Determine the length of the longest common subsequence and its proportion to the length of the text content in the OCR-recognized text labels;

[0087] Determine if the length ratio is less than the preset ratio threshold. If not, record the candidate text label as the text label of the target architectural drawing.

[0088] If so, when the second preset condition is met, the OCR-recognized text label is recorded as the text label of the target architectural drawing; otherwise, the candidate text label is recorded as the text label of the target architectural drawing. The second preset condition is that the characters in the text content of the candidate text label are non-Chinese characters, and the character length in the text content of the candidate text label is less than a preset length threshold.

[0089] Thirdly, embodiments of this application provide a device for extracting the names of engineering drawings, including: a memory and a processor;

[0090] The memory stores instructions that the computer executes;

[0091] The processor executes computer execution instructions stored in memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.

[0092] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.

[0093] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.

[0094] The method, apparatus, device, storage medium, and program product for extracting engineering drawing names provided in this application embodiment obtain PDF parsing and OCR recognition text tags by performing two different text recognition methods on the target architectural engineering drawing. These two results are then fused to obtain the text tags of the target architectural engineering drawing and create a corresponding RTree search tree. First, a coarse-matching regular expression is used to perform a first regular expression match on the text tags of the target architectural engineering drawing. Then, the bounding boxes of the matched text tags are expanded, and in conjunction with the constructed RTree search tree, text tags that may belong to the same text in the spatial representation of the architectural engineering drawing are found, forming a fused text set. These are then fused based on set rules to obtain fused text tags. Finally, a fine-matching regular expression is used to perform a second regular expression match on the fused text tags, ultimately determining the engineering drawing name of the target architectural engineering drawing. This method helps improve the accuracy of engineering drawing name extraction and reduces interference from other text tags in the target architectural engineering drawing, diverse line breaks in the engineering drawing name, and varying character lengths of the text tags. Attached Figure Description

[0095] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0096] Figure 1 A schematic diagram of the location of the drawing titles provided in this application within the architectural engineering drawings. Figure 1 ;

[0097] Figure 2 A schematic diagram of the location of the drawing titles provided in this application within the architectural engineering drawings. Figure 2 ;

[0098] Figure 3 A flowchart illustrating the method for extracting drawing names provided in this application. Figure 1 ;

[0099] Figure 4 A flowchart illustrating the method for extracting drawing names provided in this application. Figure 2 ;

[0100] Figure 5 A flowchart illustrating the method for extracting drawing names provided in this application. Figure 3 ;

[0101] Figure 6 A schematic diagram of the device for extracting the names of engineering drawings provided in this application;

[0102] Figure 7 A schematic diagram of the device for extracting the engineering drawing name provided in this application.

[0103] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0104] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0105] First, let me explain the terms used in this application:

[0106] Spatial location diversity: This refers to the fact that the text label of the drawing name (engineering drawing name) may appear in any location on the drawing.

[0107] The number of characters varies: This refers to the number of characters in the text label of the drawing name (engineering drawing name). For example, "elevation drawing" has 3 characters, while "12-story building floor plan" has 11 characters.

[0108] Multiple rotation angles: This means that the text label for the drawing name may be in a horizontal or vertical direction.

[0109] Multiple line break expressions: This refers to the possibility of line breaks in the drawing name text label. If the text label is horizontal, it may wrap vertically; if the text label is vertical, it may wrap horizontally.

[0110] Numerous text labels: Architectural engineering drawings not only contain text labels for the drawing name, but also other necessary text labels for the drawing, such as: room name text labels, door and window name text labels, dimension annotations, leader line annotations, etc.

[0111] Architectural drawings are crucial documents in the architectural design, construction, and approval processes. Typically, a single building project corresponds to a complete set of drawings. Before construction begins, these drawings must undergo rigorous fire safety review to identify and prevent unreasonable fire safety design flaws as early as possible, avoiding high repair costs later. Drawing name resolution is the foundational work for automating fire safety reviews of drawings. Architectural drawings are mainly divided into architectural, HVAC, electrical, and plumbing specialties. These drawings differ in structure, content layout, and the focus of review also varies.

[0112] Therefore, before fire safety review, it's necessary to determine the professional category, floor number, and type of the drawings so that the review system can select the correct review branch. Generally, the drawing title contains this key information, and compared to filenames, titles are more standardized and have more regular naming conventions. Therefore, if the drawing title can be found within the architectural drawings, it's highly likely that accurate drawing category, floor number, and other information can be extracted from it, thus helping the subsequent review process select the correct review branch.

[0113] The drawing titles in architectural engineering drawings exhibit a degree of spatial diversity and can be rotated at various angles. The vast majority of architectural engineering drawing titles are located in the title block area, such as... Figure 1 and Figure 2 As shown, the areas indicated by boxes 101 and 201 are where the drawing title is located. However, the drawing title of some architectural engineering drawings may not be in the title bar, or there may not even be a title bar.

[0114] Furthermore, the names of architectural engineering drawings vary in length and may contain various line breaks. In addition, architectural engineering drawings also contain a large number of text tags, all of which increase the difficulty of extracting the names of architectural engineering drawings.

[0115] These factors undoubtedly increase the difficulty of extracting the names of architectural drawings, resulting in lower accuracy in the extraction of drawing names.

[0116] The method for extracting drawing names from architectural drawings provided in this application employs two different text recognition methods—PDF parsing and OCR recognition—to obtain PDF parsing text tags and OCR recognition text tags. These two results are then fused to obtain the text tags of the target architectural drawing and create a corresponding RTree search tree. Next, a coarse-matching regular expression is used to perform a first regular expression match on the text tags of the target architectural drawing. The bounding boxes of the matched text tags are then expanded, and combined with the constructed RTree search tree, text tags that may belong to the same text in the spatial representation of the architectural drawing are found, forming a fused text set. These are then fused according to predefined rules to obtain fused text tags. Finally, a fine-matching regular expression is used to perform a second regular expression match on the fused text tags, ultimately determining the drawing name of the target architectural drawing, thus solving the technical problem of poor accuracy in extracting drawing names.

[0117] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0118] Figure 3 A flowchart illustrating the method for extracting drawing names provided in this application. Figure 1 ,like Figure 3 As shown, the method includes:

[0119] S301. Obtain the PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and OCR recognition text tags, wherein the text tags include at least text and bounding boxes;

[0120] In this embodiment, for PDF format architectural drawings, the PDF file is first converted to PNG format with a certain Dots Per Inch (DPI) parameter (e.g., 192), and the signature information is removed. Simultaneously, the OpenCV library can be used to read the PNG format architectural drawing and save the image height. and width .

[0121] For a target architectural drawing file in PDF format, the first step is to use PDF file parsing methods to extract text tags from the PDF file, denoted as PDF parsing text tags. This yields the text text (i.e., text content) of the text tag and its bounding box, which is represented by the coordinate sequence of the four vertices it contains.

[0122] Using the top-left corner of the drawing border in the PDF file as the origin, a Cartesian coordinate system is established. Starting from the top-left corner and proceeding clockwise, the coordinates of the four vertices are arranged as follows: [[x_min,y_min],[x_max,y_min],[x_max,y_max],[x_min,y_max]], where x_min and y_min are the coordinates of the top-left corner of the bounding box, and x_max and y_max are the coordinates of the bottom-right corner of the bounding box. Simultaneously, the image height of the PDF file is extracted. and image width .

[0123] It should be noted that when converting PDF files to PNG format architectural drawings, the file sizes of the two files may be the same or different. When the sizes are different, to ensure the accuracy of the text labels in the target architectural drawing, the bounding box vertex coordinates extracted from the PDF parsing text labels can be transformed to the PNG coordinate system based on the image height and width of the PDF file and the image height and width of the PNG file. Alternatively, the bounding box vertex coordinates in the OCR-recognized text labels in the PNG format can be transformed to the PDF coordinate system.

[0124] For PNG format architectural drawings, full-image text label detection and recognition can be performed by calling a deep learning model (such as the PP-OCRv4 model). The recognized OCR text label includes at least: the text text of the text label (i.e., the text content), the bounding box, and the confidence score. The bounding box is also represented as a coordinate sequence of four vertices [[x_min,y_min],[x_max,y_min],[x_max,y_max],[x_min,y_max]], where [x_min,y_min] is the coordinate of the upper left corner of the bounding box, and [x_max,y_max] is the coordinate of the lower right corner of the bounding box.

[0125] The coordinate system of the coordinate points in the above coordinate sequence is also a Cartesian coordinate system established with the upper left corner of the drawing border in the PNG file as the origin.

[0126] After obtaining the PDF parsing text tags and OCR recognition text tags, you can first recognize the content of the text in the two types of text tags, and then select one of the text tags with the same content to keep. For example, keep the PDF parsing text tags, and use the deduplicated PDF parsing text tags and OCR recognition text tags as the text tags of the target architectural engineering drawing.

[0127] At this point, the text tags of the target architectural engineering drawing contain two types of text tags: PDF parsing text tags and OCR recognition text tags, which together serve as the data source for extracting the drawing name, reducing the possibility of poor accuracy in drawing name extraction due to errors in a single data source (such as missing characters, garbled characters, etc.).

[0128] In this embodiment, each of the above text labels contains at least text and its corresponding bounding box, which is a sequence of coordinates of four vertices.

[0129] In one possible implementation, to ensure the accuracy of the text labels of the obtained target architectural drawings, two closely spaced text labels can be merged to reduce the impact of some abnormal text labels on the accuracy of drawing title extraction. The above method also includes:

[0130] The bounding box of the text label is expanded according to a preset step size;

[0131] When it is determined that the bounding boxes of any two text labels overlap after expansion, the corresponding two text labels are clustered and merged according to preset rules, and the text labels are updated based on the clustering and fusion results.

[0132] In this embodiment, for any type of text tag obtained through the above two methods, adjacent text tags in this type of text tag can be clustered and fused based on the distance between the text tags.

[0133] This embodiment uses the Python geometry library Shapely as an example to illustrate the above text label clustering and fusion process.

[0134] First, you can use a Python geometry library like Shapely to convert the bounding box coordinate sequence in each text label information into a geometric object, Polygon. Then, using the buffer method provided by the Shapely library, set the buffer distance parameter to 1 (or other values) to perform an expansion operation on the bounding box's geometric object, Polygon, that is, expand the edges of the text label's bounding box outward by 1 unit.

[0135] After processing in this way, especially for OCR recognition of text tags, if the bounding boxes of two text tags overlap, it means that the two text tags should be of the same category (the text content is related), and they can be merged according to preset rules.

[0136] Considering that text labels may have multiple rotation angles, i.e., text labels containing engineering drawing names may be horizontal or vertical, the current direction of each text label can be determined based on the ratio or length of the horizontal and vertical sides of its original bounding box. Then, based on the determined direction of the text labels and in combination with preset rules, the label fusion operation is performed by traversing through the text labels.

[0137] When determining the direction of a text label, the following method can be used: if the horizontal side of the bounding box is longer than the vertical side, then the direction of the current bounding box (the direction of the text label) is horizontal; if the horizontal side of the bounding box is shorter than the vertical side, then the direction of the current bounding box (the direction of the text label) is vertical.

[0138] 1) For bounding boxes of text labels that are all horizontal, first determine the minimum vertical side length (min_vertical) of all bounding boxes in this cluster, and simultaneously determine the coordinates (x_min, y_min) of the top-left corner and (x_max, y_max) of the bottom-right corner of all bounding boxes. Then, sort all bounding boxes using the following method:

[0139] If the difference between the y-values ​​(y_min) of the top-left corner points of the two bounding boxes is less than the minimum value min_vertical mentioned above, then the x-values ​​(x_min) of the top-left corner points of the two bounding boxes are sorted in ascending order.

[0140] If the difference in the y-values ​​of the top-left corner points of two bounding boxes is greater than the minimum value min_vertical, then the y-values ​​of the top-left corner points of these two bounding boxes are sorted in ascending order.

[0141] After sorting, when the difference in the y-value of the top-left corner of the bounding box of two adjacent text tags is less than the minimum value min_vertical, and the difference between the x-value of the top-left corner of the next text tag bounding box and the x-value (x_max) of the bottom-right corner of the current text tag bounding box is less than the horizontal side length of the current text tag bounding box divided by the character length of the text content corresponding to the current text tag, the two text tags are merged. That is, the text content of the next text tag is added after the text content of the current text tag, and the coordinate sequence of the bounding box of the merged text tag is updated.

[0142] 2) For text label bounding boxes that are all in a vertical direction, determine the minimum horizontal side length (min_horizontal) of all bounding boxes, and simultaneously determine the coordinates of the top-left corner (x_min, y_min) and bottom-right corner (x_max, y_max) of all bounding boxes. Then, sort all bounding boxes using the following method:

[0143] If the difference between the x-values ​​(x_max) at the bottom right corners of the two bounding boxes is less than the minimum value min_horizontal mentioned above, then the y-values ​​(y_min) at the top left corners of the two bounding boxes are sorted in ascending order.

[0144] If the difference between the x-values ​​(x_max) at the bottom right corner of the two bounding boxes is greater than the minimum value min_horizontal, then the x-values ​​(x_min) at the top left corner of the two bounding boxes are sorted in ascending order.

[0145] After sorting, when the difference between the x-values ​​(x_max) of the bottom right corner of the bounding boxes of two adjacent text tags is less than the minimum value min_horizontal, and the difference between the y-values ​​(y_min) of the top left corner of the bounding box of the next text tag and the y-values ​​(y_max) of the bottom right corner of the bounding box of the current text tag is less than the vertical side length of the current text tag bounding box divided by the character length of the text content corresponding to the current text tag, the two text tags are merged. That is, the text content of the next text tag is added after the text content of the current text tag, and the coordinate sequence of the bounding boxes of the merged text tags is updated.

[0146] It should be noted that when performing the above fusion operation on OCR-recognized text tags, the confidence level of each OCR-recognized text tag should also be considered.

[0147] For OCR-recognized text labels obtained by calling a deep learning model, the deep learning model will output the confidence score corresponding to the OCR-recognized text label. Then, for the text label obtained by fusing the two text labels in the above manner, its confidence score can be selected as the maximum of the confidence scores of the two fused text labels.

[0148] Meanwhile, for the OCR-recognized text labels obtained by fusing them in the above way, a confidence threshold can be set to filter out OCR-recognized text labels whose confidence after fusion is still less than the preset confidence threshold (such as 0.7), thereby reducing the impact of such labels on the accuracy of the image name recognition results.

[0149] In this embodiment, considering that the engineering drawing name should conform to certain naming rules, text tags with more than a certain number of characters (such as 40 characters) in the text text of the fused text tag can also be filtered out to reduce the impact of such tags on the accuracy of the drawing name recognition result.

[0150] The text tag clustering method in this embodiment can cluster and fuse multiple text tags of the same class based on spatial location relationship and bounding box direction, which helps to reduce the number of identified text tags, thereby improving the efficiency of engineering drawing name extraction, and also reducing the impact of some text tags that should be merged but were not merged on the accuracy of drawing name extraction.

[0151] S302. Based on the text labels, construct a first RTree search tree, wherein the first RTree search tree contains leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text in the text label and the bounding box, and the index of a non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0152] In this embodiment, an RTree data structure is introduced. Based on the text tags determined in the above process, a first RTree search tree is constructed. The first RTree search tree contains at least leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text text in the text tag and the bounding box. The index of a non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer pointing to any leaf node (text tag).

[0153] S303. Based on the first regular expression, match the text in the text tag, and based on the first matching result, determine the target text tag current_text;

[0154] S304. Expand the bounding box of the target text label current_text by a preset multiple, and based on the first RTree search tree, search for text labels that have an intersection with the expanded bounding box of the target text label current_text to form a fused text set Z.

[0155] S305. Merge the text labels in the merged text set Z with the target text label current_text to generate merged text labels;

[0156] S306. Based on the second regular expression, match the fused text in the fused text tag, and based on the second matching result, determine the engineering drawing name of the target architectural engineering drawing.

[0157] In this embodiment, the engineering drawing name of the target architectural engineering drawing is determined by two regular expression matching methods.

[0158] The first regular expression is a coarse matching regular expression. This first regular expression can contain single keywords such as "plan", "system", "description", and "fire protection" to filter out text tags that may be drawing titles. For example, the first regular expression could be:

[0159] ".*(Description | Configuration | Layout | Floor Plan | Site Plan | Elevation | Connections | Detail | Flow | Dimensions | Electrical | Emergency | Evacuation | Fire Protection | Alarm | Fire | Monitoring | Equipment | Water Supply | Fire Hydrant | Fire Extinguisher | HVAC | Smoke Control | Smoke Exhaust | Fire Prevention | Catalog | Sprinkler | Architecture | Design | Decoration | Ceiling | Ceiling | Floor | Floor Pattern | System | Evacuation | Paving | Lighting | Schematic | Boundaries | Detail | Index)."

[0160] If the above text tag matches the first regular expression, it is marked as the target text tag current_text, and then the size of its bounding box is expanded. The expansion factor can be set according to the actual situation, such as expanding to 3 times.

[0161] Then, using the expanded bounding box as a reference, a query is performed in the first RTree search tree, matching the expanded bounding box with the rectangular regions in the index entries of non-leaf nodes in the first RTree search tree. When a match is found, it indicates that the text labels corresponding to the leaf nodes on different paths under that non-leaf node are all text labels that intersect with the expanded bounding box. The set of these text labels is denoted as the fused text set Z.

[0162] Considering that text tags in different directions and positions should have different merging orders when merging, for example, for two horizontal text tags to be merged, if one text tag A is located to the lower left of another text tag B, then text tag A should be appended to the end of text tag B.

[0163] Therefore, before merging, the orientation of the text labels in the merging text set Z and the target text label current_text can be determined. This can be done based on the lengths of the horizontal and vertical edges of the bounding box. If the horizontal edge of the bounding box is longer than the vertical edge, the orientation of the text label corresponding to the current bounding box is horizontal; otherwise, it is vertical.

[0164] Next, based on the relative positions of the text labels in the fused text set Z and the target text label current_text, the fusion order is determined. For example, if the target text label current_text is horizontal and the text labels in the fused text set Z are located to the lower left of the target text label current_text, then the text labels in the fused text set Z are added after the target text label current_text to generate fused text labels.

[0165] After obtaining the merged text tags, a second regular expression is used for fine-grained matching. The regular expression used for matching can be a regular expression based on the composition characteristics of architectural engineering drawing names, which can include information such as discipline, drawing type, and drawing name suffix. For example, it can be:

[0166] "(.*drawings.*table of contents|table of contents)(\d+|[one two three four five six seven eight nine ten hundred]+|[((].*[))])?$"

[0167] It can also be:

[0168] ".*(Design Specifications|Material Specifications|Door and Window Schedule)(\d+|[One Two Three Four Five Six Seven Eight Nine Ten Hundred]+|[((].*[))])?$"

[0169] If the second regular expression matches successfully, the matched merged text tag can be used as a candidate map name. Simultaneously, based on the text information contained in the merged text tag, keyword extraction can be performed to obtain the map name level corresponding to the candidate map name. The map name level can be set according to the actual situation.

[0170] For example, the level of the candidate drawing name containing the keyword "catalog" can be set to "Level 1"; the level of the candidate drawing name containing keywords such as "plan", "layout", "description", and "detail" can be set to "Level 2". The level of Level 1 drawing names is higher than that of Level 2 drawing names.

[0171] Therefore, after obtaining the above candidate drawing names, if there is only one candidate drawing name, it is directly used as the drawing name of the target architectural engineering drawing; if there is more than one candidate drawing name, the drawing name of the target architectural engineering drawing is determined according to the drawing name level of the candidate drawing names; if there are multiple candidate drawing names under the same highest drawing name level, these drawing names can be used together as the final drawing name for output, or the final drawing name of the target architectural engineering drawing can be determined according to the text in the candidate drawing names and the corresponding set rules (such as selecting the one with the most characters).

[0172] The method for extracting drawing names from architectural drawings provided in this application involves using two different text recognition methods—PDF parsing and OCR recognition—to obtain PDF parsing text tags and OCR recognition text tags. These two results are then fused to obtain the text tags of the target architectural drawing and create a corresponding RTree search tree. First, a coarse-matching regular expression is used to perform a first regular expression match on the text tags of the target architectural drawing. Then, the bounding boxes of the matched text tags are expanded. Combined with the constructed RTree search tree, text tags that may belong to the same text in the spatial representation of the architectural drawing are found, forming a fused text set. These are then fused according to predefined rules to obtain fused text tags. Finally, a fine-matching regular expression is used to perform a second regular expression match on the fused text tags, ultimately determining the drawing name of the target architectural drawing. This method helps improve the accuracy of drawing name extraction and reduces interference from other text tags in the target architectural drawing, diverse line breaks in the drawing name, and varying character lengths of the text tags.

[0173] In one possible implementation, considering that if the drawing name wraps, and it is within a cell of a column in the architectural drawing, the wrapped drawing name should still be within that cell. Therefore, by using the center point coordinates of the bounding box edges connecting two text tags, it can be determined whether the connecting line intersects with the cell edge, and thus infer whether the corresponding text tag in the fused text set Z should be merged with the target text tag current_text. Simultaneously, this method can reduce the possibility of interference between the text content in different cells due to close cell proximity, thereby improving the reliability of the fused text tag and the accuracy of drawing name extraction. In this embodiment, merging the text tags in the fused text set Z to generate fused text tags includes:

[0174] By iterating through the text, the relative positional relationship between any text label in the fused text set Z and the target text label current_text is determined sequentially.

[0175] Based on the relative positional relationship, determine whether the projection of any text label and the target text label current_text on the corresponding coordinate axis overlaps;

[0176] If yes, determine the center point line connecting the bounding box of any text label and the bounding box of the target text label current_text; if no, select the next text label in the merged text set Z; wherein, the center point line connecting the bounding box of the text label and the bounding box of the target text label current_text is the line connecting the center points of the two adjacent sides between the bounding boxes of the two text labels.

[0177] Determine whether the number of pixels with gray values ​​less than the gray threshold on the line connecting the center points is less than a preset number threshold. If so, merge the corresponding text label with the target text label current_text based on the preset merging rules to generate a merged text label. If not, discard the corresponding text label and select the next text label in the merged text set Z.

[0178] In this embodiment, the orientation of each text tag in the fused text set Z is determined sequentially by comparing the lengths of the horizontal and vertical sides in the bounding box.

[0179] When the target text tag current_text is horizontal, for two text tags in the merged text set Z that may have line breaks, they are merged in a "top to bottom, left to right" order. When the target text tag current_text is vertical, for two text tags in the merged text set Z that may have line breaks, they are merged in a "right to left, top to bottom" order, which can include the following scenarios:

[0180] (1) When the direction of the target text label current_text is horizontal, if the text label z is above the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the X-axis direction, then construct a connecting line segment that connects the center point of the lower edge of the bounding box of text label z to the center point of the upper edge of the bounding box of the target text label current_text.

[0181] Specifically, when text label z is above target text label current_text, the following conditions must be met: the lower edge of the bounding box of text label z is less than the upper edge of the bounding box of target text label current_text - 20% of the length of the short side of the bounding box of target text label current_text, and the lower edge of the bounding box of text label z is greater than the upper edge of the bounding box of target text label current_text - the length of the short side of the bounding box of target text label current_text.

[0182] Using the OpenCV library, read the original PNG format architectural drawing. Along the line segment connecting the geometric centers of two bounding boxes, iterate pixel-by-pixel and count for pixels with a grayscale value less than 10. If no pixel with a grayscale value less than 10 exists, it's determined that the two text labels are located within the same cell and are on different lines; in this case, the text content of text label z is appended before the text content of the target text label current_text. If a pixel with a grayscale value less than 10 exists, it's determined that the two text labels are located within different cells and are unrelated.

[0183] (2) When the direction of the target text label current_text is horizontal, if the text label z is below the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the X-axis direction, then construct a connecting line segment connecting the center point of the upper edge of the bounding box of text label z to the center point of the lower edge of the bounding box of the target text label current_text.

[0184] Specifically, when text label z is located below the target text label current_text, the following conditions must be met: the top edge of the bounding box of text label z is greater than the bottom edge of the bounding box of target text label current_text + 20% of the short side length of the bounding box of target text label current_text, and the top edge of the bounding box of text label z is less than the bottom edge of the bounding box of target text label current_text + the short side length of the bounding box of target text label current_text.

[0185] Using the OpenCV library, read the original PNG format architectural drawing. Along the line segment connecting the geometric centers of two bounding boxes, iterate pixel-by-pixel and count for pixels with a grayscale value less than 10. If no pixel with a grayscale value less than 10 exists, it's determined that the two text labels are located within the same cell and are separated by line breaks; in this case, the text content of text label z is appended to the text content of the target text label current_text. If a pixel with a grayscale value less than 10 exists, it's determined that the two text labels are located within different cells and are unrelated.

[0186] (3) When the direction of the target text label current_text is horizontal, if the text label z is located to the left of the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the Y-axis direction, then construct a connecting line segment connecting the center point of the right edge of the bounding box of text label z to the center point of the left edge of the bounding box of the target text label current_text.

[0187] Specifically, when text label z is located to the left of target text label current_text, the following conditions must be met: the right edge of the bounding box of text label z is less than the left edge of the bounding box of target text label current_text - 20% of the short side length of the bounding box of target text label current_text, and the right edge of the bounding box of text label z is greater than the left edge of the bounding box of target text label current_text - the short side length of the bounding box of target text label current_text.

[0188] Repeat the pixel comparison process described above. If there are no pixels with a gray value less than 10, it is determined that the two text labels are located within the same cell and are related as local text recognition results of the same text label in the architectural drawing. In this case, the text content of text label z is added before the text content of the target text label current_text. If there are pixels with a gray value less than 10, it is determined that the two text labels are located within different cells and are not related to each other.

[0189] (4) When the direction of the target text label current_text is horizontal, if the text label z is located to the right of the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the Y-axis direction, then construct a connecting line segment from the center point of the left edge of the bounding box of text label z to the center point of the right edge of the bounding box of the target text label current_text.

[0190] Specifically, when text label z is located to the right of target text label current_text, the following conditions must be met: the left edge of the bounding box of text label z is greater than the right edge of the bounding box of target text label current_text + 20% of the short side length of the bounding box of target text label current_text, and the left edge of the bounding box of text label z is less than the right edge of the bounding box of target text label current_text + the short side length of the bounding box of target text label current_text.

[0191] Repeat the pixel comparison process described above. If there are no pixels with a gray value less than 10, it is determined that the two text labels are located within the same cell and are related as local text recognition results of the same text label in the architectural drawing. In this case, the text content of text label z is added after the text content of the target text label current_text. If there are pixels with a gray value less than 10, it is determined that the two text labels are located within different cells and are not related to each other.

[0192] (5) When the direction of the target text label current_text is vertical, if the text label z is above the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the X-axis direction, then construct a connecting line segment from the center point of the lower edge of the bounding box of text label z to the center point of the upper edge of the bounding box of the target text label current_text.

[0193] Repeat the pixel comparison process described above. If there are no pixels with a gray value less than 10, it is determined that the two text labels are located within the same cell and are related as local text recognition results of the same text label in the architectural drawing. In this case, the text content of text label z is added before the text content of the target text label current_text. If there are pixels with a gray value less than 10, it is determined that the two text labels are located within different cells and are not related to each other.

[0194] (6) When the direction of the target text label current_text is vertical, if the text label z is below the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the X-axis direction, then construct a connecting line segment that connects the center point of the upper edge of the bounding box of text label z to the center point of the lower edge of the bounding box of the target text label current_text.

[0195] Repeat the pixel comparison process described above. If there are no pixels with a gray value less than 10, it is determined that the two text labels are located within the same cell and are related as local text recognition results of the same text label in the architectural drawing. In this case, the text content of text label z is added after the text content of the target text label current_text. If there are pixels with a gray value less than 10, it is determined that the two text labels are located within different cells and are not related to each other.

[0196] (7) When the direction of the target text label current_text is vertical, if the text label z is located to the left of the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the Y-axis direction, then construct a connecting line segment connecting the center point of the right edge of the bounding box of text label z to the center point of the left edge of the bounding box of the target text label current_text.

[0197] Repeat the pixel comparison process described above. If there are no pixels with a gray value less than 10, it is determined that the two text labels are located in the same cell and are in a line break relationship. In this case, the text content of text label z is added after the text content of the target text label current_text. If there are pixels with a gray value less than 10, it is determined that the two text labels are located in different cells and are not related to each other.

[0198] (8) When the direction of the target text label current_text is vertical, if the text label z is located to the right of the target text label current_text, and the coordinate projections of the two text label bounding boxes overlap in the Y-axis direction, then construct a connecting line segment connecting the center point of the left edge of the bounding box of text label z to the center point of the right edge of the bounding box of the target text label current_text.

[0199] Repeat the pixel comparison process described above. If there are no pixels with a gray value less than 10, it is determined that the two text labels are located in the same cell and are in a line break relationship. In this case, the text content of text label z is added before the text content of the target text label current_text. If there are pixels with a gray value less than 10, it is determined that the two text labels are located in different cells and are not related to each other.

[0200] Figure 4 A flowchart illustrating the method for extracting drawing names provided in this application. Figure 2 ,like Figure 4 As shown, in this embodiment... Figure 3 Based on the embodiments, the method for extracting the drawing name of the engineering drawing is described in detail. The method includes:

[0201] S401. Obtain the PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and OCR recognition text tags, wherein the text tags include at least text text and bounding boxes;

[0202] S402. Based on the text labels, construct a first RTree search tree, wherein the first RTree search tree contains leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text in the text label and the bounding box, and the index of a non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0203] S403. Based on the first regular expression, match the text in the text tag, and based on the first matching result, determine the target text tag;

[0204] S404. Expand the bounding box of the target text label by a preset multiple, and based on the first RTree search tree, search for text labels that have an intersection with the expanded bounding box of the target text label to form a fused text set.

[0205] S405. Merge the text tags in the merged text set with the target text tags to generate merged text tags;

[0206] S406. Based on the second regular expression, match the merged text in the merged text tag;

[0207] S407. Divide the target architectural engineering drawing into regions according to the preset order, match the text labels in any region based on the third regular expression, and determine the geometric center coordinates of the bounding box of the matched text labels, which are recorded as reference coordinates.

[0208] In this embodiment, considering that the names of engineering drawings have a certain spatial variety, they are usually located in the four edges of the architectural engineering drawing paper, and most commonly in the lower right corner area. Therefore, based on the height and width of the PDF or PNG format architectural engineering drawings in the above process, the drawing is divided into 6 areas.

[0209] This process prioritizes the height of PNG format architectural drawings. and width The drawing is divided into 6 logical areas: the right side area (x-coordinate > 4 / 5) Top region (y coordinate < 1 / 5) The lower right corner area (x-coordinate > 1 / 2) And the y-coordinate is greater than 4 / 5. The lower left corner region (x-coordinate < 1 / 2) And the y-coordinate is greater than 4 / 5. ), left region (x-coordinate < 1 / 5) ) and the middle area (the remaining part excluding the four edges).

[0210] When searching for image names later, search for image names in the following order: bottom right area, bottom left area, right side area, top area, and left side area. If the image name is not found in any of these areas, then search for the image name in the middle area.

[0211] After dividing the target architectural drawings into the six regions mentioned above, the text labels obtained in the above process can be divided according to the bounding box coordinates (such as the coordinates of the top left corner). After dividing them into the corresponding regions, the subsequent drawing name extraction process can be performed sequentially according to the order of the regions. For text labels divided into a certain region, they can also be sorted according to certain rules by comparing the coordinates of the top left corner and the bottom right corner of the bounding box.

[0212] For example, text labels in the bottom right corner, top, and middle areas can be sorted according to the horizontal text label sorting order during the text label update process described above; while text labels in other areas can be sorted according to the vertical text label sorting order described above.

[0213] After completing the above area division, iterate through all text tags processed by the above process within each area, and use a third regular expression containing keywords such as "drawing name", "drawing title", and "drawing content" for matching. The third regular expression can be: ".*(drawing name|drawing title|drawing content).*".

[0214] Once a matching text label is found, it is used as the spatial reference for subsequent filtering of drawing names. The geometric center coordinates of the label's bounding box are calculated using the coordinates of its upper left and lower right corners, and used as the reference coordinates for determining the drawing name.

[0215] It should be noted that there can be at most one reference datum coordinate for the engineering drawing name in each of the above six areas. If more than one reference datum coordinate is obtained through the above process, the coordinates of the geometric center point surrounded by the text label located in the lower right corner of the corresponding area shall be selected as the reference datum coordinate for that area.

[0216] S408. Based on the second matching result of the second regular expression, determine the title level of all merged text within any region;

[0217] In this embodiment, considering that architectural engineering drawings may consist of a main drawing and sub-drawings, where the main drawing name is the name of the engineering drawing to be extracted, while the sub-drawing names may interfere with the extraction of the main drawing name, a drawing name hierarchy can also be set. The drawing name hierarchy can be determined based on keywords appearing in the drawing name, and the specific hierarchy can be set according to the actual situation.

[0218] For example, drawings containing the keyword "catalog" are designated as level 1, which is the highest level. Since drawings containing keywords such as "plan", "layout", "description", and "detail" are generally ordinary drawings, their names are designated as level 2. Drawings containing keywords such as "schematic", "principle", and "system diagram" are usually sub-drawings, and their names are designated as level 3.

[0219] It should be noted that the merged text in some extracted merged text tags may not contain regular keywords, but it may still be the final drawing name. Therefore, its drawing name level can be uniformly set to level 2.

[0220] In this embodiment, before performing the second regular expression matching, consecutive hyphens ("-") in the merged text tags can be removed; after the second regular expression matching, it can be further checked whether the matched merged text contains invalid characters, such as ".", "《", "edition", etc. If they are contained, these invalid characters and reverse lines can be deleted / discarded to ensure the accuracy of the determined map title level.

[0221] S409. When the title level of any merged text meets the preset level conditions, and the number of merged texts in the corresponding title level is 1, the corresponding merged text is recorded as the engineering drawing title.

[0222] S410. When the title level of any merged text meets the preset level conditions and the number of merged texts in the corresponding title level is greater than or equal to 2, determine whether there is an inclusion relationship between the text content of any two merged texts with the same title level. If so, compare the number of characters in the two corresponding merged texts and record the merged text with the larger number of characters as the title of the engineering drawing.

[0223] If not, calculate the distance between the geometric center point of the bounding box of the two corresponding merged texts and the reference coordinates, compare the distances, and record the merged text with the smaller distance as the drawing name.

[0224] In this embodiment, for the six regions defined above, each region may contain multiple fused text tags. After matching with the second regular expression, the second matching result may still be multiple. Therefore, it is necessary to filter these fused texts that conform to the second regular expression to determine the final engineering drawing name.

[0225] The following explanation will use the merged text label in any region as an example.

[0226] The merged text that matches the second regular expression in the above 6 regions is used as candidate image names, forming a list of candidate image names. The candidate image names in this list are then iterated through sequentially.

[0227] (1) When a candidate drawing name is found to be at level 1, it is immediately returned as the final engineering drawing name.

[0228] (2) During each iteration, the title level of the currently obtained merged text is compared with the previous results. If its title level is high, such as level 2, and meets the preset title level conditions, it is temporarily stored as the best title. Continue the iteration. If there are merged texts of the same title level, they are all temporarily stored as the best titles. If there are merged texts with title levels lower than level 2, they are discarded.

[0229] If, after completing the subsequent traversal, there is only one merged text with a drawing title level of 2, then that is output as the final drawing title.

[0230] If, after completing the subsequent traversal, there are multiple merged text texts with a drawing title level of 2, then based on the text content in these texts, it is determined whether there is an inclusion relationship between the text content of these two merged text texts with the same drawing title level. If there is an inclusion relationship, then the number of characters in these two merged text texts is compared. The one with more characters contains more comprehensive information. Therefore, the merged text text with the larger number of characters is recorded as the drawing title.

[0231] If there is no containment relationship between the text content in the two merged texts of the same title level, the distance between the geometric center point of their bounding box and the above reference coordinates is calculated. The smaller the distance, the higher the probability that it is the title of the engineering drawing. Therefore, the merged text with the smaller distance is recorded as the title of the engineering drawing so that it can be displayed on the front-end page and stored in the database.

[0232] In this embodiment, the engineering drawing name obtained in the above process can also be cleaned to determine whether the string contains the character "TITLE". If it does, the content after it is extracted. Regular expressions can also be used to correct common similar-looking character errors in the text recognition results, remove illegal characters at the beginning and end of the string, and replace all consecutive whitespace characters with underscores.

[0233] The method for extracting drawing titles from architectural drawings provided in this application employs two different text recognition methods—PDF parsing and OCR recognition—to obtain PDF-parsed text tags and OCR-recognized text tags. These two results are then fused to obtain the text tags of the target architectural drawing and create a corresponding RTree search tree. First, a coarse-matching regular expression is used to perform a first regular expression match on the text tags of the target architectural drawing. Then, the bounding boxes of the matched text tags are expanded. Combined with the constructed RTree search tree, text tags that may belong to the same text in the spatial representation of the architectural drawing are found, forming a fused text set. These are then fused based on predefined rules to obtain fused text tags. Finally, a fine-matching regular expression is used to perform a second regular expression match on the fused text tags. Based on the reference coordinates calculated using a third regular expression and the predefined drawing title level, the drawing title of the target architectural drawing is determined. This approach helps improve the accuracy of drawing title extraction and reduces interference from other text tags in the target architectural drawing, diverse line breaks in the drawing title, and varying character lengths of the text tags.

[0234] In one possible implementation, the method further includes:

[0235] Determine the label direction of the target text label current_text and any text label in the fused text set Z, and denote the text label in the fused text set Z with the same label direction as the target text label current_text as the first candidate label;

[0236] Calculate the ratio of the short side length of any first candidate label to the short side length of the target text label current_text;

[0237] Select the first candidate label whose ratio falls within the preset ratio range and update the fused text set Z.

[0238] In this embodiment, considering that the engineering drawing name may have multiple rotation angles, and the extracted text labels and the text labels contained in the fused text set Z may also have multiple rotation angles, after the direction of the target text label current_text is identified, the text labels contained in the fused text set Z can be filtered, and the text labels with the same direction as the target text label current_text can be selected as the first candidate labels.

[0239] Then, the first candidate labels are filtered based on the ratio of the shorter side lengths of the two text labels, selecting the label most likely to be merged with the target text label current_text to obtain the drawing name. Therefore, the ratio of the shorter side length of any first candidate label to the shorter side length of the target text label current_text is calculated. Only when the ratio is within a certain range is the corresponding first candidate label finally retained, and the merged text set Z is updated according to the final retention result.

[0240] It should be noted that when calculating the ratio of short side lengths, the short side length of the first candidate tag may be greater than or less than the short side length of the target text tag current_text. Therefore, when calculating the difference in short side lengths, the absolute value of the difference should be selected. Accordingly, the specific range at this time can be selected as a range less than a certain positive number (1.2).

[0241] Figure 5 A flowchart illustrating the method for extracting drawing names provided in this application. Figure 3 Considering that even for text content of the same length, the obtained PDF parsing text tags and OCR-recognized text tags will still differ due to variations in recognition accuracy, if tag deduplication is performed solely based on the text content, the resulting target architectural engineering drawing text tags will still contain a large number of text tags with some content repetition. To improve the efficiency of engineering drawing title extraction and avoid the impact of some abnormal recognition results on the accuracy of engineering drawing title extraction, this embodiment further performs a fusion operation on the PDF parsing text tags and OCR-recognized text tags before obtaining the target architectural engineering drawing text tags.

[0242] like Figure 5 As shown, in this embodiment... Figure 3 Based on the embodiments, the method for extracting the drawing name of the engineering drawing is described in detail. The method includes:

[0243] S501. Obtain the PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawings.

[0244] S502. Based on the PDF parsing text tags, construct a second RTree search tree, wherein the second RTree search tree contains leaf nodes and non-leaf nodes. The index of the leaf node is determined by the text and bounding box in the PDF parsing text tags, and the index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0245] In this embodiment, the PDF parsing text tags are denoted as tag x, and the OCR-recognized text tags are denoted as tag y. For all tags x, an RTree data structure is introduced to construct a second RTree search tree corresponding to all tags x. The second RTree search tree contains at least leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text and bounding box in the PDF parsing text tag x, and the index of a non-leaf node is determined by a rectangular region containing multiple leaf nodes and a pointer to any leaf node (tag x).

[0246] S503. Based on the second RTree search tree, sequentially search for PDF parsing text tags that intersect with the bounding boxes of OCR-recognized text tags, and record them as candidate text tags;

[0247] In this embodiment, for any tag y (OCR-recognized text tag), its corresponding bounding box is used to perform a query in the second RTree search tree. The bounding box of the tag y to be queried is matched with the rectangular region in the index item of the non-leaf node in the second RTree search tree. When a match is found, all tags x (PDF parsing text tags) that intersect with the bounding box of tag y can be obtained, and the obtained tags x are used as candidate text tags for the corresponding tag y.

[0248] S504. Calculate the area ratio of the bounding box of the candidate text label to the bounding box of the corresponding OCR recognized text label in sequence.

[0249] In this embodiment, after obtaining the candidate text label corresponding to label y (OCR-recognized text label), the area ratio between the two bounding boxes is calculated using the following formula (1), which is:

[0250]

[0251] in, Let x be the area of ​​the overlapping region between the bounding boxes of label x and label y. Let x be the area of ​​the bounding box of label x. Let y be the area of ​​the bounding box of label y. This represents the area percentage of the bounding box. At this point, label x is the selected text label to be chosen.

[0252] S505. When the area ratio is less than or equal to the preset ratio threshold, the candidate text labels and the corresponding OCR-recognized text labels are recorded as the text labels of the target architectural engineering drawing.

[0253] S506. When the area ratio is greater than the preset ratio threshold, determine the longest common subsequence between the text content in the candidate text label and the text content in the corresponding OCR-recognized text label.

[0254] S507. Determine the length of the longest common subsequence and its proportion to the length of the text content in the OCR-recognized text label;

[0255] S508. Determine whether the length ratio is less than a preset ratio threshold. If not, record the candidate text label as the text label of the target architectural drawing. If yes, when it is determined that the second preset condition is met, record the OCR-recognized text label as the text label of the target architectural drawing. Otherwise, record the candidate text label as the text label of the target architectural drawing. The second preset condition is that the characters in the text content of the candidate text label are non-Chinese characters, and the character length in the text content of the candidate text label is less than a preset length threshold.

[0256] In this embodiment, in order to remove duplicate tags that overlap between PDF parsing text tags and OCR recognition text tags, and to remove tags that contain only part of the characters, the area ratio of the bounding box between the OCR recognition text tag (tag y) and the corresponding PDF parsing text tag (tag x) is calculated, and the calculated area ratio is compared with a preset ratio threshold. The preset ratio threshold can be set according to the actual situation and the desired efficiency of engineering drawing name extraction, such as 2 / 3.

[0257] If the calculated area percentage is less than or equal to the preset percentage threshold, it is considered that the possibility of the two being the same text label is low, and both label y and the corresponding label x are used as text labels of the target architectural drawing.

[0258] If the calculated area ratio is greater than the preset ratio threshold, it is considered that there is a high probability that the two are the same text label in the target architectural drawing. At this time, the longest common subsequence of the text content in the candidate text label (selected label x) and the text content in the corresponding OCR recognized text label (label y) is calculated. The calculation method can be to traverse the strings in the two text contents character by character, or to use the corresponding dynamic programming algorithm.

[0259] Next, the length ratio of the longest common subsequence to the length of the text content in the label y is calculated. It is then determined whether the calculated length ratio is less than a preset ratio threshold. If the length ratio is greater than or equal to the preset ratio threshold, the candidate text label is recorded as the text label of the target architectural engineering drawing, and the corresponding OCR-recognized text label is deleted.

[0260] If the length percentage is less than the preset percentage threshold, then it is determined whether the text content in the corresponding candidate text label meets the second preset condition.

[0261] If the characters in the text content of the candidate text label are not Chinese characters, and the length of the characters in the text content of the candidate text label is less than the preset length threshold, then it is determined that the second preset condition is met, label y is retained and label x is deleted, that is, the OCR-recognized text label is recorded as the text label of the target architectural engineering drawing; otherwise, label x is retained and label y is deleted, that is, the candidate text label is recorded as the text label of the target architectural engineering drawing.

[0262] S509. Based on the text labels, construct a first RTree search tree, wherein the first RTree search tree contains leaf nodes and non-leaf nodes, the index of the leaf node is determined by the text text in the text label and the bounding box, and the index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0263] S510. Based on the first regular expression, match the text in the text tag, and based on the first matching result, determine the target text tag;

[0264] S511. Expand the bounding box of the target text label by a preset multiple, and based on the first RTree search tree, search for text labels that have an intersection with the expanded bounding box of the target text label to form a fused text set.

[0265] S512. Merge the text tags in the merged text set with the target text tags to generate merged text tags;

[0266] S513. Based on the second regular expression, match the fused text text in the fused text tag, and based on the second matching result, determine the engineering drawing name of the target architectural engineering drawing.

[0267] The method for extracting drawing names from architectural drawings provided in this application involves using two different text recognition methods—PDF parsing and OCR recognition—to obtain PDF parsing text tags and OCR recognition text tags. These two results are then fused to obtain the text tags of the target architectural drawing and create a corresponding RTree search tree. First, a coarse-matching regular expression is used to perform a first regular expression match on the text tags of the target architectural drawing. Then, the bounding boxes of the matched text tags are expanded. Combined with the constructed RTree search tree, text tags that may belong to the same text in the spatial representation of the architectural drawing are found, forming a fused text set. These are then fused according to predefined rules to obtain fused text tags. Finally, a fine-matching regular expression is used to perform a second regular expression match on the fused text tags, ultimately determining the drawing name of the target architectural drawing. This method helps improve the accuracy of drawing name extraction and reduces interference from other text tags in the target architectural drawing, diverse line breaks in the drawing name, and varying character lengths of the text tags.

[0268] In one possible implementation, obtaining PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawings includes:

[0269] Obtain the PDF parsing text tags of the target architectural engineering drawings, and recognize the text within the PDF parsing text tags;

[0270] Based on the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing. The first preset condition is that the number of PDF parsing text tags in the preset area is less than the first quantity threshold, and the number of PDF parsing text tags containing preset characters is less than the second quantity threshold.

[0271] If so, perform OCR recognition on the target architectural drawing to obtain the OCR-recognized text tags. If not, directly use the PDF parsing text tags as the text tags for the target architectural drawing.

[0272] In this embodiment, if all text tags contained in the target architectural drawing can be obtained through PDF file parsing, OCR recognition is not required. Therefore, in order to improve the efficiency of text tag recognition, adaptive judgment logic can be introduced. The model is only used to perform OCR recognition on the PNG format file of the target architectural drawing when it is necessary to call the deep learning model to obtain the OCR recognized text tags. This can effectively reduce the call to the deep learning model and improve the efficiency of text tag recognition when recognizing the drawing name of large-scale architectural drawings.

[0273] Considering the regularity of the location of drawing titles in engineering drawings, which mainly includes four situations: the drawing title is in the lower right corner of the drawing, the drawing title is on the right side of the drawing, the drawing title is at the top of the drawing, and the drawing title is on the left side of the drawing, the central area of ​​the architectural engineering drawing, that is, the area where both the horizontal and vertical axes are located between 1 / 5 and 4 / 5 of the drawing size, is designated as the preset area.

[0274] When determining whether to perform OCR recognition on the target architectural drawing, the number of PDF parsing text tags within the preset area can be counted, and the text in the PDF parsing text tags can be recognized. If the number of PDF parsing text tags contained in the preset area is less than the first threshold (e.g., 20), and the number of PDF parsing text tags containing preset characters (e.g., "M" and "C" representing doors and windows) is less than the second threshold (e.g., 5), then the first preset condition is met. In this case, it is determined that the PDF parsing text tags extracted from the corresponding PDF file using the PDF file parsing method have missing or garbled text tags, and a deep learning model is needed to perform OCR text tag recognition on the PNG format architectural drawing.

[0275] It should be noted that the preset area involved in this embodiment is the central area of ​​the PNG format architectural drawing. Therefore, when the size of the PDF format architectural drawing is inconsistent with the size of the PNG format architectural drawing, it is also necessary to perform coordinate transformation on the bounding box in the PDF parsing text tag.

[0276] In one possible implementation, before determining whether to perform OCR recognition on the target architectural drawing based on a first preset condition, the method further includes:

[0277] Obtain the PDF file size and image file size of the target architectural engineering drawings;

[0278] Based on the PDF file size and image file size, coordinate transformation is performed on the bounding boxes in the parsed text tags of the PDF.

[0279] Based on the PDF parsing text tags after bounding box coordinate transformation and the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing.

[0280] In this embodiment, the coordinates of the bounding boxes in the PDF parsing text tags extracted by the above PDF file parsing method are coordinates in the PDF file coordinate system. Therefore, before determining whether to perform OCR recognition on the target architectural engineering drawing, it is necessary to perform coordinate transformation on its bounding boxes to ensure that the above-mentioned first preset condition is determined under a unified coordinate system / image size.

[0281] When performing coordinate transformation, the height of the architectural engineering drawing in PDF format saved during the above process can be used as a reference. ) and image width ( The coordinates of the four vertices of the bounding box of the extracted PDF parsing text tags are transformed to the coordinate system of the PNG format architectural drawing using the following formulas (2) and (3). The corresponding formulas are:

[0282]

[0283]

[0284] in, , These are coordinates in the PDF file's coordinate system. You can substitute the coordinates of the four vertices of the bounding box in the PDF parsing text tags sequentially and perform a coordinate transformation. , These are the coordinates in the coordinate system of the architectural drawing in PNG format, i.e., the transformed coordinates. , The image height and width are for architectural drawings in PNG format.

[0285] Figure 6 A schematic diagram of the device for extracting the names of engineering drawings provided in this application, such as... Figure 6 As shown, the apparatus 60 for extracting the drawing name of an engineering drawing provided in this embodiment includes:

[0286] The acquisition module 601 is used to acquire PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and to determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and OCR recognition text tags, wherein the text tags include at least text and bounding boxes;

[0287] Module 602 is used to construct a first RTree search tree based on text labels. The first RTree search tree contains leaf nodes and non-leaf nodes. The index of a leaf node is determined by the text in the text label and the bounding box. The index of a non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0288] The first matching module 603 is used to match the text in the text tag based on the first regular expression, and determine the target text tag based on the first matching result;

[0289] The search module 604 is used to expand the bounding box of the target text tag by a preset multiple, and based on the first RTree search tree, search for text tags that have an intersection with the expanded bounding box of the target text tag to form a fused text set.

[0290] The fusion module 605 is used to merge the text tags in the fusion text set with the target text tags to generate fused text tags;

[0291] The second matching module 606 is used to match the fused text text in the fused text tag based on the second regular expression, and to determine the engineering drawing name of the target architectural engineering drawing based on the second matching result.

[0292] In one possible implementation, text tags in the fused text set are merged to generate fused text tags, including:

[0293] By iterating through the text, the relative positional relationship between any text tag in the fused text set and the target text tag is determined sequentially.

[0294] Based on the relative positional relationship, determine whether the projection of any text label and the target text label on the corresponding coordinate axis overlaps;

[0295] If yes, determine the center point line connecting the bounding box of any text tag and the bounding box of the target text tag; if no, select the next text tag in the merged text set.

[0296] Determine whether the number of pixels with gray values ​​less than the gray threshold on the line connecting the center points is less than a preset number threshold. If so, merge the corresponding text label with the target text label based on the preset merging rules to generate a merged text label. If not, discard the corresponding text label and select the next text label in the merged text set.

[0297] In one possible implementation, based on the second matching result, determining the drawing name of the target architectural drawing includes:

[0298] According to the preset order, the target architectural engineering drawing is divided into regions, and the text labels in any region are matched based on the third regular expression. The geometric center coordinates of the bounding box of the matched text labels are determined and recorded as the reference coordinates.

[0299] Based on the second matching result of the second regular expression, determine the title level of all merged text within any region;

[0300] When the title level of any merged text meets the preset level conditions, and the number of merged text in the corresponding title level is 1, the corresponding merged text is recorded as the engineering drawing title.

[0301] When the title level of any merged text meets the preset level conditions, and the number of merged texts in the corresponding title level is greater than or equal to 2, determine whether there is an inclusion relationship between the text content of any two merged texts with the same title level. If so, compare the number of characters in the two corresponding merged texts, and record the merged text with the larger number of characters as the title of the engineering drawing.

[0302] If not, calculate the distance between the geometric center point of the bounding box of the two corresponding merged texts and the reference coordinates, compare the distances, and record the merged text with the smaller distance as the drawing name.

[0303] In one possible implementation, device 60 further includes:

[0304] The expansion module is used to expand the bounding box of text tags according to a preset step size;

[0305] The label update module is used to cluster and merge the corresponding two text labels according to preset rules when it is determined that the bounding boxes of any two text labels overlap after expansion, and update the text labels based on the clustering and fusion results.

[0306] In one possible implementation, device 60 further includes:

[0307] The direction determination module is used to determine the label direction of the target text label and any text label in the fused text set, and to record the text labels in the fused text set that have the same label direction as the target text label as the first candidate label;

[0308] The ratio calculation module is used to calculate the ratio of the short side length of any first candidate tag to the short side length of the target text tag;

[0309] The set update module is used to select the first candidate label whose ratio falls within a preset ratio range and update the fused text set.

[0310] In one possible implementation, obtaining PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawings includes:

[0311] Obtain the PDF parsing text tags of the target architectural engineering drawings, and recognize the text within the PDF parsing text tags;

[0312] Based on the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing. The first preset condition is that the number of PDF parsing text tags in the preset area is less than the first quantity threshold, and the number of PDF parsing text tags containing preset characters is less than the second quantity threshold.

[0313] If so, perform OCR recognition on the target architectural drawings to obtain OCR-recognized text tags.

[0314] In one possible implementation, before determining whether to perform OCR recognition on the target architectural drawing based on a first preset condition, the method further includes:

[0315] Obtain the PDF file size and image file size of the target architectural engineering drawings;

[0316] Based on the PDF file size and image file size, coordinate transformation is performed on the bounding boxes in the parsed text tags of the PDF.

[0317] Based on the PDF parsing text tags after bounding box coordinate transformation and the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing.

[0318] In one possible implementation, the text tags of the target architectural drawing are determined based on PDF parsing and OCR recognition of text tags, including:

[0319] Based on the PDF parsing text tags, a second RTree search tree is constructed. The second RTree search tree contains leaf nodes and non-leaf nodes. The index of the leaf node is determined by the text and bounding box in the PDF parsing text tags. The index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any leaf node.

[0320] Based on the second RTree search tree, PDF parsing text tags that intersect with the bounding boxes of OCR-recognized text tags are sequentially searched and recorded as candidate text tags;

[0321] Calculate the area ratio of the bounding box of the candidate text label to the bounding box of the corresponding OCR-recognized text label in sequence;

[0322] When the area ratio is less than or equal to the preset ratio threshold, the candidate text labels and the corresponding OCR-recognized text labels are recorded as the text labels of the target architectural engineering drawing;

[0323] When the area ratio is greater than the preset ratio threshold, determine the longest common subsequence between the text content in the candidate text label and the text content in the corresponding OCR-recognized text label;

[0324] Determine the length of the longest common subsequence and its proportion to the length of the text content in the OCR-recognized text labels;

[0325] Determine if the length ratio is less than the preset ratio threshold. If not, record the candidate text label as the text label of the target architectural drawing.

[0326] If so, when the second preset condition is met, the OCR-recognized text label is recorded as the text label of the target architectural drawing; otherwise, the candidate text label is recorded as the text label of the target architectural drawing. The second preset condition is that the characters in the text content of the candidate text label are non-Chinese characters, and the character length in the text content of the candidate text label is less than a preset length threshold.

[0327] The apparatus for extracting the names of engineering drawings provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.

[0328] Figure 7 A schematic diagram of the device used to extract the names of engineering drawings provided in this application. For example... Figure 7 As shown, the device 70 for extracting engineering drawing names provided in this embodiment includes at least one processor 701 and a memory 702. Optionally, the device 70 further includes a communication component 703. The processor 701, memory 702, and communication component 703 are connected via a bus 704.

[0329] In a specific implementation, at least one processor 701 executes computer execution instructions stored in memory 702, causing at least one processor 701 to perform the above-described method.

[0330] The specific implementation process of processor 701 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0331] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0332] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0333] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0334] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0335] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0336] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0337] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0338] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0339] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0340] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0341] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0342] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0343] Finally, it should be noted that other embodiments of this application will readily conceive of by those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and alterations may be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for extracting the name of an engineering drawing, characterized in that, include: Obtain PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and the OCR recognition text tags, wherein the text tags include at least text text and bounding boxes; Based on the text tags, a first RTree search tree is constructed, wherein the first RTree search tree contains leaf nodes and non-leaf nodes, the index of the leaf node is determined by the text text in the text tag and the bounding box, and the index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any of the leaf nodes. Based on the first regular expression, the text in the text tag is matched, and based on the first matching result, the target text tag is determined; The bounding box of the target text tag is expanded by a preset multiple, and based on the first RTree search tree, text tags that intersect with the expanded bounding box of the target text tag are searched to form a fused text set; The text tags in the fused text set are merged with the target text tags to generate fused text tags; Based on the second regular expression, the merged text in the merged text tag is matched, and based on the second matching result, the engineering drawing name of the target architectural engineering drawing is determined.

2. The method according to claim 1, characterized in that, The process of fusing text tags in the fused text set to generate fused text tags includes: By iterating through the text, the relative positional relationship between any text tag in the fused text set and the target text tag is determined sequentially. Based on the relative positional relationship, determine whether the projections of any text label and the target text label on the corresponding coordinate axis overlap; If yes, determine the center point line connecting the bounding box of any text tag and the bounding box of the target text tag; if no, select the next text tag in the merged text set. Determine whether the number of pixels with gray values ​​less than a gray threshold on the line connecting the center points is less than a preset number threshold. If so, merge the corresponding text label with the target text label based on a preset merging rule to generate a merged text label. If not, discard the corresponding text label and select the next text label in the merged text set.

3. The method according to claim 1, characterized in that, The step of determining the engineering drawing name of the target architectural engineering drawing based on the second matching result includes: According to a preset order, the target architectural engineering drawing is divided into regions, and the text tags in any region are matched based on the third regular expression. The geometric center coordinates of the bounding box of the matched text tags are determined and recorded as the reference coordinates. Based on the second matching result of the second regular expression, determine the image title level of all merged text within any region; When the title level of any fused text meets the preset level conditions, and the number of fused text in the corresponding title level is 1, the corresponding fused text is recorded as the title of the engineering drawing. When the title level of any fused text meets the preset level condition, and the number of fused text in the corresponding title level is greater than or equal to 2, determine whether there is an inclusion relationship between the text content of any two fused texts with the same title level. If so, compare the number of characters in the two corresponding fused texts, and record the fused text with the larger number of characters as the title of the engineering drawing. If not, calculate the distance between the geometric center point of the bounding box of the two corresponding merged texts and the reference coordinates, compare the magnitude of the distance, and record the merged text with the smaller distance as the drawing name.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: The bounding box of the text label is expanded according to a preset step size; When it is determined that the bounding boxes of any two text tags overlap after expansion, the corresponding two text tags are clustered and merged according to preset rules, and the text tags are updated based on the clustering and fusion results.

5. The method according to any one of claims 1-3, characterized in that, The method further includes: Determine the label direction of the target text label and any text label in the fused text set, and record the text labels in the fused text set with the same label direction as the target text label as the first candidate labels; Calculate the ratio of the short side length of any of the first candidate tags to the short side length of the target text tag; Select the first candidate label whose ratio falls within a preset ratio range, and update the fused text set.

6. The method according to claim 1, characterized in that, The acquisition of PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawings includes: Obtain the PDF parsing text tags of the target architectural engineering drawing, and recognize the text in the PDF parsing text tags; Based on a first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing. The first preset condition is that the number of PDF parsing text tags in the preset area is less than a first quantity threshold, and the number of PDF parsing text tags containing preset characters is less than a second quantity threshold. If so, perform OCR recognition on the target architectural drawing to obtain the OCR-recognized text label.

7. The method according to claim 6, characterized in that, Before determining whether to perform OCR recognition on the target architectural drawing based on the first preset condition, the method further includes: Obtain the PDF file size and image file size of the target architectural drawings; Based on the PDF file size and the image file size, perform coordinate transformation on the bounding boxes in the PDF parsing text tags; Based on the PDF parsing text tags after bounding box coordinate transformation and the first preset condition, it is determined whether to perform OCR recognition on the target architectural engineering drawing.

8. The method according to claim 1 or 6, characterized in that, The process of determining the text tags of the target architectural drawing based on the PDF parsed text tags and the OCR recognized text tags includes: Based on the PDF parsing text tags, a second RTree search tree is constructed, wherein the second RTree search tree contains leaf nodes and non-leaf nodes. The index of the leaf node is determined by the text in the PDF parsing text tags and the bounding box, and the index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any of the leaf nodes. Based on the second RTree search tree, sequentially search for PDF parsing text tags that intersect with the bounding boxes of the OCR-recognized text tags, and record them as candidate text tags; Calculate the area ratio of the bounding box of the candidate text label to the bounding box of the corresponding OCR-recognized text label in sequence; When the area ratio is less than or equal to a preset ratio threshold, the candidate text labels and the corresponding OCR-recognized text labels are recorded as the text labels of the target architectural drawing; When the area ratio is greater than the preset ratio threshold, determine the longest common subsequence between the text content of the candidate text label and the text content of the corresponding OCR-recognized text label; Determine the ratio of the length of the longest common subsequence to the length of the text content in the OCR-recognized text label; Determine whether the length ratio is less than a preset ratio threshold. If not, record the candidate text label as the text label of the target architectural drawing. If so, when the second preset condition is met, the OCR-recognized text label is recorded as the text label of the target architectural drawing; otherwise, the candidate text label is recorded as the text label of the target architectural drawing. The second preset condition is that the characters in the text content of the candidate text label are non-Chinese characters, and the character length in the text content of the candidate text label is less than a preset length threshold.

9. A device for extracting the name of an engineering drawing, characterized in that, include: The acquisition module is used to acquire PDF parsing text tags and OCR recognition text tags of the target architectural engineering drawing, and determine the text tags of the target architectural engineering drawing based on the PDF parsing text tags and the OCR recognition text tags, wherein the text tags include at least text and bounding boxes; A construction module is used to construct a first RTree search tree based on the text tag, wherein the first RTree search tree contains leaf nodes and non-leaf nodes, the index of the leaf node is determined by the text text in the text tag and the bounding box, and the index of the non-leaf node is determined by a rectangular area containing multiple leaf nodes and a pointer to any of the leaf nodes. The first matching module is used to match the text in the text tag based on the first regular expression, and determine the target text tag based on the first matching result; The search module is used to expand the bounding box of the target text tag by a preset multiple, and based on the first RTree search tree, search for text tags that have an intersection with the expanded bounding box of the target text tag to form a fused text set. The fusion module is used to fuse the text tags in the fused text set with the target text tags to generate fused text tags; The second matching module is used to match the fused text in the fused text tag based on the second regular expression, and to determine the engineering drawing name of the target architectural engineering drawing based on the second matching result.

10. A device / computer-readable storage medium / computer program product for extracting the names of engineering drawings, characterized in that, The device for extracting the drawing names of engineering drawings includes: a memory and a processor; The memory stores computer-executed instructions; The processor executes the computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-8; and / or, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-8; and / or, The computer program product includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-8.