Method and system for calculating building envelope disease area

By using adaptive sampling, ray intersection, and connectivity analysis, the three-dimensional boundary of building envelope defects is restored, solving the problem of inaccuracy in defect area calculation in existing technologies and achieving high-precision defect area measurement.

CN123181544APending Publication Date: 2026-11-27NANJING WEIBO INTELLIGENT CONTROL TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611714589.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-11-02
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In existing technologies, the methods for calculating the area of ​​defects in building envelopes are difficult to reliably restore the two-dimensional labeled boundary to the three-dimensional true boundary under the influence of coarse triangular meshes, local fragments, deep mixing, and occlusions. Furthermore, the area calculation is easily affected by erroneous surface hits, resulting in inaccurate measurement results.

Method used

An adaptive tiered sampling mechanism is used to generate dense sampling points. By finding the nearest positive intersection between spatial rays and triangular meshes, combined with observation axis depth coherent grouping and multi-constraint connectivity analysis, the real connected components are decomposed. The three-dimensional boundary is restored using a position-direction joint gating mechanism. Finally, the actual area of ​​the disease is obtained by calculating planar geometric quantities.

Benefits of technology

It improves the accuracy and stability of disease area calculation, ensures semantic consistency between the calculation results and the original labeled boundaries, reduces interference from local debris and obstructions, and meets the accuracy requirements of engineering inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123181544A_ABST
    Figure CN123181544A_ABST
Patent Text Reader

Abstract

The present application relates to photogrammetry and space geometry measurement field, disclose a kind of building outer envelope disease area calculation method and system, comprising: disease marking and imaging parameter, the normalized boundary and ray calculation relationship of triangular mesh model by coordinate check and ray mapping;Marking boundary is obtained by adaptive grading sampling internal sampling pixel set;Sampling pixel is obtained by ray and triangular mesh nearest positive intersection effective intersection set;Effective intersection point is obtained by depth coherent grouping nearest depth group intersection set;Nearest depth group is obtained by multi-constraint connectivity analysis multiple real connectivity components;Each component is obtained by joint gate control solution target plane;Original marking boundary is obtained by target plane re-projection three-dimensional boundary polygon;Three-dimensional polygon is obtained by geometric calculation disease actual area and perimeter.The present application improves the accuracy and stability of disease area measurement in coarse grid scene by cascading processing of connected component splitting, joint gate control decoupling position direction and original boundary re-projection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of photogrammetry and spatial geometry measurement technology, and in particular to a method and system for calculating the area of ​​defects in the building envelope. Background Technology

[0002] Currently, defects such as hollow areas, peeling, leakage marks, and cracks in the building envelope are usually marked as two-dimensional polygons in inspection images. Due to the influence of shooting distance, viewing angle, and perspective distortion, the area of ​​two-dimensional pixels cannot be directly used for engineering quantity statistics. The actual area must be calculated by associating the marked boundaries with the three-dimensional model of the building to ensure the interpretability and accuracy of the measurement results.

[0003] The existing technology has the following main drawbacks: Relying on only a few boundary corner points for spatial intersection is greatly affected by local roughness of the triangular mesh, occlusions, and corner gaps. Rays tend to sweep across the gaps between adjacent triangular faces, making it impossible to hit them stably, which leads to the failure of boundary recovery. Directly using the outer contour of the sampling points to replace the original labeled boundary changes the semantic meaning of the disease boundary defined by the labelers, and the area result does not match the actual label meaning. Triangular meshes are discrete approximations of the actual surface. However, they have accuracy issues such as fragmentation and depth mixing in some areas. Directly using all hit points to fit the plane will be biased by local anomalies, and the direction error will be amplified, resulting in significant deviations in area calculation. When there are uncertain deviations in camera pose, the reliability of a single boundary ray is insufficient. Existing methods lack a decoupling optimization mechanism for position and orientation, making it difficult to simultaneously ensure position accuracy and orientation rationality.

[0004] Therefore, there is an urgent need for a method to calculate the area of ​​building envelope defects that can adapt to coarse triangular meshes, resist local fragment interference, and retain the original annotation semantics, so as to improve the accuracy and stability of defect area measurement in complex scenarios. Summary of the Invention

[0005] To address the aforementioned technical shortcomings, the purpose of this invention is to propose a method and system for calculating the area of ​​defects in the building envelope. This aims to solve the technical problems in the prior art where, when there are local fragments, depth mixing, occlusion, or geometric roughness in the building triangular mesh, the two-dimensional defect annotation boundary is difficult to stably recover into a three-dimensional true boundary, and the area is easily affected by erroneous surface hits.

[0006] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: The present invention provides a method for calculating the area of ​​defects in the building envelope.

[0007] The method for calculating the area of ​​defects in the building envelope includes: Step S10: Obtain the two-dimensional closed-lined boundary of the disease to be tested, the image imaging parameters, and the building triangular mesh model under a unified spatial reference. After coordinate consistency verification and spatial ray mapping, output the normalized line-of-sight boundary and spatial ray calculation relationship. Step S20: Based on the relationship between the standardized annotation boundary and the spatial ray calculation, an adaptive graded sampling mechanism is used to perform internal pixel sampling, and the set of sampled pixels inside the annotation area is output; Step S30: Based on the sampled pixel set, perform the nearest positive intersection processing of the spatial ray and the triangular mesh, and output the set of effective intersection points carrying three-dimensional coordinates, viewing axis depth and triangular face direction; Step S40: Based on the set of valid intersection points, perform depth filtering using the observation axis depth coherent grouping mechanism, and output the set of intersection points of the nearest depth group with the smallest average depth; Step S50: Based on the nearest depth group intersection set, perform component splitting using a multi-constraint connectivity analysis mechanism to output multiple mutually unconnected real connected components; Step S60: Based on each real connected component, the target plane parameter calculation is performed using a position-direction joint gating mechanism, and the target plane with determined position and direction parameters is output; Step S70: Perform spatial ray reprojection intersection on each vertex of the original labeled boundary based on the target plane, and output a three-dimensional boundary polygon that preserves the vertex order; Step S80: Perform planar geometric calculations based on the three-dimensional boundary polygon, and output the actual area and perimeter parameters of the defect.

