A line frame topology repairing and semantic space dividing method for engineering drawings

CN122531050BActive Publication Date: 2026-09-18YUANZHIFU (HANGZHOU) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610988981.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-07-03
Publication Date
2026-09-18
Estimated Expiration
2046-07-03

AI Technical Summary

Technical Problem

传统方法仅能进行基于连通域的简单分割,无法区分这些语义类别

Benefits of technology

本发明实现算法参数的自适应与动态调整,提升系统泛化能力:通过分析图纸中线框的骨架与结构张量,自动识别墙线类型(单层/双层)并精确计算全局平均线宽、双层墙间距等关键物理特征。将这些特征作为动态参数反馈给后续处理模块,使得虚线检测、门洞闭合、形态学操作等算法的阈值和核尺寸能够自适应不同绘图标准、比例尺和扫描质量的图纸,显著提升了整套方案的鲁棒性与适应性,克服了固定参数算法难以适配多种图纸规格的痛点。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122531050B_ABST
    Figure CN122531050B_ABST
Patent Text Reader

Abstract

The application discloses an engineering drawing line frame topology repair and semantic space division method, comprising a line frame feature analysis and parameter decision step: analyzing an input engineering drawing line frame diagram, extracting line width and line type features, and outputting the features as dynamic parameters; a line frame topology repair step: based on the dynamic parameters, detecting virtual line gaps and door hole bottlenecks in the drawing, adopting multiple geometric constraints and text collision avoidance strategies, and performing pixel-level completion on the virtual line gaps and door hole structures meeting the conditions to form a topologically closed line frame diagram; and a semantic space division step: based on the topologically closed line frame diagram, giving labels to each closed region in the drawing, synchronously expanding the labels with an OCR frame as a seed, detecting boundaries through real-time connected domain analysis, automatically stopping at the color boundaries of different entries, and forming colored regions; thereby providing a high-precision, high-robustness and high-logic automatic processing scheme for complex engineering drawings.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial safety technology, and more specifically, to a method for wireframe topology repair and semantic spatial partitioning of engineering drawings. Background Technology

[0002] In the field of computer vision and image processing, automated risk area identification and annotation of CAD engineering drawings or scanned drawings in fields such as architecture and factories is a key technology for intelligent safety management and digital factory construction. Existing technical solutions are typically based on traditional image processing algorithms, but they face several core challenges when processing complex and diverse real-world engineering drawings: Damage to wireframe structure: Traditional methods for erasing text on drawings typically use rectangular bounding boxes detected by OCR (Optical Character Recognition) to directly cover or erase the text area. However, text annotations in engineering drawings often intersect or overlap with wireframes (wall lines, axis lines) representing the outlines of walls, beams, and equipment. This method of erasing the entire rectangular bounding box can inadvertently damage the pixels of the wireframes overlapping with the text, causing breakage of the underlying geometric skeleton of the drawing, destroying the overall topological structure of the image, and creating serious hidden dangers for subsequent region segmentation and filling steps.

[0003] Poor robustness and adaptability of algorithms: Actual engineering drawings exhibit significant differences in visual features due to variations in design standards, drawing specifications, output scale, and scanning quality. This is primarily reflected in the varying thickness of wall lines and diverse line styles (e.g., solid lines, double lines / hollow lines representing thick walls). Most existing algorithms employ fixed morphological processing parameters (such as kernel size for dilation and erosion, gap detection thresholds, etc.), making it difficult to adaptively adapt to different drawing specifications. Consequently, while the same set of parameters may yield acceptable results for some drawings, it can lead to issues like incorrect wireframe connections, incorrect disconnections, or feature extraction failures for others.

[0004] Difficulty in Wireframe Topology Closure: Engineering drawings contain numerous dashed lines (representing hidden lines, planning lines, etc.) and doorway structures, which appear as discontinuous wireframes in the image. When using traditional region-filling algorithms (such as FloodFill), the algorithm "overflows" at these discontinuities, causing color to fill outside the intended area, resulting in "color leakage." Existing methods lack robust mechanisms to automatically and accurately detect and repair these specific discontinuous structures to form closed fill boundaries.

[0005] Difficulty in distinguishing semantic regions: Different regions in drawings possess different physical and functional semantics, such as independent functional rooms (exclusive areas), large spaces shared by multiple devices (non-exclusive areas), and corridors connecting these areas. Traditional methods can only perform simple segmentation based on connected components and cannot distinguish these semantic categories. This leads to the inability to adopt differentiated strategies based on regional semantics during automated coloring (e.g., corridors should not be colored over large areas), resulting in inaccurate coloring ranges and logically confused risk visualization results.

[0006] In summary, existing technologies have significant shortcomings in processing complex engineering drawings, particularly in terms of geometric preservation, parameter adaptation, topological integrity restoration, and high-level semantic understanding. There is an urgent need for a high-precision, robust, and automated processing solution that can comprehensively address these issues. Summary of the Invention

[0007] This invention overcomes the shortcomings of existing technologies and provides a method for wireframe topology repair and semantic spatial partitioning of engineering drawings that offers high precision, high robustness, and high logic for fully automatic risk area identification and coloring.

[0008] The technical solution of the present invention is as follows: A method for wireframe topology repair and semantic spatial partitioning of engineering drawings includes the following steps: S1 Wireframe Feature Analysis and Parameter Decision Steps: Analyze the input engineering drawing wireframe, extract line width and line type features, and output them as dynamic parameters; S2 wireframe topology repair steps: Based on the dynamic parameters obtained from S1, the gaps between dashed lines and bottlenecks in the drawing are detected, and multiple geometric constraints and text collision avoidance strategies are adopted to perform pixel-level completion of the gaps between dashed lines and the structure of the doorway that meet the conditions, forming a topologically closed wireframe diagram. S3 Semantic Space Partitioning Steps: Based on the topological closure wireframe obtained in S2, assign exclusive, non-exclusive, and passageway labels to each closed region in the drawing. Use OCR boxes as seeds for synchronous expansion, detect boundaries through real-time connected component analysis, and automatically stop at the color boundaries of different terms to form colored areas.