[0008] Preferably, step S20, which involves performing internal pixel sampling using an adaptive grading sampling mechanism based on the normalized annotation boundary and outputting the set of sampled pixels within the annotation region, specifically includes: Step S201: Remove adjacent duplicate vertices from the normalized annotation boundary, determine the pixel enclosing range, and preserve the original vertex order; Step S202: Set multiple incremental target sampling scales, determine the initial sampling level based on the labeled pixel area, generate sampling points in an interlaced grid manner, and retain only pixels located inside the closed boundary; Step S203: When the hit missing ratio, depth mixing ratio or component stability does not meet the preset requirements, the sampling level is increased. When the level is increased, the calculated ray intersection results are reused, and subsequent calculations are only performed on newly added pixels. Step S204: Summarize all valid sampled pixels, arrange them by pixel coordinates, and output the sampled pixel set.

[0009] Preferably, step S30, which involves performing nearest forward intersection processing between the spatial ray and the triangular mesh based on the sampled pixel set, and outputting a set of valid intersection points carrying three-dimensional coordinates, viewing axis depth, and triangular face direction, specifically includes: Step S301: Based on the camera intrinsic parameters, convert the sampled pixels into the camera coordinate system viewing direction, and obtain the spatial ray in the world coordinate system through camera pose transformation. The starting point of the ray is the camera position, and the direction points in front of the camera. Step S302: Calculate all positive intersection candidates between a single spatial ray and the triangular mesh, sort them by ray parameters from smallest to largest, and retain only the valid intersection point closest to the camera; Step S303: Record the 3D coordinates, corresponding pixel coordinates, depth value along the observation axis and normal vector of the corresponding triangle for each valid intersection point. For missed rays, only the missed state is recorded and no virtual intersection points are generated. Step S304: Summarize the attribute information of all valid intersection points and output the set of valid intersection points.

[0010] Preferably, step S40, which involves performing depth filtering based on the set of valid intersection points using an observation axis depth coherent grouping mechanism, and outputting the nearest depth group intersection point set with the smallest average depth, specifically includes: Step S401: Using the camera's observation axis as the depth direction, calculate the axial depth value of each valid intersection point; Step S402: Set the depth neighborhood threshold and the minimum number of samples in the smallest group, and coherently group the effective intersection points according to the depth value to form multiple depth groups; Step S403: Select the effective depth group with the smallest average depth as the nearest depth group, and remove intersections and invalid groups with more distant depths; Step S404: Output the set of intersection points of the nearest depth group, which consists of all intersection points within the nearest depth group.

[0011] Preferably, step S50, which involves performing component decomposition based on the nearest depth group intersection set using a multi-constraint connectivity analysis mechanism and outputting multiple truly disconnected components, specifically includes: Step S501: Establish pixel adjacency relationships using the sampled pixels within the nearest depth group as nodes; Step S502: Simultaneously verify the local depth continuity and triangular face orientation compatibility of adjacent nodes. If both conditions are met, connectivity expansion is allowed. Step S503: Connectivity components are constructed only from actual valid hit points. Missed points, depth-removed points, and gap locations are not involved in the connection, and no point filling or gap bridging is performed. Step S504: Split to obtain multiple independent real connected components. Record the number of points, coverage, representative depth and fitting plane direction of each component, and output all real connected components.

[0012] Preferably, step S60, which involves calculating the target plane parameters based on a position-direction joint gating mechanism for each real connected component and outputting the target plane with determined position and direction parameters, specifically includes: Step S601: Select the nearest real connected component to the camera as the nearest measurement component, and calculate the position parameters of the target plane from its point set statistically. Step S602: When there are multiple real connected components, simultaneously verify four joint gating conditions: the coverage ratio of the most recently measured component is lower than the first threshold, the size ratio of the larger component covering the label center to the most recently measured component is not less than the second threshold, the label center belongs to the larger component, and the difference in the fitting direction of the two components is greater than the third threshold. Sort the multiple real connected components by size and set the top 50% as the larger components. Step S603: Calculate the angle between the plane direction of the most recently measured component and the larger component according to the following formula. :

[0013] in, Let be the unit normal vector of the fitted plane of the most recently measured component, and be a dimensionless vector. The unit normal vector of the plane fitting the larger component is a dimensionless vector. The angle between the directions of the two planes, with a value range of [0°, 90°]; Step S604: When all four conditions are met, the target plane is constructed by providing position parameters from the nearest measuring component and orientation parameters from the larger component. If any condition is not met, the target plane is constructed by providing both position and orientation parameters from the nearest measuring component. Step S605: Output the target plane containing position and orientation parameters.

[0014] Preferably, step S80, which involves performing planar geometric calculations based on the three-dimensional boundary polygon and outputting the actual area and perimeter parameters of the defect, specifically includes: Step S801: Arrange the vertices of the 3D boundary polygon in the original vertex order, and verify the polygon's closure and coplanarity; Step S802: Calculate the actual area of ​​the defect in the planar polygon according to the following formula. :

[0015] in, Let be the position vector of the i-th 3D vertex, in meters. That is, the beginning and end vertices are closed. Let be the unit normal vector of the target plane, and be a dimensionless vector. The total number of boundary vertices is a positive integer. The actual area affected by the disease is expressed in square meters. Step S803: Accumulate the Euclidean distances between adjacent vertices to obtain the perimeter of the diseased area, in meters; Step S804: Verify that the area is a finite positive value and the geometric parameters are valid. Output the actual area and perimeter parameters of the disease. If the parameters are invalid, return an invalid state and reject the output area result.

[0016] This invention also provides a system for calculating the area of ​​building envelope defects, comprising: Input preprocessing module: used to obtain the two-dimensional closed-lined boundary of the disease to be tested, image imaging parameters and building triangular mesh model under unified spatial reference. After coordinate consistency verification and spatial ray mapping processing, it outputs the normalized line-of-sight boundary and spatial ray calculation relationship. Adaptive sampling module: used to perform internal pixel sampling based on the relationship between the standardized annotation boundary and the spatial ray calculation using an adaptive graded sampling mechanism, and output the set of sampled pixels inside the annotation area; Ray intersection module: used to perform nearest positive intersection processing between spatial rays and triangular meshes based on the sampled pixel set, and output a set of effective intersection points carrying three-dimensional coordinates, viewing axis depth and triangular face direction; Depth filtering module: used to perform depth filtering based on the set of valid intersection points using the observation axis depth coherent grouping mechanism, and output the set of intersection points of the nearest depth group with the smallest average depth; Component splitting module: used to perform component splitting based on the nearest depth group intersection set using a multi-constraint connectivity analysis mechanism, and output multiple unconnected real connected components; Plane calculation module: Used to perform target plane parameter calculation based on each real connected component using a position-direction joint gating mechanism, and output the target plane with determined position and direction parameters; Boundary reprojection module: used to perform spatial ray reprojection intersection on each vertex of the original labeled boundary based on the target plane, and output a 3D boundary polygon that preserves the vertex order; Geometric calculation module: used to perform planar geometric calculations based on the three-dimensional boundary polygon, and output the actual area and perimeter parameters of the defect.

[0017] The present invention also provides a computer program product, the computer program product including a calculation program for the area of ​​defects in the building envelope, the calculation program for the area of ​​defects in the building envelope implementing the above method when executed by a processor.

[0018] The beneficial effects of this invention are as follows: This invention generates dense sampling points and obtains the nearest valid intersection point within the labeled area through an adaptive graded sampling and nearest forward intersection mechanism, avoiding calculation failures caused by a single boundary ray not being hit. It also improves calculation efficiency through incremental grade reuse, providing sufficient and effective data support for subsequent planar solutions.

[0019] This invention filters out the effective intersection points of the nearest visible surface by observing the coherent grouping of axis depth and the splitting of multi-constrained connected components, and splits out independent real connected components. This isolates local mesh fragments, occluded surfaces and gap interference from the source, ensuring the purity of the plane fitting data source.

[0020] This invention decouples the determination of the position and direction of the target plane through a position-direction joint gating mechanism: in normal scenarios, the nearest component provides both position and direction; when there are local fragments and the macro components meet strict conditions, the nearest component ensures the accuracy of the position, and the macro component covering the center ensures the rationality of the direction, which significantly reduces the interference of local fragments on the plane direction and improves the area calculation accuracy in coarse mesh scenarios.

[0021] This invention restores the 3D boundary based on the target plane obtained by robust solution through the reprojection mechanism of the original labeled boundary vertices. It completely preserves the boundary semantics and vertex order of the original label, and does not replace the labeling results with the sampling point contours or triangular face boundaries, thus ensuring the consistency between the area calculation results and the meaning of the manual label.

[0022] This invention employs a rigorous validity verification and invalid return mechanism to reject output results when there are insufficient valid points, invalid planes, or abnormal boundaries, thereby avoiding the generation of false measurement data and ensuring the reliability and seriousness of measurement results, which meets the accuracy requirements of engineering testing. Attached Figure Description

[0023] Figure 1 This is a flowchart illustrating the first embodiment of a method for calculating the area of ​​defects in the building envelope according to the present invention.

[0024] Figure 2 This is a schematic diagram illustrating the relationship between input data, coordinate consistency verification, and spatial ray mapping in one embodiment of the present invention.

[0025] Figure 3 This is a schematic diagram of adaptive graded sampling and ray result reuse during grade upgrade in one embodiment of the present invention.

[0026] Figure 4 This is a schematic diagram illustrating the nearest positive intersection of a sampled pixel ray and a triangular mesh in one embodiment of the present invention.

[0027] Figure 5 This is a schematic diagram illustrating the process from region sampling, nearest forward intersection to nearest depth group filtering in one embodiment of the present invention.

[0028] Figure 6 This is a schematic diagram of the actual connected components in the nearest depth group and their positions and orientations in one embodiment of the present invention.

[0029] Figure 7 This is a schematic diagram of the splitting of a real connected component and the position-direction joint gating conditions in one embodiment of the present invention.

[0030] Figure 8 This is a schematic diagram illustrating the intersection of the original labeled boundary vertex ray and the target plane to recover the three-dimensional boundary in one embodiment of the present invention.