[0009] Furthermore, in step S2, detecting the dashed line gap includes: scanning and identifying white gaps along the row or column direction of the image, and extracting the gap length, the length and thickness of the wall segments on both sides of the gap; only when the gap length is less than a first preset threshold, the length of the wall segments on both sides is greater than a second preset threshold, the ratio of the thickness of the wall lines on both sides is less than a third preset value, and the number of candidate gaps that intersect at a vertical position on the same straight line is not less than two, is the area determined to be a dashed line structure and completed.

[0010] Furthermore, in step S2, detecting the bottleneck of the doorway includes: generating a width mapping map based on the wireframe diagram, searching for local bottlenecks in the width mapping map, and verifying the width by combining the projection intersection width of the wide regions on both sides of the bottleneck, so as to identify the doorway structure.

[0011] Furthermore, the bottleneck of the doorway is precisely located by analyzing the changing trend of the "width field," and the specific operation is as follows: i) Width Map Generation: Calculate the horizontal width map of the entire image. and vertical width diagram The value of each pixel represents the geometric width of its connected region in the corresponding direction. ii) One-dimensional Gaussian smoothing noise reduction: The width profile is processed by one-dimensional Gaussian filtering to eliminate width fluctuations caused by scanning noise or wall line burrs. iii) Bottleneck identification: A sliding window is used to search for the local minimum bottleneck; the span k is determined by the average line thickness. and average spacing Decide:

[0012] Where Round indicates rounding the result to the nearest integer; if the current bottleneck width W(y) is significantly smaller than its neighborhood width W(y±k), and satisfies If so, it is marked as an effective bottleneck; iv) Neighborhood overlap verification: Calculate the width of the projection intersection of the wide regions above, below, left, and right of the bottleneck; only when the intersection width is greater than the width of the current bottleneck position is it confirmed as a doorway region that needs to be closed.

[0013] Furthermore, in step S2, the text collision avoidance strategy specifically involves: compressing the identified text area according to a preset ratio to generate a protection mask; before repairing the detected doorway or dotted line gap, simulating the coverage area of ​​the repair block; if the simulated area intersects with the protection mask, then abandoning the repair operation.

[0014] Furthermore, in step S3, assigning exclusive, non-exclusive, and passageway labels to each area includes: S31. Using the coordinates of each text annotation in the drawing as seed points, execute the flood fill algorithm to generate the corresponding initial area mask; S32. Calculate the overlap between the initial region masks, and use the disjoint-set data structure algorithm to aggregate the masks with an overlap higher than a preset threshold into the same logical group; for a logical group containing only one mask, assign it an exclusive label, and for a logical group containing multiple masks, assign it a non-exclusive label. S33. For the region mask corresponding to each logical group, morphological dilation and collision detection are used to count the number of all distinct adjacent regions. If the number of adjacent regions exceeds a preset threshold, a passage label is assigned to the region.

[0015] Furthermore, in step S33, the method of counting the number of adjacent regions through morphological dilation and collision detection includes: for each logical group region, dilution is performed by multiplying the thickness of the wall by a specific coefficient, and it is observed whether there is pixel intersection with the mask of other regions to determine whether the two are adjacent; the number of all distinct adjacent regions of the logical group region is counted.

[0016] The advantages of this invention compared to the prior art are: This invention achieves adaptive and dynamic adjustment of algorithm parameters, enhancing the system's generalization ability: by analyzing the skeleton and structural tensor of the wireframe in the drawing, it automatically identifies the wall line type (single-layer / double-layer) and accurately calculates key physical features such as the global average line width and the spacing between double-layer walls. These features are fed back as dynamic parameters to subsequent processing modules, enabling the thresholds and kernel sizes of algorithms such as dashed line detection, doorway closure, and morphological operations to adapt to drawings with different drawing standards, scales, and scanning qualities. This significantly improves the robustness and adaptability of the entire solution, overcoming the pain point of fixed-parameter algorithms being unable to adapt to various drawing specifications.

[0017] This invention, by establishing rules that include multiple geometric constraints such as gap length, support length of wall segments on both sides, thickness consistency, and the number of coaxial candidates, can accurately distinguish between true "dashed line structures" and "isolated wall openings," completing only the dashed lines that meet the collective characteristics, thus significantly reducing the false repair rate. Combined with a doorway detection mechanism that uses a "wide-narrow-wide" template and neighborhood overlap verification, it can accurately identify and close doorways.

[0018] By employing a "text collision avoidance strategy," the collision between the repair block and the compressed OCR text protection mask is simulated before repair. If a collision occurs, the repair is abandoned, ensuring that the topology repair operation does not destroy the original text annotation information in the drawing. This achieves linkage between geometric repair and semantic preservation, improving the logical correctness of the processing.

[0019] By calculating the overlap between region masks (using disjoint-set aggregation) and statistical topological adjacency (detecting the number of neighbors through morphological dilation), the system can automatically assign "exclusivity," "non-exclusivity," and "corridor" labels to each region. This enables the system to understand the spatial logic of the drawing, distinguish between independent rooms, shared spaces, and circulation corridors, and provide a semantic basis for differentiated coloring strategies.