[0031] Figure 9 This is a schematic diagram illustrating the calculation of the actual area and perimeter of a disease based on ordered three-dimensional boundary vertices in one embodiment of the present invention. Detailed Implementation

[0032] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0033] Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0034] Example 1: As Figure 1 The diagram shown is a flowchart illustrating a first embodiment of a method for calculating the area of ​​defects in the building envelope according to the present invention.

[0035] In the first embodiment, the method for calculating the area of ​​building envelope defects includes: Step S10: Obtain the two-dimensional closed-lined boundary of the defect to be tested, the image imaging parameters, and the building triangular mesh model under a unified spatial reference. After coordinate consistency verification and spatial ray mapping, output the standardized line drawing boundary and spatial ray calculation relationship.

[0036] This step first acquires input data, including manually annotated 2D closed boundaries of defects in the inspection images, ensuring at least three distinct vertices and preserving their original order; camera intrinsic parameters of the images, including equivalent focal length and principal point coordinates; camera extrinsic parameters, including camera spatial position and orientation; and a triangular mesh model of the building envelope under the same spatial reference as the images. Then, a consistency check is performed: verifying the validity of the annotated vertices, the integrity of the camera parameters, and the spatial reference consistency between the mesh coordinates and camera coordinates. After passing the check, a mapping relationship from pixel coordinates to spatial rays is established, providing a foundation for subsequent intersection calculations. Finally, the normalized annotated boundaries and the ray calculation relationship under a unified spatial reference are output and passed to step S20 for region sampling.

[0037] The core of this step is to unify and validate the coordinates of multi-source data, thereby avoiding calculation errors caused by coordinate misalignment and missing parameters from the source, and ensuring the consistency of the baseline for all subsequent spatial calculations.

[0038] like Figure 2 As shown, the input elements for this step include image width and height, camera intrinsic parameters, camera position and pose, building triangular mesh model, and two-dimensional closed annotation boundary. After unified spatial reference transformation and coordinate availability verification, a mapping relationship between sampled pixels and spatial rays is established. The verification rules include that the annotation contains at least three different vertices, the camera parameters are valid, and the model coordinates are consistent with the camera coordinates, to ensure the consistency of the benchmark for subsequent spatial calculations.

[0039] Step S20: Based on the relationship between the standardized annotation boundary and the spatial ray calculation, an adaptive graded sampling mechanism is used to perform internal pixel sampling, and the set of sampled pixels inside the annotation area is output.

[0040] After receiving the normalized labeled boundary, this step first removes adjacent duplicate vertices and calculates the bounding box of the boundary pixels. Three increasing target sampling scales (200, 400, and 600) are set, with the initial sampling scale selected based on the pixel area of ​​the labeled region: 200 for small areas, 400 for medium areas, and 600 for large areas. Sampling mother points are generated using an interlaced mesh method, removing pixels outside the labeled boundary and retaining internal sampling points, while also retaining all original labeled vertices. When subsequent calculations encounter issues such as low hit rate, severe depth mixing, or component instability, the sampling scale is automatically increased, and previously calculated ray results are directly reused, only supplementing the calculation of newly added pixels. Finally, the set of sampled pixels within the labeled region is output and passed to step S30 for ray intersection.

[0041] By introducing adaptive tiered sampling, the computational efficiency of small labels is guaranteed, and the reliability of results can be improved by increasing the tier in complex scenarios. The incremental reuse mechanism also avoids repeated calculations, thus balancing accuracy and efficiency.

[0042] like Figure 3 As shown, the same disease-marked area corresponds to three sampling levels: 200, 400, and 600. The sparse level retains one staggered phase of the parent grid, the medium-dense level retains two staggered phases, and the high-dense level retains all parent grid points and then removes pixels outside the boundary. The level number is the target sampling scale, and the actual number of points may vary slightly due to the polygon shape, boundary vertices, and grid rounding. When upgrading the level, the calculated ray intersection results are reused, and calculations are only performed on newly added points, balancing accuracy and efficiency.

[0043] For example, when marking a medium-sized area of ​​exterior wall peeling damage, the initial sampling level of 400 was selected, generating 387 valid internal sampling points; subsequent calculations found that the component stability was insufficient, so the level was automatically increased to 600, reusing the calculation results of the existing 387 points, and adding 212 sampling points to supplement the calculation.

[0044] Step S30: Perform the nearest positive intersection processing of the spatial ray and the triangular mesh based on the sampled pixel set, and output the set of effective intersection points carrying three-dimensional coordinates, viewing axis depth and triangular face direction.

[0045] After receiving the sampled pixel set, this step performs spatial ray generation and triangular mesh intersection calculation for each sampled pixel. First, the pixel coordinates are converted to the viewing direction in the camera coordinate system based on the camera intrinsic parameters. Then, the camera pose rotation matrix is ​​used to transform it to the world coordinate system direction. A spatial ray is generated starting from the camera position, extending only in front of the camera. For each ray, all positive intersection results with the triangular mesh are calculated and sorted from closest to farthest from the camera. Only the closest valid intersection point is retained, and the occluded surfaces behind are masked. For each valid intersection point, its 3D coordinates, corresponding pixel coordinates, depth value along the viewing axis, and the normal vector of the triangular face to which it belongs are recorded. Rays that do not hit the mesh are only marked as missing; no virtual intersection points are generated, and adjacent triangular faces are not used for replacement. Finally, the attribute information of all valid intersection points is summarized, and the set of valid intersection points is output and passed to step S40 for depth filtering.

[0046] By using the nearest forward intersection mechanism, it is ensured that each sampling point corresponds to the most visible front surface, eliminating interference from obstructions and back structures, and restoring the true visible building surface morphology; at the same time, the rule of not supplementing virtual points also avoids errors introduced by humans.

[0047] like Figure 4 As shown, each sampled pixel in the pixel domain corresponds to a spatial ray originating from the camera position. There may be multiple positive intersection candidates between the ray and the triangular mesh. After sorting the ray parameters t from smallest to largest, only the effective intersection point closest to the camera is retained, and all candidate points further away are discarded to avoid interference from the occluding surface behind. Rays that do not hit the triangular mesh only record the missing state, do not generate virtual intersection points, and are not replaced by adjacent triangular faces to ensure the authenticity of the data.

[0048] Step S40: Based on the set of valid intersection points, perform depth filtering using the observation axis depth coherent grouping mechanism, and output the set of intersection points of the nearest depth group with the smallest average depth.

[0049] After receiving the set of valid intersection points, this step calculates the axial depth value of each valid intersection point along the viewing axis, using the camera's observation axis as the depth direction. A depth neighborhood threshold of 0.5 meters is set, and the minimum number of samples in each group is the greater of 5 and 5% of the total number of valid intersection points. All valid intersection points are coherently grouped according to their depth values: consecutive samples with depth values ​​falling within the same neighborhood are grouped into the same depth group. After grouping, valid depth groups that meet the minimum sample size requirement are selected, and the group with the smallest average depth is chosen as the nearest depth group, corresponding to the visible surface closest to the camera; intersection points at greater depths are all discarded and do not participate in subsequent plane construction. Finally, the nearest depth group intersection point set is output and passed to step S50 for connected component splitting.

[0050] Depth coherent grouping isolates structures at different levels from the depth dimension, retaining only the visible surface at the foreground. This further eliminates interference from occlusions and deep structures, ensuring that subsequent planar fitting is based on valid data from the same depth level.

[0051] like Figure 5 As shown, a complete progressive filtering chain is formed from adaptive sampling of the labeled area, spatial ray generation, nearest positive intersection to depth grouping and filtering; S2 completes pixel sampling within the area, S3 obtains all nearest positive intersection points, and S4 retains only the nearest depth group after grouping by the observation axis depth; points that do not hit the ray, intersections of more distant depth groups, and candidate points that cannot form a valid depth group are not included in the subsequent target plane construction stage, thus isolating interference from the data source.

[0052] Step S50: Based on the nearest depth group intersection set, perform component splitting using a multi-constraint connectivity analysis mechanism to output multiple truly connected components that are not connected to each other.

[0053] After receiving the nearest depth group intersection set, this step establishes adjacency relationships between sampling points in the pixel domain, using adjacent or nearest neighbor sampling grids as candidate connection edges. For each pair of candidate adjacent nodes, two constraints are simultaneously checked: first, local depth continuity, where the depth difference between the two points is less than a depth threshold; second, triangular face orientation compatibility, where the angle between the normal vectors of the triangular faces to which the two points belong is less than an angle threshold. When both constraints are satisfied, the two points are allowed to be connected. The entire component construction only uses the actually hit valid sampling points; missed points and rejected points do not participate in the connection, nor are gaps filled or bridged. Finally, multiple independent real connected components are obtained. Each component records its included points, pixel coverage, representative depth value, fitted plane normal vector, and other attributes. All real connected components are output and passed to step S60 for target plane calculation.

[0054] Multi-constraint connected component decomposition separates local fragments and isolated patches within the same depth level into independent components, avoiding the bias of the overall direction caused by scattered fragments participating in plane fitting, and providing a foundation for subsequent decoupling optimization of position and direction.

[0055] Step S60: Based on each real connected component, the target plane parameter calculation is performed using a position-direction joint gating mechanism, and the target plane with determined position and direction parameters is output.

[0056] After receiving all real connected components, this step first selects the component closest to the camera as the nearest measurement component. The spatial position parameters, such as the projected median value of the center of the point set, are then calculated from the point set of this component to ensure that the position of the target plane fits the real surface at the foreground.

[0057] When only one component exists, the target plane is constructed directly from the position and orientation parameters provided by that component. When multiple components exist, four joint gating checks are initiated: The first is coverage ratio check, which calculates the ratio of the number of points of the most recently measured component to the total number of valid points in the most recently depth group; if it is less than 50%, it is considered insufficient coverage. The second is scale ratio check, which finds the larger component that covers the center of the annotation and calculates the ratio of its number of points to the number of points of the nearest component; if it is not less than 1.50, it is considered to have a scale advantage. The third is center attribution check, which requires that the nearest valid sampling point at the center of the annotation must belong to the larger component to ensure that the larger component covers the main area of ​​the annotation. The fourth is orientation difference check, which calculates the angle between the orientations of the fitted planes of the two components. :

[0058] in, Let be the unit normal vector of the fitted plane of the most recently measured component, and be a dimensionless vector. The unit normal vector of the plane fitting the larger component is a dimensionless vector. The angle between the directions of the two planes is defined as [0°, 90°]. An angle greater than 20 degrees is considered to indicate a significant difference in direction.

[0059] When all four conditions are met, a decoupling scheme is adopted: the nearest measuring component provides the planar position parameters, and the larger component covering the center provides the planar orientation parameters, jointly constructing the target plane. If any one condition is not met, the nearest measuring component still provides both position and orientation parameters. Finally, the target plane with determined position and orientation is output and passed to step S70 for boundary reprojection.