[0020] This invention accurately identifies "corridors" and assigns them corresponding labels, preventing large-scale incorrect coloring of corridors due to incomplete wireframes or algorithmic logic defects. This ensures that the color blocks in the final generated "risk four-color map" more accurately focus on the actual production or functional rooms, improving the accuracy and interpretability of risk visualization. Furthermore, it implements multi-strategy adaptive coloring, balancing efficiency and boundary accuracy: the system intelligently selects three strategies—"direct filling," "competitive expansion," or "OCR box fallback"—based on the "exclusivity," "quality," and "corridor" labels of the region mask. This guarantees fast rendering of high-quality exclusive areas while solving the boundary delineation problem when multiple color blocks compete for space in non-exclusive areas and corridors. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of the overall process of the present invention; Figure 2 This is a schematic diagram of an original engineering drawing of the present invention; Figure 3 This is a schematic diagram of the text removal results of the present invention; Figure 4 This is a schematic diagram of the wall line expansion and background noise removal processing results of the present invention; Figure 5 This is a schematic diagram of the result of the dotted line and the doorway closure in this invention; Figure 6 This is a four-color diagram of the risk area of ​​the completed invention; Figure 7 This is a schematic diagram of another engineering drawing of the present invention; Figure 8 This is a diagram illustrating the text erasure result; Figure 9 This is a schematic diagram of a single-layer wall line of the present invention; Figure 10 This is a schematic diagram of the double-layer wall line of the present invention; Figure 11 This is a schematic diagram of the overlapping mask aggregation of the present invention. Detailed Implementation

[0022] Embodiments of the present invention are described in detail below, wherein the same or similar reference numerals denote the same or similar elements or elements with similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention and should not be construed as limiting the present invention.

[0023] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless defined as herein.

[0024] The numbering of steps mentioned in the various embodiments is merely for descriptive convenience and does not imply a sequential relationship. Different steps in various specific embodiments can be combined in different orders to achieve the inventive objective of this invention.

[0025] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. Example 1

[0026] A method for wireframe topology repair and semantic spatial partitioning of engineering drawings includes the following steps: S1 Wireframe Feature Analysis and Parameter Decision Steps: Analyze the input engineering drawing wireframe, extract line width and line type features, and output them as dynamic parameters.

[0027] S2 wireframe topology repair steps: Based on the dynamic parameters obtained from S1, the gaps between dashed lines and bottlenecks in the drawing are detected, and multiple geometric constraints and text collision avoidance strategies are adopted to perform pixel-level completion of the gaps between dashed lines and the structure of the doorway that meet the conditions, forming a topologically closed wireframe diagram.

[0028] The detection of the dashed line gaps includes: scanning and identifying white gaps along the row or column direction of the image, and extracting the gap length, the length and thickness of the wall segments on both sides of the gap. A dashed line structure is determined and completed only when, on the same straight line, the gap length is less than a first preset threshold, the lengths of the wall segments on both sides are greater than a second preset threshold, the ratio of the thicknesses of the wall segments on both sides is less than a third preset value, and the number of candidate gaps intersecting at a vertical position on the straight line is not less than two.

[0029] The detection of the bottleneck in the doorway includes: generating a width mapping map based on the wireframe diagram, searching for local bottlenecks in the width mapping map, and verifying the width by combining the projection intersection width of the wide regions on both sides of the bottleneck, so as to identify the doorway structure.

[0030] The bottleneck in the doorway is precisely located by analyzing the changing trend of the "width field," and the specific operation is as follows: i) Width Map Generation: Calculate the horizontal width map of the entire image. and vertical width diagram The value of each pixel represents the geometric width of its connected region in the corresponding direction.

[0031] ii) One-dimensional Gaussian smoothing noise reduction: The width profile is processed by one-dimensional Gaussian filtering to eliminate width fluctuations caused by scanning noise or wall line burrs.

[0032] iii) Bottleneck identification: A sliding window search is used to find the local minimum bottleneck. The span k is determined by the average line thickness obtained. and average spacing Decide:

[0033] Where Round indicates rounding the result to the nearest integer. If the current bottleneck width W(y) is significantly smaller than its neighborhood width W(y±k), and satisfies... If it is, then it is marked as an effective bottleneck.

[0034] iv) Neighborhood overlap verification: Calculate the width of the projected intersection of the wide regions above, below, left, and right of the bottleneck. Only when the intersection width is greater than the width of the current bottleneck position is it confirmed as a doorway region that needs to be closed.

[0035] The text collision avoidance strategy specifically involves compressing the identified text area according to a preset ratio to generate a protection mask. Before repairing detected gaps or dashed lines, the coverage area of ​​the repair block is simulated. If the simulated area intersects with the protection mask, the repair operation is abandoned.

[0036] S3 Semantic Spatial Partitioning Steps: Based on the topologically closed wireframe obtained in S2, assign exclusive, non-exclusive, and passageway labels to each closed region in the drawing. Synchronous expansion is performed using OCR boxes as seeds. Boundaries are detected through real-time connected component analysis, and the process automatically stops at the color boundaries of different terms, forming colored areas. Assigning exclusive, non-exclusive, and passageway labels to each region includes the following: S31. Using the coordinates of each text annotation in the drawing as seed points, execute the flood fill algorithm to generate the corresponding initial area mask.

[0037] S32. Calculate the overlap between the initial region masks, and use the disjoint-set data structure algorithm to aggregate masks with an overlap higher than a preset threshold into the same logical group. For a logical group containing only one mask, assign it an exclusive label; for a logical group containing multiple masks, assign it a non-exclusive label.

[0038] S33. For the region mask corresponding to each logical group, morphological dilation and collision detection are used to count the number of all distinct adjacent regions. If the number of adjacent regions exceeds a preset threshold, a passage label is assigned to the region.

[0039] The method of counting adjacent regions through morphological dilation and collision detection includes: for each logical group region, dilution is performed by multiplying the wall thickness by a specific coefficient, and observing whether it intersects with the masks of other regions to determine if they are adjacent. The number of all distinct adjacent regions in that logical group region is then counted. Example 2