[0060] The joint gating mechanism achieves robust decoupling of position and orientation: it ensures the accuracy of planar position through the nearest component, and corrects orientation with the help of macro components under strict conditions, avoiding orientation interference from local fragments, thus improving the accuracy of planar solution in coarse mesh scenarios from a mechanism perspective.

[0061] like Figure 6 As shown, this is the distribution of real connected components within the nearest depth group in the test cases. The red closed box represents the boundary of the disease label; the dark blue dots are the measurement components closest to the camera, used to determine the position of the target plane; the brown dots are the larger components covering the label center, used only to determine the direction of the target plane when joint gating is established; the light blue dots are other real connected components, which do not participate in the calculation of the position or direction parameters of the target plane.

[0062] like Figure 7 As shown, the real connected components are obtained by decomposing them through triple constraints of pixel adjacency, local depth continuity, and directional continuity. They are constructed only by actual hit points, without connecting across gaps or filling virtual points. The joint gating includes four parallel conditions: the coverage ratio of the nearest component is less than 50%, the size ratio of the larger component to the nearest component is not less than 1.50, the annotation center is assigned to the larger component, and the directional difference between the two components is greater than 20 degrees. When all four conditions are met, position and direction decoupling is enabled, with the nearest component determining the position and the larger component determining the direction. If any condition is not met, the nearest component still determines both the position and direction.

[0063] For example, in a certain test case, the nearest component has 198 points, accounting for 34.02% of the nearest depth group. The larger component covering the labeled center has 336 points, with a size ratio of 1.697. The labeled center belongs to the larger component, and the angle between the two components is 37.73 degrees. All four conditions are met. The relative deviation of the area calculated using the decoupling scheme is 1.44%, while the relative deviation using only the nearest component is 50.62%, demonstrating a significant improvement in accuracy.

[0064] Step S70: Perform spatial ray reprojection and intersection on each vertex of the original labeled boundary based on the target plane, and output a three-dimensional boundary polygon that preserves the vertex order.

[0065] After receiving the target plane, this step regenerates the corresponding spatial ray for each vertex of the original 2D labeled boundary, calculates the intersection of the ray with the target plane, and obtains the 3D coordinates of that vertex. All boundary vertices are arranged in the original labeled order to form a closed 3D boundary polygon. This process completely preserves the vertex order and boundary shape of the original label, and does not replace the original label with the outer contour or triangular face boundary of the sampled points, ensuring that the boundary semantics of the area calculation are completely consistent with the manual label. Even if some boundary vertices did not originally hit the triangular mesh, as long as the target plane is robustly constructed from valid points within the region, its 3D coordinates can still be recovered through plane intersection. Finally, an ordered 3D boundary polygon is output and passed to step S80 for area calculation.

[0066] The original boundary reprojection mechanism decouples the planar solution from the boundary restoration, uses dense sampling of regions to ensure the reliability of the planar solution, and uses the planar solution to infer the boundary vertices. This not only solves the problem of single boundary rays being prone to failure, but also completely preserves the semantic boundaries of the original annotations.

[0067] like Figure 8 As shown, due to the limited accuracy of triangular mesh faces and the uncertain deviation of camera pose, a single ray emanating from the original labeled boundary vertex may not directly intersect with the triangular mesh. This method does not use fixed distance, adjacent face replacement, or virtual point filling to complete the vertex. Instead, it obtains a large number of effective intersection points through dense sampling within the region. After filtering by the nearest depth group and the real connected components, a robust target plane is constructed. Then, the original boundary vertex ray intersects with the target plane to restore the ordered 3D boundary, thereby solving the single ray failure problem without changing the label semantics.

[0068] Step S80: Perform planar geometric calculations based on the three-dimensional boundary polygon, and output the actual area and perimeter parameters of the defect.

[0069] After receiving the 3D boundary polygon, this step first verifies the polygon's closure, vertex coplanarity, and vertex validity. If the verification passes, the actual area of ​​the defect in the planar polygon is calculated using the vector cross product method. :

[0070] in, Let be the position vector of the i-th 3D vertex, in meters. That is, the beginning and end vertices are closed. Let be the unit normal vector of the target plane, and be a dimensionless vector. The total number of boundary vertices is a positive integer. This represents the actual area of ​​the disease, in square meters. The perimeter of the diseased area is calculated by summing the Euclidean distances between adjacent vertices.

[0071] If any anomalies occur, such as fewer than 3 valid hit points, the target plane cannot be fitted, the boundary ray is approximately parallel to the plane, intersection points are missing, or the area is not a finite positive value, the system returns an invalid status, refuses to output the area result, and does not generate false measurement data. After successful verification, the actual area and perimeter parameters of the defect are output, completing a full defect area calculation process.

[0072] A rigorous validity check and invalid return mechanism ensures the reliability of the output results, avoids outputting erroneous data in invalid scenarios, and meets the rigorous requirements of engineering testing.

[0073] like Figure 9 As shown, each of the original labeled boundary vertices in the image pixel plane corresponds to a spatial ray originating from the camera position; all rays intersect with a unified target plane to obtain three-dimensional boundary vertices, and the original vertex order is strictly maintained, without replacing the labeled boundary with the sampled point contour; finally, the area and perimeter are calculated based on the ordered three-dimensional vertices and the target plane normal vector. If there are abnormalities such as missing intersections or non-regular area, the invalid state is returned.