[0040] like Figure 1 As shown, an automatic identification and coloring method for risk areas in complex engineering drawings based on multi-model fusion includes the following steps: S1 Drawing Text Parsing and Non-destructive Erasing Steps: For the input engineering drawing, an OCR model is used for text detection and recognition to obtain the text content and its bounding box coordinates. After local merging and segmentation, LLM (Liquidity Management Model) can be selectively introduced for semantic error correction. Then, the SAM2 model is used to perform pixel-level segmentation within the text content and its bounding box coordinates, extracting only the mask of the area occupied by the character itself. Based on the mask, the corresponding pixel area in the drawing is erased to preserve the wireframe structure outside the text area. This maximizes the preservation of the geometric wireframe skeleton around the text, avoiding accidental damage to the surrounding wireframes caused by rectangular frame erasing.

[0041] The text content and its bounding box coordinates can be semantically verified and spatially reconstructed based on a preset standard term knowledge base to obtain optimized text bounding boxes. Using the optimized text bounding boxes as prompts, the visual segmentation SAM2 model is invoked for pixel-level instance segmentation to generate accurate text masks.

[0042] To address the complexities of irregular text layout, dense line breaks, and multiple parallel terms in engineering drawings, a term reconstruction scheme based on semantic-geometric bidirectional verification was designed on top of the underlying visual recognition. The specific steps are as follows: 1) Low-level information extraction based on a high-performance inference engine Engine Invocation: The system uses the RapidOCR framework to call the PP-OCRv4 deep learning inference engine to perform global text detection and recognition on the input original engineering drawings. It accurately extracts the string content of all text elements in the drawings, as well as their corresponding two-dimensional spatial coordinate sets (BoundingBoxes), forming an initial structured text and image dataset.

[0043] 2) "Line break merging" and "adhesive segmentation" mechanisms based on standard knowledge bases Due to the unique nature of industrial drawing annotations, the original OCR results often exhibit misalignment between physical boundaries and logical semantics. Therefore, a pre-defined "standard term knowledge base" is introduced to compare, verify, and spatially reconstruct the initial data.

[0044] For multi-frame terms, a line-breaking merging method is used: Drawings often contain text that is broken into multiple lines due to space constraints (e.g., "air compressor" and "machine room" displayed on separate lines), causing OCR to misidentify them as multiple isolated terms. The system calculates the spatial distance between candidate frames (Euclidean distance and vertical overlap) and compares the combined text with the knowledge base. If a standard term is matched, a merging operation is performed, and the minimum bounding rectangle encompassing all fragments is recalculated as the new coordinates.

[0045] For cases where a single bounding box contains multiple words, a parallel segmentation method is used: When multiple independent functional area labels are closely arranged on the same horizontal line (such as "rest area processing area"), OCR is very likely to misidentify it as a single long term. The system performs knowledge base segmentation and matching on the extracted string. If it finds that the string contains multiple independent standard terms, it performs a segmentation operation. The system dynamically divides the original long bounding box into multiple independent text boxes based on the physical pixel ratio of the string length, and assigns each box the correct coordinate information.

[0046] This breaks through the limitations of traditional image processing that relies solely on visual features. By introducing a priori "standard knowledge base," it completely solves the inherent pain points of "fragmentation" and "excessive adhesion" in OCR when dealing with complex industrial drawings from a semantic dimension. This ensures the subsequent geometric accuracy processing downstream and provides "seed coordinates" for subsequent SAM2 model erasure, dashed line / doorway closure, and floodfill algorithms.

[0047] Addressing the common problem of text annotations in engineering drawings frequently overlapping with building wall lines, equipment outlines, and dimension lines, this solution abandons the traditional, crude "rectangular outline erasure" approach. Instead, it introduces the SAM2 (SegmentAnythingModel2) visual segmentation model, achieving pixel-level processing that "erases only the text, without damaging the lines." The implementation steps are as follows: 1) BoxPrompting based on spatial coordinates The system receives structured data output from the front-end "OCR and knowledge base dual verification module" and extracts high-precision text bounding box coordinates after merging and segmentation correction. These two-dimensional coordinate sets are used as spatial prompt matrices and are batch-input into the SAM2 image segmentation model deployed in the inference backend, guiding the model to focus its attention mechanism on each local image region (ROI) containing text.

[0048] 2) Pixel-level text feature extraction and mask generation The SAM2 model leverages its powerful zero-shot generalization ability and deep image feature extraction network to perform fine-grained instance segmentation within each input bounding box. It automatically extracts the precise pixel-level contours of text strokes, generating a high-fidelity text mask. This process accurately distinguishes between the "black pixels of the character body" and "interfering pixels such as wall lines and pipes interspersed within the text box," ensuring that the mask's boundaries conform to the text topology.

[0049] 3) Lossless Text Erasure The precise text mask output by SAM2 is mapped back to the original engineering drawing (or binarized drawing). Targeted pixel replacement operations are performed on the areas covered by the mask (such as setting it to a white background pixel value of 255, or performing local image inpainting), while areas outside the mask (i.e., engineering primitives such as lines and arcs that are contained within the original OCR rectangle but are not part of the text strokes) are preserved to the greatest extent possible.

[0050] The traditional BoundingBox erasing method inevitably causes "physical breaks" in wall lines or pipes overlapping with the text when removing text, disrupting the geometric continuity of the drawing. However, the SAM2 model achieves more precise pixel removal, preserving the original global topological skeleton of the drawing to the maximum extent. This reduces the dimensionality and improves efficiency of subsequent algorithms. Because the original wireframe is preserved to the greatest extent, the pressure and misjudgment rate of subsequent morphological restoration algorithms such as "dashed line filling" and "doorway closure" are greatly reduced, fundamentally improving the robustness of connected component segmentation in the risky four-color image. Specific effects are shown below. Figure 7 and Figure 8 As shown.