[0074] Example 2: Furthermore, the present invention provides a system for calculating the area of ​​building envelope defects, employing a method for calculating the area of ​​building envelope defects described in the above embodiments. This system addresses the technical problems in the prior art where, when building triangular meshes exhibit local fragmentation, depth mixing, occlusion, or geometric roughness, the two-dimensional defect annotation boundaries are difficult to stably recover as three-dimensional true boundaries, and the area is easily affected by erroneous surface hits. The beneficial effects of the system for calculating the area of ​​building envelope defects provided by the present invention are the same as those of the method for calculating the area of ​​building envelope defects provided in the above embodiments, and other technical features of the system for calculating the area of ​​building envelope defects are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0075] Example 3: This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method for calculating the area of ​​building envelope defects as described above. The computer program product provided by this invention can solve the technical problems in the prior art where, when there are local fragments, depth mixing, occlusion, or geometric roughness in the building triangular mesh, the two-dimensional defect annotation boundary is difficult to stably recover as a three-dimensional true boundary, and the area is easily affected by erroneous surface hits. Compared with the prior art, the beneficial effects of the computer program product provided by this invention are the same as the beneficial effects of the method for calculating the area of ​​building envelope defects provided in the above embodiments, and will not be repeated here.

[0076] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a read-only memory. When the computer program is executed by a processing device, it performs the functions defined in the methods of the embodiments disclosed in this invention.

[0077] It should be understood that the various parts disclosed in this invention can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.

[0078] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the present invention and its equivalents, the present invention also intends to include these modifications and variations.

Claims

1. A method for calculating the area of ​​defects in the building's exterior envelope, characterized in that, The methods include: Step S10: Obtain the two-dimensional closed-lined boundary of the disease to be tested, the image imaging parameters, and the building triangular mesh model under a unified spatial reference. After coordinate consistency verification and spatial ray mapping, output the normalized line-of-sight boundary and spatial ray calculation relationship. Step S20: Based on the relationship between the standardized annotation boundary and the spatial ray calculation, an adaptive graded sampling mechanism is used to perform internal pixel sampling, and the set of sampled pixels inside the annotation area is output; Step S30: Based on the sampled pixel set, perform the nearest positive intersection processing of the spatial ray and the triangular mesh, and output the set of effective intersection points carrying three-dimensional coordinates, viewing axis depth and triangular face direction; Step S40: Based on the set of valid intersection points, perform depth filtering using the observation axis depth coherent grouping mechanism, and output the set of intersection points of the nearest depth group with the smallest average depth; Step S50: Based on the nearest depth group intersection set, a multi-constraint connectivity analysis mechanism is used to perform component splitting, and output multiple unconnected real connected components; Step S60: Based on each real connected component, the target plane parameter is calculated using a position-direction joint gating mechanism, and the target plane with determined position and direction parameters is output. Step S70: Perform spatial ray reprojection intersection on each vertex of the original labeled boundary based on the target plane, and output a three-dimensional boundary polygon that preserves the vertex order; Step S80: Perform planar geometric calculations based on the three-dimensional boundary polygon, and output the actual area and perimeter parameters of the defect.

2. The method for calculating the area of ​​defects in the building envelope according to claim 1, characterized in that, Step S20, which involves performing internal pixel sampling using an adaptive graded sampling mechanism based on the relationship between the standardized annotation boundary and the spatial ray calculation, and outputting the set of sampled pixels within the annotation region, specifically includes: Step S201: Remove adjacent duplicate vertices from the normalized annotation boundary, determine the pixel enclosing range, and preserve the original vertex order; Step S202: Set multiple incremental target sampling scales, determine the initial sampling level based on the labeled pixel area, generate sampling points in an interlaced grid manner, and retain only pixels located inside the closed boundary; Step S203: When the hit missing ratio, depth mixing ratio or component stability does not meet the preset requirements, the sampling level is increased. When the level is increased, the calculated ray intersection results are reused, and subsequent calculations are only performed on newly added pixels. Step S204: Summarize all valid sampled pixels, arrange them by pixel coordinates, and output the sampled pixel set.

3. The method for calculating the area of ​​defects in the building envelope according to claim 1, characterized in that, Step S30, which involves performing the nearest positive intersection processing between the spatial ray and the triangular mesh based on the sampled pixel set, and outputting a set of valid intersection points carrying three-dimensional coordinates, viewing axis depth, and triangular face direction, specifically includes: Step S301: Based on the camera intrinsic parameters, convert the sampled pixels into the camera coordinate system viewing direction, and obtain the spatial ray in the world coordinate system through camera pose transformation. The starting point of the ray is the camera position, and the direction points in front of the camera. Step S302: Calculate all positive intersection candidates between a single spatial ray and the triangular mesh, sort them by ray parameters from smallest to largest, and retain only the valid intersection point closest to the camera; Step S303: Record the 3D coordinates, corresponding pixel coordinates, depth value along the observation axis and normal vector of the corresponding triangle for each valid intersection point. For missed rays, only the missed state is recorded and no virtual intersection points are generated. Step S304: Summarize the attribute information of all valid intersection points and output the set of valid intersection points.

4. The method for calculating the area of ​​defects in the building envelope according to claim 1, characterized in that, Step S40, which involves performing depth filtering based on the set of valid intersection points using an observation axis depth coherent grouping mechanism and outputting the nearest depth group intersection point set with the smallest average depth, specifically includes: Step S401: Using the camera's observation axis as the depth direction, calculate the axial depth value of each valid intersection point; Step S402: Set the depth neighborhood threshold and the minimum number of samples in the smallest group, and coherently group the effective intersection points according to the depth value to form multiple depth groups; Step S403: Select the effective depth group with the smallest average depth as the nearest depth group, and remove intersections and invalid groups with more distant depths; Step S404: Output the set of intersection points of the nearest depth group, which consists of all intersection points within the nearest depth group.

5. The method for calculating the area of ​​defects in the building envelope according to claim 1, characterized in that, Step S50, which involves performing component decomposition based on the nearest depth group intersection set using a multi-constraint connectivity analysis mechanism and outputting multiple truly connected but unconnected components, specifically includes: Step S501: Establish pixel adjacency relationships using the sampled pixels within the nearest depth group as nodes; Step S502: Simultaneously verify the local depth continuity and triangular face orientation compatibility of adjacent nodes. If both conditions are met, connectivity expansion is allowed. Step S503: Connectivity components are constructed only from actual valid hit points. Missed points, depth-removed points, and gap locations are not involved in the connection, and no point filling or gap bridging is performed. Step S504: Split to obtain multiple independent real connected components. Record the number of points, coverage, representative depth and fitting plane direction of each component, and output all real connected components.

6. The method for calculating the area of ​​defects in the building envelope according to claim 1, characterized in that, In step S60, the step of performing target plane parameter calculation based on the position-direction joint gating mechanism of each real connected component and outputting the target plane with determined position and direction parameters specifically includes: Step S601: Select the nearest real connected component to the camera as the nearest measurement component, and calculate the position parameters of the target plane from its point set statistically. Step S602: When there are multiple real connected components, simultaneously verify four joint gating conditions: the coverage ratio of the most recently measured component is lower than the first threshold, the size ratio of the larger component covering the label center to the most recently measured component is not less than the second threshold, the label center belongs to the larger component, and the difference in the fitting direction of the two components is greater than the third threshold. Sort the multiple real connected components by size and set the top 50% as the larger components. Step S603: Calculate the angle between the plane direction of the most recently measured component and the larger component according to the following formula. : in, Let be the unit normal vector of the fitted plane of the most recently measured component, and be a dimensionless vector. The unit normal vector of the plane fitting the larger component is a dimensionless vector. The angle between the directions of the two planes, with a value range of [0°, 90°]; Step S604: When all four conditions are met, the target plane is constructed by providing position parameters from the nearest measuring component and orientation parameters from the larger component. If any condition is not met, the target plane is constructed by providing both position and orientation parameters from the nearest measuring component. Step S605: Output the target plane containing position and orientation parameters.

7. The method for calculating the area of ​​defects in the building envelope according to claim 1, characterized in that, Step S80, which involves performing planar geometric calculations based on the three-dimensional boundary polygon and outputting the actual area and perimeter parameters of the defect, specifically includes: Step S801: Arrange the vertices of the 3D boundary polygon in the original vertex order, and verify the polygon's closure and coplanarity; Step S802: Calculate the actual area of ​​the defect in the planar polygon according to the following formula. : in, Let i be the position vector of the i-th 3D vertex. That is, the beginning and end vertices are closed. Let be the unit normal vector of the target plane, and be a dimensionless vector. The total number of boundary vertices is a positive integer. The actual area affected by the disease is expressed in square meters. Step S803: Accumulate the Euclidean distances between adjacent vertices to obtain the perimeter of the diseased area, in meters; Step S804: Verify that the area is a finite positive value and the geometric parameters are valid. Output the actual area and perimeter parameters of the disease. If the parameters are invalid, return an invalid state and reject the output area result.

8. A system for calculating the area of ​​defects in the building envelope, applied to the method for calculating the area of ​​defects in the building envelope as described in any one of claims 1 to 7, characterized in that, include: Input preprocessing module: used to obtain the two-dimensional closed-lined boundary of the disease to be tested, image imaging parameters and building triangular mesh model under unified spatial reference. After coordinate consistency verification and spatial ray mapping processing, it outputs the normalized line-of-sight boundary and spatial ray calculation relationship. Adaptive sampling module: used to perform internal pixel sampling based on the relationship between the standardized annotation boundary and the spatial ray calculation using an adaptive graded sampling mechanism, and output the set of sampled pixels inside the annotation area; Ray intersection module: used to perform nearest positive intersection processing between spatial rays and triangular meshes based on the sampled pixel set, and output a set of effective intersection points carrying three-dimensional coordinates, viewing axis depth and triangular face direction; Depth filtering module: used to perform depth filtering based on the set of valid intersection points using the observation axis depth coherent grouping mechanism, and output the set of intersection points of the nearest depth group with the smallest average depth; Component splitting module: used to perform component splitting based on the nearest depth group intersection set using a multi-constraint connectivity analysis mechanism, and output multiple unconnected real connected components; Plane calculation module: Used to perform target plane parameter calculation based on each real connected component using a position-direction joint gating mechanism, and output the target plane with determined position and direction parameters; Boundary reprojection module: used to perform spatial ray reprojection intersection on each vertex of the original labeled boundary based on the target plane, and output a 3D boundary polygon that preserves the vertex order; Geometric calculation module: used to perform planar geometric calculations based on the three-dimensional boundary polygon, and output the actual area and perimeter parameters of the defect.

9. A computer program product, characterized in that, The computer program product includes a program for calculating the area of ​​defects in the building envelope, which, when executed by a processor, implements a method for calculating the area of ​​defects in the building envelope as described in any one of claims 1 to 7.