[0051] S2 Wireframe Feature Analysis and Parameter Decision Steps: The drawing processed by S1 is binarized, the wall line skeleton is extracted, and the global average line width is calculated. Based on this, the wall line type (single-layer / double-layer line) can be automatically identified and its characteristic thickness calculated. The global average line width is used as a dynamic parameter to adjust the parameters of subsequent processing algorithms.

[0052] It also includes calculating the wall line normal direction based on the structural tensor and performing spatial probing along the normal direction to statistically analyze the proportion of skeleton pixels with parallel symmetry. Based on this, it determines whether the drawing is in a single-layer solid line or double-layer hollow line style, and extracts the average spacing of the double-layer wall lines. The average spacing is also used as a dynamic parameter to adjust the parameters of subsequent processing algorithms.

[0053] The specific steps for drawing feature analysis based on structural tensor and space exploration are as follows: 1) Image preprocessing and standardization First, the original RGB drawing is converted to grayscale and then adaptively binarized using Otsu's binarization method. To ensure consistency in subsequent algorithms, the system implements "intelligent inversion" by calculating the global proportion of bright pixels, ensuring that the processed objects are uniformly formatted as black background with white lines.

[0054] 2) Linewidth estimation based on "skeleton-range field" fusion The morphological skeleton extraction algorithm is used to obtain the central axis S of the line, and the binarized image is then processed. Euclidean distance transformation to generate a distance field map .

[0055] The calculation formula is the line at the point Local thickness ,in Extract the width values ​​of all points on the skeleton and apply a preset threshold. After filtering out abnormal noise, the average value is taken to obtain the global feature linewidth. .

[0056] 3) Calculation of the orientation field based on the structure tensor Instead of simple gradient calculations, a structure tensor is introduced to obtain the topological orientation of lines in the drawing, thereby utilizing eigenvalue decomposition to calculate the image's feature vectors. Feature values ​​are then extracted. The eigenvector corresponding to the dominant gradient direction This vector is the normal direction perpendicular to the direction of the wall line.

[0057] 4) Vectorized Spatial Parallel Probing Mechanism To distinguish between "single-layer solid lines" and "double-layer hollow lines," this scheme employs a detection logic based on normal stepping: i) Detection point generation: For the skeleton Every point on Along its normal Ray detection is performed in both positive and negative directions.

[0058] ii) Dynamic search range: The search range is defined as follows: Set minimum step size This avoids interference from the width of the current line itself, maximizing the step size. Used to capture potential parallel opposite lines.

[0059] iii) Collision detection: If the coordinates are within the search range If a skeleton pixel is detected again at this location, then the decision point is determined. It has parallel symmetry.

[0060] Single-layer and double-layer wall lines are as follows Figure 9and Figure 10 As shown, Figure 9 For single-layer wall lines, Figure 10 It is a double-layer wall line.

[0061] 5) Determination of wall line type based on coverage Sum the number of skeleton pixels that possess "parallel symmetry". Calculate its position in the total skeleton pixels. Percentage in: ,

[0062] when When the preferred threshold is 0.8, the drawing is determined to be in a double-line / hollow-line style (the same drawing is determined to be one wall line style, with no mixed styles). Otherwise, it is determined to be in a single-layer solid-line style. If it is determined to be a double-line style, the system will automatically extract the detected average spacing. This spacing will serve as a dynamic reference parameter for subsequent "wireframe expansion" and "doorway detector" operations, enabling the algorithm to self-calibrate for drawings of different scales. If the style is determined to be single-line, then set... .

[0063] S3 Wireframe Topology Repair Steps: Based on the text position information obtained in S1 and the dynamic parameters obtained in S2, the gaps between dashed lines and bottlenecks in the drawing are detected. Multiple geometric constraints and text collision avoidance strategies are employed to perform pixel-level completion of eligible gaps and bottleneck structures, forming a topologically closed wireframe diagram. Specifically, multi-dimensional heuristic rules including gap length, support length, thickness consistency, and boundary protection are established, and completion is performed using vertical intersection calculations. A "width-narrow-width" geometric template detector is introduced, linked in real-time with the OCR semantic box. If a detected bottleneck coincides with a text mark, it is determined to be a non-bottom structure and is not closed.

[0064] The specific detection of dashed line gaps includes: scanning along the rows and columns of the image to identify white gaps, and extracting the gap length, the length and thickness of the wall segments on both sides. Only when there are at least two candidate gaps on the same straight line that meet the following conditions: the gap length is less than a threshold, the length of the wall segments on both sides is greater than the minimum support length, the ratio of the thickness of the wall lines on both sides is less than a preset value, and there is an intersection in the vertical position, is the area determined to be a dashed line structure and is then completed.

[0065] The text collision avoidance strategy specifically involves compressing the text region recognized by OCR according to a preset ratio to generate a protection mask. Before repairing detected gaps or dashed lines, the coverage area of ​​the repair block is simulated. If this area intersects with the protection mask, the repair operation is abandoned.

[0066] Specifically, the gaps between the dashed lines and the bottlenecks in the doorway are inspected, mainly to distinguish between "dashed line markings" and "isolated openings".

[0067] The specific steps for creating gaps between dashed lines are as follows: i) Gap Search and Feature Extraction: Scan the binarized image along rows (or columns) to identify gaps formed by white pixels. Extract the gap length. Length of wall sections on both sides of the gap ( ) and the vertical thickness of the side wall lines ( ).

[0068] ii) Multi-heuristic constraint filtering: Length constraint: gap length It must be less than the preset maximum threshold, and the wall sections on both sides must have sufficient support length, that is... At the same time, it is greater than the preset minimum support length threshold.

[0069] Thickness consistency verification: the thickness ratio of the two side wall lines The ratio should be smaller than a preset ratio (preferably 2.0), and the intersection of their vertical positions should be smaller than a preset ratio. It must be greater than zero to ensure that they belong to the same straight line.

[0070] iii) Collective verification logic: On the same horizontal (or vertical) straight line, the line is only determined to be a "dashed line" when the number of candidate gaps N that meet the above conditions is greater than or equal to 2. This effectively prevents the algorithm from mistakenly blocking isolated gaps.

[0071] For dashed structures that have passed all validation mechanisms, this project will complete them.

[0072] 2) The bottleneck of the doorway is accurately located by analyzing the changing trend of the "width field". The specific operation is as follows: i) Width Map Generation: Calculate the horizontal width map of the entire image. and vertical width diagram The value of each pixel represents the geometric width of its connected region in the corresponding direction.

[0073] ii) One-dimensional Gaussian smoothing noise reduction: The width profile is processed by one-dimensional Gaussian filtering to eliminate width fluctuations caused by scanning noise or wall line burrs.

[0074] iii) Bottleneck identification: A sliding window search is used to find the local minimum bottleneck. The span k is determined by the average line thickness obtained. and average spacing Decide:

[0075] The "Round" option indicates that the result is rounded to the nearest integer.

[0076] If the current bottleneck width W(y) is significantly smaller than its neighborhood width W(y±k), and satisfies If the value is 1, it is marked as an effective bottleneck, and the preferred Ratio is 1.2.

[0077] iv) Neighborhood overlap check: Calculate the width of the projected intersection of the wide regions above and below (or to the left and right) of the bottleneck. Only when the intersection width is greater than the width of the current bottleneck position is it confirmed as a doorway area that needs to be closed. This is mainly used to eliminate false doorways formed by the alignment of corners of different rooms.

[0078] 3) Collision-escape security filling mechanism based on text-protected mask To prevent the repair algorithm from disrupting the connectivity of text-occupied areas in the drawing, an OCR-linked protection mechanism is introduced, as follows: i) Protection Mask Generation: The text region recognized by OCR is compressed by a certain ratio (preferably 0.8) and then converted into a highlight protection mask. .

[0079] ii) Repair Simulation: Simulate repairing the partially identified bottleneck in the doorway bottleneck, thus calculating the coverage area of ​​the filling block in the actual space. .

[0080] iii) Decision-making logic: If If the area to be repaired overlaps with the text region, the system will forcibly abandon the repair task to maintain the connectivity of the region. Otherwise, the repair will proceed. This ensures that the repair process is "semantically safe" and will not cut off key text annotations due to closed wireframes.

[0081] S4 Region Semantic Segmentation and Attribute Determination Steps: Based on the closed wireframe obtained in S3, each region is assigned exclusive, non-exclusive, and passageway labels. For non-exclusive regions and passageways, synchronous expansion is performed using OCR boxes as seeds. Boundaries are detected through real-time connected component analysis, and the process automatically stops at the color boundaries of different terms, forming colored regions.

[0082] Using the coordinates of each risk-annotated text as seed points, a flooding-fill algorithm is executed to generate corresponding initial region masks. The overlap between each region mask is calculated, and a disjoint-set data structure algorithm is used to aggregate masks with high overlap into the same logical group. Based on this, each region is assigned an exclusive or non-exclusive label. Morphological dilation and collision detection are used to count the number of neighboring regions in each logical group. If the number of neighboring regions exceeds a preset threshold, the region is assigned a passageway label.

[0083] The specific determination of aisle labels is as follows: For each logical group region, morphological dilation of its region mask is performed until it intersects with the pixel masks of other regions to determine their adjacency. The number of all distinct adjacent regions in that logical group region is counted; if this number exceeds a certain threshold, the region is determined to be an aisle. Specific steps: 1) Initial region mask generation based on flood filling Before performing topological and semantic analysis, the initial region mask generation based on floodfill requires obtaining the physical spatial boundary corresponding to each risk term. Based on the repaired closed binarized wireframe, the center of the coordinate frame of each term (risk point) is used as a seed point, and the floodfill algorithm is applied to perform pixel-level connected component diffusion. The filling process automatically stops when it touches the black wall boundary, thus extracting the corresponding initial region mask set for each of the n risk terms in the drawing. These masks visually define the independent physical rooms or isolated spaces where each risk point is located, laying the foundation for subsequent calculations of overlap and topological relationships.

[0084] 2) Overlapping mask aggregation based on disjoint-set data structure Since there may be multiple risk points in the same area of ​​the factory, the "exclusivity" of the risk point is first determined by calculating whether the mask overlaps with other masks: Overlap verification: Calculate the overlap between any two masks. and The intersection-over-union ratio (IoU) or one-way coverage. If (Preferably 0.5), then it is determined that the risk points corresponding to the two are in the same physical space. ).

[0085] like Figure 7 The image shown is the original image that needs to be colored. Figure 11 The area mask for the "embossing machine" in the middle room is on the left side of the first row. Figure 11 The mask for the "manual workbench" in the middle room is on the right side of the first row. Since the two overlap, they are both determined to be "non-exclusive". Figure 11 The second row in the middle is the mask for the "Hazardous Chemicals Warehouse" in the room on the left. Since there are no other masks that overlap with it, it is determined to be "exclusive".

[0086] Logical merging: A disjoint-set data structure algorithm is used to group mask indices with high overlap into the same logical group, avoiding duplicate counts caused by dense labeling and ensuring the accuracy of subsequent neighbor statistics.

[0087] 3) Topological adjacency calculation based on "expansion detection" Establish a connectivity graph between regions through spatial search: Circumscribed rectangle pre-screening: Calculate the Euclidean distance of the circumscribed rectangle for each pair of all region masks. Perform initial screening. For a given mask, its bounding rectangle is calculated as follows: find the minimum and maximum values ​​of all pixels in the mask in both the horizontal and vertical directions; the rectangle formed by these four values ​​is its bounding rectangle.

[0088] Dynamic expansion collision: for For regions smaller than the safety threshold, perform a morphological dilation operation on one of the masks (using an elliptical structuring element, with a radius of...). Dynamically defined, its value depends on the line thickness and... The value of (preferably equal to the k value mentioned above) and the dilation radius are the distance thresholds used to determine whether two regions are adjacent. The dilation method is a relatively simple algorithm for calculating the distance between the outer contours of two objects: when one shape is dilated by x pixels, the two shapes become connected, and the distance between the two shapes is x.

[0089] Adjacency determination: If the expanded mask has a pixel-level intersection with another mask, then these two regions are marked as "near neighbors". This prepares for the subsequent third step of counting the number of neighbors.

[0090] 4) Semantic discrimination of "corridors" based on neighbor counting threshold After acquiring the topological connectivity graph, the system infers the semantic attributes of nodes by analyzing their degrees. Degree statistics: Count the number of distinct external neighbors associated with each region group (NeighborCount).

[0091] Corridor determination logic: Corridors play a transit role in the building structure, and their physical boundaries are usually connected to a large number of rooms.

[0092] Threshold trigger: If (Preferably 8), then the area is marked as Otherwise, mark it as is_aisle=False.

[0093] Therefore, calculating the overlap can help determine whether a certain area is exclusively occupied by a single risk point or shared by multiple risk points, providing traversal information for subsequent coloring. Identifying corridors prevents large areas of corridors from being colored due to incomplete wireframes, ensuring that risky color blocks are concentrated in specific production or functional rooms.

[0094] Preferably, the process also includes an S5 intelligent coloring rendering step: based on the region mask obtained in S4 and its corresponding exclusive label and aisle label, combined with the mask's own fill completeness, a corresponding coloring strategy is selected for each region. The coloring strategy includes: directly filling exclusive, complete, and non-aisle masks; for non-exclusive or aisle masks, initiating a pixel-level competitive expansion-based coloring algorithm to define the precise coloring boundaries of each region; for incompletely filled masks, using their corresponding OCR text bounding boxes as the coloring area. Finally, a minimum value fusion algorithm is used to blend the target color with the original drawing pixels to generate the final risk four-color image.

[0095] Specifically, the pixel-level competitive expansion-based coloring algorithm involves assigning a unique ID to each region to be expanded in the global label map, and then, centered on its respective seed point, taking turns moving one pixel in each direction. Before each step, it checks whether there are IDs of other regions in the adjacent pixels of the target direction. If so, it immediately stops expanding in that direction, thereby forming an isolation zone between adjacent regions.

[0096] The minimum value fusion algorithm for hybrid rendering is specifically as follows: for each pixel that needs to be colored, the smaller value between the R, G, and B channel values ​​of the original pixel and the R, G, and B channel values ​​of the target color is taken as the final channel value of the output image at that pixel.

[0097] Specifically, such as Figures 2-6 The diagram illustrates the process of handling changes to an engineering drawing. Figures 2-6 The images show the original engineering drawing, the results of text removal, the results of wall line expansion and background noise removal, the results of dashed lines and doorway closure, and the final coloring effect. The complete coloring decision-making process is as follows: 1) Multi-criteria coloring strategy decision logic Based on the geometric quality, topological exclusivity, and channel semantic attributes of the region mask, the optimal solution is automatically selected from the following three execution paths: High-confidence exclusive mode: Triggering condition: The area is determined to be "exclusive" ( The mask quality meets the standards (complete internal filling) and is not located in a passageway area. ).

[0098] Execution: Directly use the generated mask for pixel-level coloring.

[0099] Dynamic expansion mode: Triggering condition: The mask is complete but is judged as non-exclusive (multiple terms competing). ) or belongs to the passageway area ( ).

[0100] Execution: Add the task to the "Competitive Growth Task Pool" for subsequent iteration space allocation.

[0101] ROI Minimization Fallback Mode: Triggering condition: When the mask is determined to be incomplete (non-high quality) and cannot be effectively expanded.

[0102] Execution: Use the bounding box of the OCR text box as the coloring area to prevent the loss of risk points.

[0103] 2) Competitive Growth Algorithm Based on Neighborhood Collision Detection For the expansion tasks in the competitive growth task pool in the above path, a fair competition strategy is adopted to define the physical boundaries: Label matrix initialization: Mark the initial IDs of all candidate text boxes in the global label graph L.

[0104] Competitive iterative growth: Each region expands outward by 1 pixel in turn according to the step sequence of "top-right-bottom-left".

[0105] Neighborhood hard isolation mechanism: Before each region step, the system scans the adjacent pixels in the target direction of the region.

[0106] Judgment criterion: If a heterogeneous ID (label from another region) exists in the neighborhood, growth in that direction is immediately stopped. This hard isolation mechanism enforces a 1-pixel-wide safety barrier between two color regions at the algorithm level, solving the problem of color overlap and contamination in densely labeled areas.

[0107] 3) Maximal Connectivity Refinement and Min-Blend Rendering Spatial intersection and cleaning: The intersection of the LabelMap generated by the competitive growth algorithm and the original segmentation mask is taken, and the maximal connected components are extracted. Scattered debris blocks caused by broken lines are removed to make the coloring edge logic consistent.

[0108] High-fidelity "color without line overlap" rendering: Employing a pixel-level minimum value fusion algorithm, for each pixel that needs to be colored, the R, G, and B values ​​of the corresponding pixel in the original image are compared with the R, G, and B values ​​of the color to be applied, and the minimum value is used for coloring.

[0109] Taking advantage of the "black lines on a white background" characteristic of industrial drawings, colored pixels are automatically discarded when they are minimized by black pixels (close to 0), so that the text, axes, and dimensions of the original drawing naturally "float" on the color blocks without the need for manual adjustment of transparency.

[0110] In summary, this invention systematically solves the core problems that have long existed in the automatic processing of engineering drawings, such as wireframe damage, poor adaptability, rampant color leakage, and semantic indistinction, through a series of interconnected technical features, including pixel-level non-destructive erasure, environmentally aware parameter decision-making, multi-constraint topology repair, semantically aware region segmentation, and intelligent competitive coloring. Ultimately, it achieves high-precision, high-robustness, and high-logic fully automatic risk area identification and coloring, which has significant practical value and promising industrial application prospects.

[0111] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0112] The several embodiments described in this application are quite specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these modifications and refinements should also be considered within the scope of protection of this invention. Therefore, the scope of protection of this patent application should be determined by the appended claims.

Claims

1. A method for wireframe topology repair and semantic spatial partitioning of engineering drawings, characterized in that, Includes the following steps: S1 Wireframe Feature Analysis and Parameter Decision Steps: Analyze the input engineering drawing wireframe, extract line width and line type features, and output them as dynamic parameters; S2 wireframe topology repair steps: Based on the dynamic parameters obtained in S1, the gaps between dashed lines and bottlenecks in the drawing are detected, and multiple geometric constraints and text collision avoidance strategies are adopted to perform pixel-level completion of the gaps between dashed lines and the doorway structure that meet the conditions, forming a topologically closed wireframe diagram; wherein, the detection of the doorway bottleneck includes: generating a width mapping map based on the wireframe diagram, searching for local bottlenecks in the width mapping map, and verifying them by combining the projection intersection width of the wide areas on both sides of the bottleneck to identify the doorway structure; The bottleneck in the doorway is precisely located by analyzing the changing trend of the "width field," and the specific operation is as follows: i) Width Map Generation: Calculate the horizontal width map of the entire image. and vertical width diagram The value of each pixel represents the geometric width of its connected region in the corresponding direction. ii) One-dimensional Gaussian smoothing noise reduction: The width profile is processed by one-dimensional Gaussian filtering to eliminate width fluctuations caused by scanning noise or wall line burrs. iii) Bottleneck identification: A sliding window is used to search for the local minimum bottleneck; the span k is determined by the average line thickness. and average spacing Decide: , Where Round indicates rounding the result to the nearest integer; if the current bottleneck width W(y) is significantly smaller than its neighborhood width W(y±k), and satisfies If so, it is marked as an effective bottleneck; iv) Neighborhood overlap verification: Calculate the width of the projection intersection of the wide regions above, below, left, and right of the bottleneck; only when the intersection width is greater than the width of the current bottleneck position is it confirmed as a doorway region that needs to be closed. S3 Semantic Space Partitioning Steps: Based on the topological closure wireframe obtained in S2, assign exclusive, non-exclusive, and passageway labels to each closed region in the drawing. Use OCR boxes as seeds for synchronous expansion, detect boundaries through real-time connected component analysis, and automatically stop at the color boundaries of different terms to form colored areas.

2. The method for wireframe topology repair and semantic spatial partitioning of engineering drawings according to claim 1, characterized in that, In step S2, detecting the gaps in the dashed lines includes: scanning and identifying white gaps along the row or column direction of the image, and extracting the gap length, the length and thickness of the wall segments on both sides of the gap; only when there are at least two candidate gaps that intersect at a vertical position on the same straight line, and the gap length is less than a first preset threshold, the lengths of the wall segments on both sides are greater than a second preset threshold, the ratio of the thicknesses of the wall segments on both sides is less than a third preset value, and the number of candidate gaps is not less than two.

3. The method for wireframe topology repair and semantic spatial partitioning of engineering drawings according to claim 1, characterized in that, In step S2, the text collision avoidance strategy is as follows: the identified text area is compressed according to a preset ratio to generate a protection mask; before repairing the detected doorway or dotted line gap, the coverage area of ​​the repair block is simulated. If the coverage area intersects with the protection mask, the repair operation is abandoned.

4. The method for wireframe topology repair and semantic spatial partitioning of engineering drawings according to claim 1, characterized in that, In step S3, assigning exclusive, non-exclusive, and passageway labels to each area includes: S31. Using the coordinates of each text annotation in the drawing as seed points, execute the flood fill algorithm to generate the corresponding initial area mask; S32. Calculate the overlap between the initial region masks, and use the disjoint-set data structure algorithm to aggregate the masks with an overlap higher than a preset threshold into the same logical group; for a logical group containing only one mask, assign it an exclusive label, and for a logical group containing multiple masks, assign it a non-exclusive label. S33. For the region mask corresponding to each logical group, morphological dilation and collision detection are used to count the number of all distinct adjacent regions. If the number of adjacent regions exceeds a preset threshold, a passage label is assigned to the region.

5. A method for wireframe topology repair and semantic spatial partitioning of engineering drawings according to claim 4, characterized in that, In step S33, the step of counting the number of adjacent regions by morphological dilation and collision detection includes: for each logical group region, dilution is performed by multiplying the wall thickness by a specific coefficient, and it is observed whether pixels are generated with other region masks; the number of all distinct adjacent regions of the logical group region is counted.

6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 5.

7. A computer-readable storage medium storing a computer program, characterized in that, When the program is executed, it performs the steps as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • House plan reconstruction method based on multi-modal semantic fusion and topological optimization and medium

    CN122134845A

  • Floor plan space detection

    US20150131871A1