Part size intelligent measurement method based on natural language understanding and deep contour representation
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAZHONG UNIV OF SCI & TECH
- Filing Date
- 2026-04-21
- Publication Date
- 2026-08-04
AI Technical Summary
然而,现有工作多聚焦于物体识别或体积估算等粗粒度任务,在面向工业零件的高精度几何尺寸测量方面,如何将自然语言指令转化为可执行的测量计划、如何根据语义描述精准定位目标实例、如何从离散像素中重构连续轮廓以支持亚像素级几何参数提取,仍是亟待突破的技术难题
[0028] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
Smart Images

Figure CN122510168A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to, but is not limited to, the field of industrial vision measurement technology, and particularly relates to an intelligent measurement method and system for part dimensions based on natural language understanding and depth contour representation. Background Technology
[0002] Dimensional measurement of parts is a fundamental aspect of intelligent manufacturing and precision inspection. As modern industry imposes increasingly stringent threshold requirements on dimensional tolerances and geometric tolerances for parts, achieving efficient, accurate, and intelligent dimensional measurement has become a key challenge hindering improvements in manufacturing quality. Traditional dimensional measurement methods are mainly divided into two categories: contact and non-contact. Contact measurement relies on manual point-by-point measurements using tools such as micrometers and calipers, which is not only labor-intensive and inefficient, but also significantly affected by the operator's subjective factors, making it difficult to meet the demands of large-scale automated production. Non-contact measurement, represented by machine vision technology, automates the detection of parameters such as workpiece length, diameter, angle, and curvature through image acquisition, image processing, feature extraction, and dimensional calculation. Compared to traditional manual measurement, machine vision inspection offers significant advantages in terms of non-contact nature, real-time performance, and flexibility, effectively addressing the prominent problems of low accuracy and slow speed in traditional inspection methods.
[0003] However, existing machine vision-based part dimension measurement technologies still face numerous bottlenecks. At the system level, current research generally lacks the development of general geometric measurement systems, image processing systems exhibit significant time lags, and measurement accuracy is insufficient to meet the demands of high-precision manufacturing scenarios. At the technical level, traditional visual measurement methods typically rely on prior conditions such as camera calibration, known focal lengths, or reference scales. If on-site conditions do not meet these constraints, the measurement system struggles to function properly. In recent years, the introduction of deep learning technology has improved the automation level of visual measurement to some extent. For example, YOLO-based object detection and instance segmentation methods can extract the edge contours of parts and combine camera calibration and sub-pixel optimization to achieve dimension measurement; the Segment Anything Model (SAM)-based measurement framework has shown potential in estimating the dimensions of circular cross-section objects. However, most of these methods still remain in a batch processing mode of "fixed instructions—fixed outputs," where the measurement target is determined by a preset algorithm, lacking the ability to understand the diverse measurement intentions of users. In real-world industrial scenarios, quality inspectors often need to make different dimensional measurement requests for different parts of the same image—for example, "measure the groove width on the upper surface" and "measure the aperture on the lower surface"—and existing methods cannot effectively support this type of target recognition and dimensional measurement described in natural language.
[0004] Meanwhile, the cross-integration of natural language processing and computer vision is becoming a research hotspot in the field of artificial intelligence. Visual language models can jointly reason with language instructions and visual information, and have shown application potential in tasks such as object attribute detection and volume perception. However, existing work mostly focuses on coarse-grained tasks such as object recognition or volume estimation. In the high-precision geometric dimension measurement of industrial parts, how to transform natural language instructions into executable measurement plans, how to accurately locate target instances based on semantic descriptions, and how to reconstruct continuous contours from discrete pixels to support sub-pixel-level geometric parameter extraction remain technical challenges that urgently need to be overcome. In addition, deep implicit representation methods (such as DeepSDF) achieve continuous modeling of 3D shapes through signed distance fields, but existing methods are mainly geared towards complete 3D reconstruction scenarios, and their application in the continuous representation and geometric parameter analysis of 2D image contours is still lacking.
[0005] Existing part size measurement technologies still have significant shortcomings in terms of measurement automation, semantic understanding capabilities, and contour representation accuracy. There is an urgent need for an intelligent measurement method that can integrate natural language understanding and deep contour representation to promote the development of industrial vision measurement towards a higher level of automation and intelligence. Summary of the Invention
[0006] To address the problems existing in the prior art, this invention provides a method and system for intelligent measurement of part dimensions based on natural language understanding and deep contour representation.
[0007] This invention is implemented as follows: an intelligent measurement method for part dimensions based on natural language understanding and depth contour representation, characterized in that the intelligent measurement method for part dimensions based on natural language understanding and depth contour representation specifically includes:
[0008] S1: Receive natural language measurement instructions through the measurement semantics compilation module and convert the natural language measurement instructions into a structured measurement plan;
[0009] S2: Based on the structured measurement plan, a text-guided candidate target detection network is used to locate candidate geometric targets in the image to be measured that correspond to the measurement instructions, and a unique target instance is determined through a semantic-geometric consistency screening mechanism;
[0010] S3: Based on the region of interest corresponding to the unique target instance, the target contour is continuously represented by a contour reconstruction network with a continuous signed distance field, and the initial values of the geometric parameters are analyzed by regression through a geometric parameter observation head.
[0011] S4: Based on the contour reconstruction results and initial values of geometric parameters, the pixel domain size is calculated and a measurement report is generated through zero-layer point set extraction and low-step geometric refinement.
[0012] Furthermore, the step of converting natural language measurement instructions into a structured measurement plan further includes:
[0013] The natural language measurement instructions are preprocessed, including sentence segmentation and parallel parsing, alias normalization, unit unification, and pronoun parsing;
[0014] A large language model with efficient parameter fine-tuning is used as the parser. The preprocessed instructions are transformed into a structured measurement plan that conforms to the preset JSON Schema constraints through a constrained decoding strategy. The structured measurement plan includes measurement type, description of the measured target, description of the reference benchmark, physical unit, tolerance range and measurement method.
[0015] The generated structured measurement plan is subjected to consistency verification, and the plan consistency score is calculated. When the consistency score is lower than the preset threshold, the automatic repair mechanism is activated for iterative repair.
[0016] Furthermore, the constrained decoding strategy specifically involves: parsing the target JSON Schema into a hierarchical deterministic finite automaton; calculating the set of legal lexical units based on the currently generated prefix at each step of the large language model's autoregressive generation; and forcibly setting the output probability of illegal lexical units to negative infinity.
[0017] Furthermore, the text-guided candidate target detection network adopts a dual-branch structure combining an image backbone network and a text encoder; it introduces a cross-modal attention mechanism to fuse text feature vectors on multi-scale visual features; it predicts candidate regions through an anchorless detection head; and it adopts a coverage-aware multi-positive sample allocation strategy, where the positive sample set satisfies an intersection-union ratio greater than a first threshold and a semantic similarity greater than a second threshold.
[0018] Furthermore, the semantic-geometric consistency screening mechanism includes: performing instruction constraint pruning on candidate boxes; calculating a weighted comprehensive score of detection confidence, text alignment score, and geometric consistency score; sorting the comprehensive scores in descending order and performing cross-scale redundancy removal, then taking the first candidate as the unique output instance.
[0019] Furthermore, the contour reconstruction network uses UNet as the backbone network and outputs a signed distance field prediction with the same resolution as the input; the signed distance field is defined as the target contour corresponding to the target's internal pixel value being negative, the external pixel value being positive, and the zero level set; a truncation strategy is used to focus the supervision signal on the boundary neighborhood.
[0020] Furthermore, the geometric parameter observation head analyzes the geometric parameters and covariance matrix on the deepest feature map of the UNet encoder through global average pooling and multilayer perceptron regression; a differentiable reparameterization strategy is introduced to ensure geometric feasibility.
[0021] Furthermore, the training loss function of the contour reconstruction network includes distance field reconstruction loss, Eikonal regularization term, geometric consistency coupling loss, narrowband fitting loss, and parameter regression and uncertainty loss.
[0022] Furthermore, the zero-layer band point set extraction and geometric refinement include: sampling and obtaining the boundary point set within the zero-layer band region; calculating the confidence weight based on the gradient magnitude; performing a few-step iterative refinement using the weighted Gauss-Newton method starting from the initial geometric parameter values; and calculating the target size based on the refined parameters, including diameter, center distance, point-to-line distance, included angle, roundness, and straightness.
[0023] Another objective of this invention is to provide an intelligent part dimension measurement system based on natural language understanding and deep contour representation, the system specifically comprising:
[0024] The measurement semantics compilation module is used to receive natural language measurement instructions and convert the natural language measurement instructions into a structured measurement plan;
[0025] The candidate target detection module is used to locate candidate geometric targets corresponding to the measurement command in the image to be tested through a text-guided candidate target detection network, and to determine unique target instances through a semantic-geometric consistency screening mechanism.
[0026] The contour reconstruction module is used to perform continuous representation of the target contour through a contour reconstruction network with a continuous signed distance field, and at the same time, it uses a geometric parameter observation head to regress the initial values of the analytical geometric parameters.
[0027] The size calculation module is used to calculate the pixel domain size and generate a measurement report based on the contour reconstruction results and initial values of geometric parameters, through zero-layer point set extraction and low-step geometric refinement.
[0028] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
[0029] This invention proposes an intelligent part dimension measurement method based on natural language understanding and deep contour representation. Its technical solution is not simply an overlay of existing visual measurement or target detection methods, but rather introduces an integrated closed-loop mechanism at the measurement process level, encompassing semantic-driven, geometric perception, continuous contour modeling, and refined measurement. In existing technologies, traditional dimension measurement typically relies on manually set rules or visual algorithms based on fixed templates, making it difficult to parse and automatically map natural language measurement intentions. Existing text-guided detection or visual language models mostly remain at the level of target recognition or semantic understanding, without delving further into geometric parameter analysis and precision measurement. Therefore, this invention, through a measurement semantic compilation module, transforms natural language instructions into structured measurement plans, and combines semantic-geometric consistency screening to achieve unique determination of target instances, overcoming the problem of the disconnect between semantic understanding and precision measurement. By continuously representing the contour using a continuous signed distance field, and combining it with zero-layer point set extraction and low-step geometric refinement, the measurement is upgraded from discrete pixel estimation to continuous geometric reconstruction, thereby significantly improving measurement accuracy and stability. The aforementioned technical features do not exist in isolation, but rather form a synergistic relationship, producing unexpected technical effects, namely, realizing a high-precision automatic measurement closed-loop process driven by natural language.
[0030] This invention introduces natural language understanding technology, enabling the measurement system to dynamically understand the measurement intent and plan measurement tasks based on the operator's natural language descriptions. Through depth contour representation technology based on a continuous signed distance field, robust contour reconstruction is achieved under conditions of weak edges, occlusion, and noise interference. By jointly predicting analytical geometric parameters and refining with a small number of steps, high-precision dimensional calculations are achieved while preserving true physical boundary features. This invention significantly lowers the operational threshold of industrial vision systems, allowing ordinary technicians to flexibly configure measurement tasks using natural language, and greatly improves the response speed and flexibility of production lines to changing operating conditions.
[0031] (1) The expected benefits and commercial value of the technical solution of this invention after transformation are as follows: This invention can be applied to scenarios such as online measurement of industrial parts, first article inspection, process sampling inspection, and final inspection verification. Compared with traditional solutions that rely on fixed rule configuration or manual switching of measurement processes, this invention allows operators to directly issue measurement tasks in natural language, which can reduce the time for measurement process reconstruction and manual configuration costs, reduce the dependence on the experience of skilled quality inspectors, and improve the task switching efficiency in flexible production scenarios with multiple varieties and small batches. At the same time, this invention integrates target positioning, contour reconstruction, size calculation, and report generation into the same process, which is convenient for docking with existing visual inspection production lines, MES systems, or quality traceability systems, and has strong industrialization value.
[0032] (2) The technical solution of this invention overcomes technical bias: Traditional industrial dimensional measurement generally believes that high-precision measurement tasks require structured input driven by fixed templates, fixed rules, or explicit manual configuration. However, natural language expression, due to its ambiguity, openness, and non-standardity, is not suitable as a direct entry point for high-precision measurement tasks. At the same time, although deep learning methods are suitable for object detection or contour segmentation, they are generally considered difficult to directly support interpretable and verifiable analytical geometric dimensional solutions. This invention, by combining measurement semantic compilation, semantic-geometric consistency screening, continuous signed distance field contour representation, and few-step analytical geometric refinement, proves that natural language dynamic driving and high-precision geometric measurement can be compatiblely implemented within the same technical framework, thereby overcoming the above-mentioned technical bias. Attached Figure Description
[0033] Figure 1 This is a flowchart of the intelligent part size measurement method based on natural language understanding and depth contour representation provided in the embodiments of the present invention;
[0034] Figure 2 This is a flowchart of the measurement semantics compilation module IMC provided in an embodiment of the present invention;
[0035] Figure 3 This is a framework diagram of the text-guided candidate object detection network ROLV provided in an embodiment of the present invention;
[0036] Figure 4 This is a schematic diagram of the cross-modal fusion detection framework provided in an embodiment of the present invention;
[0037] Figure 5 This is an overall framework diagram of the contour reconstruction network and analytical measurement refinement module provided in the embodiments of the present invention;
[0038] Figure 6 This is a structural diagram of the UNet backbone and SDF output header provided in an embodiment of the present invention;
[0039] Figure 7 This is a block diagram of an intelligent part size measurement system based on natural language understanding and depth contour representation provided in an embodiment of the present invention. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0041] like Figure 1 As shown in the embodiment of the present invention, the intelligent measurement method for part dimensions based on natural language understanding and deep contour representation specifically includes:
[0042] Step S10: Receive natural language measurement instructions through the measurement semantic compilation module and convert the natural language measurement instructions into a structured measurement plan; the structured measurement plan includes measurement type, description of the target being measured, description of the reference benchmark, physical unit, tolerance range, and measurement method.
[0043] Step S20: Based on the structured measurement plan, a text-guided candidate target detection network is used to locate candidate geometric targets in the image to be measured that correspond to the measurement instructions, and a unique target instance is determined through a semantic-geometric consistency screening mechanism.
[0044] Step S30: Based on the region of interest corresponding to the unique target instance, the target contour is continuously represented by a contour reconstruction network with a continuous signed distance field, and the initial values of the geometric parameters are analyzed by regression through a geometric parameter observation head.
[0045] Step S40: Based on the contour reconstruction results and initial values of geometric parameters, the pixel domain size is calculated and a measurement report is generated through zero-layer point set extraction and low-step geometric refinement.
[0046] Step S10 is the semantic understanding stage of the entire intelligent size measurement method. Through standardized text preprocessing and constrained structured generation logic, unstructured natural language measurement instructions are transformed into executable structured measurement plans, providing complete task description support for subsequent target detection and size calculation. The specific implementation process consists of four parts: text preprocessing, constrained decoding and generation, consistency verification and repair, multi-instruction merging, and object deduplication. Industrial measurement instructions have obvious domain characteristics, typically including measurement type, measured target, reference object, and fine-grained constraints such as orientation, sequence number, and geometric relationships. This step transforms natural language measurement instructions into structured measurement plans, formally defined as a conditional sequence generation task under the constraints of an industrial scenario context. This task aims to construct a mapping function that, given a context including a domain vocabulary, a standard unit set, alias mapping rules, and a JSON Schema constraint set, maps unstructured natural language text sequences into strictly compliant structured plans.
[0047] The step of receiving natural language measurement instructions through the measurement semantic compilation module and converting the natural language measurement instructions into a structured measurement plan further includes:
[0048] Step S11: Perform text preprocessing on the natural language measurement instructions, including sentence segmentation and parallel parsing, alias normalization, unit unification, and referential parsing;
[0049] Step S12: A large language model with domain-adaptive parameters is efficiently fine-tuned, and a measurement knowledge graph is used for synonym mapping and fuzzy disambiguation. A structured measurement plan is generated through a constrained decoding strategy.
[0050] Step S13: Perform consistency verification and repair on the generated structured measurement plan;
[0051] Step S14: Merge multiple measurement commands and remove duplicate objects.
[0052] The text preprocessing in step S11 is the foundation of the entire semantic compilation process. Through multi-level text normalization operations, it eliminates ambiguity and inconsistency in natural language instructions, providing clean and standard input for subsequent structured generation.
[0053] Clause segmentation and parallel structure analysis employs a hierarchical strategy: semicolons first, then periods, and finally commas. Long sentences are first broken down using semicolons as the strongest boundary; then, within each clause, parallel structures are identified sequentially based on periods and commas. When parallel predicates share the same object, if a predicate is omitted in the subsequent component, it is supplemented according to the preceding predicate during analysis.
[0054] The standardization of alternative names unifies common colloquial alternative names and spelling differences into a standardized vocabulary. For example, it unifies "hole," "round hole," and "through hole" into the standard category name "hole," "millimeters" and "mm" into the standard unit "mm," and "degree" and "angle" into the standard "deg."
[0055] Unit standardization involves extracting and converting units to the standard sets mm, deg, and dimensionless, and performing consistency checks with the measurement type: mm is generally used for lengths; deg for angles; and dimensionless for dimensionless measurements. When multiple candidates or conflicting expressions appear, a unique result is determined based on the principle of prioritizing explicit annotations and then the nearest context; if a determination still cannot be made, an ambiguity marker is set.
[0056] The reference parsing process identifies the nearest reachable noun antecedent based on syntactic dependencies and local context. If the coordinate structure results in a non-unique antecedent, the ambiguity marker is also recorded and resolved in the subsequent merging stage.
[0057] The constrained decoding generation in step S12 is the core computational step of semantic compilation. In one embodiment, a pre-trained language model can be used as the semantic parsing base, and the model can be adapted to the industrial measurement instruction parsing task through efficient parameter fine-tuning. In this embodiment, Qwen2.5-1.5B-Instruct is used as the base model, and only the attention layer is introduced with a LoRA adapter for efficient parameter fine-tuning. The LoRA rank... Set to 16, scaling factor Set to 16, dropout to 0.05. During the inference phase, a constrained decoding strategy based on a deterministic finite automaton (DFA) is employed. The target JSON schema is parsed into a hierarchical DFA. At each step of the model's autoregressive generation, the DFA calculates the set of legal terms based on the current generated prefix. Subsequently, at the term level, the model's output Logits are intervened, forcing the probability of illegal terms to negative infinity. This effectively blocks illegal keys and values at the generation source, ensuring that the output results 100% conform to the preset format constraints.
[0058] Step S13, consistency verification and repair, is a crucial step in ensuring plan executability. The plan consistency score is defined as:
[0059]
[0060] Where P is the structured measurement plan to be verified. The normalized count for compatibility violations includes three aspects: consistency of type and unit, matching of metric and task, and legality of value. This is a normalized count of missing key elements, including three categories: missing objects, missing necessary fields, and incomplete selector information. and This is the adjustment coefficient. When Below the threshold When an automatic repair mechanism is activated, the repair follows the principle of minimal intervention and is performed sequentially: first, missing fields that can be uniquely identified by context or task type are completed; second, significant type-unit or metric-task incompatibilities are corrected; and finally, missing object references are restored based on the reference chain or parallel structure. To ensure the traceability of the repair process, audit log fields must be injected into the plan structure after each correction. If the core ambiguity cannot be eliminated, the system will forcibly set the consistency score to 0 and retain the ambiguity marker. The score is recalculated after each repair until... Or reach the maximum number of iterations .
[0061] Step S14, multi-instruction merging and object deduplication, is a necessary step in processing compound instructions. For a text that may contain multiple measurement instructions, first obtain the instruction-level plan set, and then construct object normalization keys based on multi-dimensional semantic features:
[0062]
[0063] Here, the class is mapped to the standard class name in the global part ontology library; the normalized_selector parses unstructured spatial or logical modifiers into standard key-value pairs; and the role identifies the object's identity in the current measurement subtask. When objects in different instructions are detected to have the same normalized key, a merging mechanism is triggered. This mechanism handles mutually exclusive attributes, inconsistent units, missing reference bases, and spatial modifier updates according to predefined conflict resolution rules, structuring the loosely linked original instructions into a compact, unambiguous, and globally consistent measurement execution graph.
[0064] Step S20, the step of locating candidate geometric targets corresponding to the measurement instructions in the image to be measured based on the structured measurement plan using a text-guided candidate target detection network, and determining unique target instances through a semantic-geometric consistency screening mechanism, further includes:
[0065] Step S21: The target description in the structured measurement plan is converted into a text query phrase, and the image and text features are fused through a cross-modal attention mechanism;
[0066] Step S22: Model training is performed using a coverage-aware multi-positive-sample allocation strategy;
[0067] Step S23: Determine a unique target instance through semantic-geometric consistency screening and output an uncertainty signal.
[0068] Step S21 is the feature fusion stage for visual localization. The image branch uses a Swin Transformer-based image backbone network and feature pyramid network to extract feature maps at four scales with spatial strides of 8, 16, 32, and 64 pixels, corresponding to different scales from small holes to the overall contour. Simultaneously, only the targets and reference parts are parsed from the structured measurement plan output in step S10, mapping the selector field of each object to a concise target phrase. Subsequently, the target phrase is input into a BERT-based text encoder to obtain word token sequence representations and an overall semantic vector. At each layer of the feature pyramid, a cross-modal attention mechanism is used to fuse text features into visual features, making the features of that layer more sensitive to the target described by the instruction, generating an enhanced feature map. On the enhanced feature map, an anchorless detection head is constructed to directly predict the bounding box offset and classification confidence of the candidate region for each pixel position of each layer of the feature map, such as... Figure 3 and Figure 4 As shown.
[0069] Step S22 is the positive sample allocation step in the training phase. The classification branch is trained using the focus loss function:
[0070]
[0071] The regression branch uses a weighted combination of L1 loss and generalized IoU loss:
[0072]
[0073] Simultaneously, word-level contrastive alignment loss is introduced to promote semantic correspondence between keywords in text phrases and image region features:
[0074]
[0075] in For temperature coefficient, This is the feature vector of the actual target region corresponding to the instruction. For the i-th word element, Let be the feature vector of the j-th candidate region. This step also designs a coverage-aware multi-positive-sample allocation strategy. The positive-sample set is defined as a set that simultaneously satisfies an intersection-union ratio (IUU) with the true target greater than a first threshold. Furthermore, the semantic similarity with the instruction text is greater than the second threshold. The candidate prediction set allows each real target to be matched with multiple predicted positive samples, thereby increasing the number of training positive examples and improving the model's learning sufficiency for weakly textured and long-tailed targets. The comprehensive loss function is:
[0076]
[0077] Reference Figure 5 .
[0078] Step S23 is the only instance decision-making step in the inference phase. First, the candidate detection box set is pruned according to instruction constraints, retaining only candidate instances that fall within the specified directional area and whose geometric type and morphological attributes satisfy the constraints, thus eliminating interfering responses that are clearly inconsistent with the instruction semantics. Second, a joint semantic-geometric consistency score and ranking are performed, with the comprehensive score defined as:
[0079]
[0080] in , , For pre-fixed weighting coefficients, For classification confidence, Score the text alignment. Geometric consistency score. (By...) After sorting in descending order, cross-scale redundancy removal is performed: Centering on the highest-scoring candidate, candidates that highly overlap with it and have lower scores are removed. Finally, the first-ranked candidate is taken as the unique output instance of this instruction. Simultaneously, calibration confidence and uncertainty signals are output and converted into geometric inference weights.
[0081]
[0082] The weighted calculations used for subsequent geometric fitting suppress the impact of low-reliability observations on parameter estimation, referencing... Figure 6 .
[0083] Step S30, the step of performing continuous representation of the target contour based on the region of interest corresponding to the unique target instance through a contour reconstruction network with a continuous signed distance field, and simultaneously regressing the initial values of the geometric parameters using a geometric parameter observation head, further includes:
[0084] Step S31: Construct the region of interest and perform batch adaptive alignment;
[0085] Step S32: Output continuous band symbolic distance field prediction through the UNet backbone network;
[0086] Step S33: Regress the analytical geometric parameters and their uncertainties using the geometric parameter observation head;
[0087] Step S34: Jointly optimize the distance field reconstruction and geometric parameter regression using a composite loss function.
[0088] Step S31 is the data preparation step for contour reconstruction. Given the original image and the target detection bounding box output from step S20... The region of interest (ROI) is cropped in the original image coordinate system. To ensure consistency of pixel-domain measurement scale, no interpolation or scaling is performed after ROI extraction, strictly maintaining its original spatial resolution. This strategy aims to avoid introducing additional geometric quantization errors through scaling while preserving high-frequency details at real physical boundaries to the greatest extent possible. During model training, to improve the parallel computing efficiency of the GPU, ROI samples of varying sizes need to be assembled into tensor batches of uniform dimensions. An intra-batch adaptive minimum padding strategy is adopted: the maximum height and width of the ROI within the same batch are obtained, and zero-value padding is performed only on the right or bottom side of each ROI to align its spatial dimensions. Simultaneously, a binary effective region mask is constructed. The actual region of interest pixels are marked as 1, and artificially filled regions are marked as 0. This mask is used to weight the pixel-level losses such as distance field regression and geometric consistency, ensuring that the network extracts supervised gradients only from real visual signals.
[0089] Step S32 is the core prediction step in contour reconstruction. This step uses a signed distance field to achieve a continuous representation of the contour. Let the target region in the region of interest be denoted as... Its geometric boundary is For any pixel coordinates Following the sign rule of negative inside and positive outside, a signed distance field is defined: pixel values inside the target region are negative Euclidean distance values to the boundary, and pixel values outside the target region are positive Euclidean distance values to the boundary. Its zero level set... It strictly corresponds to the target contour. Compared to binary masks, the signed distance field is defined globally, no longer limited to sparse gradients provided by a few boundary pixels, thus significantly reducing the sensitivity of the training process to local breaks and noise. At the same time, the signed distance field exhibits smooth numerical changes in the boundary neighborhood, prompting the network to learn stable boundary evolution trends.
[0090] Introducing a truncation strategy focuses the supervision on the boundary neighborhood:
[0091] ,
[0092] Limiting the effective scope of online learning to This allows it to focus on optimizing the prediction accuracy of the contour neighborhood. The contour reconstruction network uses UNet as the backbone network, and the encoder follows... Stepwise downsampling extracts multi-scale features, and the decoder follows... Spatial resolution is restored by progressive upsampling and fusing features at the same scale from the encoding end through skip connections. The SDF prediction head employs... Convolution maps high-resolution features at the decoding end to single-channel responses. and through Activation function and scale parameter Amplitude limiting is applied to obtain the distance field prediction.
[0093] .
[0094] Simultaneously define the zero-layer zone region
[0095]
[0096] Used for subsequent boundary point extraction and geometric refinement, see reference. Figure 6 .
[0097] Step S33 is the global estimation of geometric parameters. The geometric parameter observation head, as a lightweight branch structure, is connected to the deepest feature map of the UNet encoder. Spatial information is integrated through global average pooling, and the analytical geometric parameters of the target object are directly regressed via a multilayer perceptron. This module plays a dual role: on the one hand, it provides a global structural prior, forcing the network to understand the overall topology of the target; on the other hand, this parameter will serve as the initial value for subsequent Gauss-Newton iterations, effectively avoiding the problem of nonlinear optimization being sensitive to initial values.
[0098] For circular features, use the coordinates of the center and radius. Describe the feature; for linear features, use the unit normal form. Description, satisfy For elliptical features, the parameter set is defined as follows: , corresponding to the center, major and minor semi-axes, and rotation angle, respectively. A differentiable reparameterization strategy is introduced to ensure the geometric feasibility of the output: a Softplus activation function is applied to the radius. Ensure positive value constraints are applied to the normal vector of the line. Normalization forces the constraint to satisfy the unit circle, and rotation angles are constrained by trigonometric function mapping. Within the interval. Furthermore, the geometric parameter observation head is designed as a probabilistic output module, in addition to regressing the mean of the geometric parameters. In addition, it also outputs the covariance matrix in parallel. , used to quantify the uncertainty of parameters.
[0099] Step S34 is the joint optimization stage of the contour reconstruction network. The total loss function is defined as:
[0100]
[0101] in To account for the distance field reconstruction loss, the following method is adopted: Norm in the effective region mask Internally calculate the pixel-level regression error between the predicted distance field and the true distance field; The Eikonal regularization term constrains the distance field to satisfy the mathematical property that the gradient magnitude is 1, forcing the network to learn the correct distance gradient field throughout the entire space. For geometric consistency coupling loss, given geometric parameters An analytic signed distance function corresponding to the geometric atom can be constructed. The loss constraint distance field should not only fit the data supervision, but also be consistent with the overall shape of the geometry described by the current parameters. For narrowband fitting loss, a set of boundary points is extracted within the zero-layer band region, and the weighted distance residuals to the analytical contour are calculated, where the weights are... These are gradient-based confidence weights used to reduce the interference of weak edge regions on the fitting direction; For parametric regression and uncertainty loss, the negative log-likelihood of a multivariate Gaussian distribution is used as the loss function. When the prediction error is large, the network tends to increase the uncertainty to reduce the penalty, while being constrained by the regularization term to prevent the variance from diverging infinitely.
[0102] Step S40, the step of calculating the pixel domain size and generating a measurement report based on the contour reconstruction result and initial geometric parameter values through zero-layer band point set extraction and few-step geometric refinement, further includes:
[0103] Step S41: Extract the set of boundary points within the zero-layer zone and calculate the confidence weights;
[0104] Step S42: Perform geometric refinement with a small number of steps using the weighted Gauss-Newton method;
[0105] Step S43: Calculate the pixel domain size and shape error index using analytical geometric operators based on the refined parameters;
[0106] Step S44: Integrate the measurement results to generate a structured measurement report.
[0107] Step S41 is the data preparation stage for dimensional calculation. The zero-layer zone region is defined as:
[0108]
[0109] in Control the narrowband width. Too small a value leads to too few candidate points and easy breakage; too large a value introduces points far from the boundary, increasing fitting noise. Uniform grid downsampling with random point addition within the zero-layer region ensures a more uniform spatial coverage of the point set, thereby reducing the impact of local defects on the fitting and obtaining a complete point set. ,in This represents the pixel coordinates in the region of interest coordinate system. Narrow bands may still contain noisy points or low-quality boundary points, therefore for each point... Calculate the confidence weights based on the magnitude of the distance field gradient:
[0110]
[0111] A larger weight indicates a steeper change in the distance field and a clearer boundary, contributing more to the refinement; a smaller weight indicates that the location is more likely to be located at a weak edge or in a noisy region, and its influence is suppressed.
[0112] Step S42 is the sub-pixel level thinning step for geometric parameters. Using initial values, construct a weighted least squares objective:
[0113]
[0114] in Let be the analytical distance from the point to the target geometric atom. Let the residual vector... Jacobian matrix Weight matrix Then the Gauss-Newton method in the 1st The increment is solved in the next iteration. satisfy:
[0115]
[0116] and according to Update parameters. The number of refinement iterations is fixed at K steps, and its scope is limited to local correction of the initial value. When K is too large, the optimization tends to over-attach the point set to the ideal geometry, thereby weakening the ability of the point set residual to characterize the error in the true shape. After refinement, the geometric contour described by the refinement parameters is back-projected onto the original region of interest image, and the residual between the projected contour and the image edge response is calculated. If the residual exceeds a preset convergence threshold, refinement is re-triggered with the current refinement parameters as the new initial value, realizing closed-loop iterative optimization.
[0117] Step S43 is the analytical calculation of dimensions. This yields the refined parameters. Subsequently, the dimension calculation was uniformly expressed as an analytical function mapping. The measurement results are output in the pixel coordinate system of the region of interest. Specifically, this includes:
[0118] Radius and Length Classification: Diameter is directly obtained from radius. radius of the arc ;
[0119] Distance type: Center distance between two circles Distance between points and lines Distance from the center of the circle to the line, the closest distance from the outer shape to the line, and the farthest distance, etc.
[0120] Angle type: Angle between two lines ;Parallel deviation, vertical deviation, etc.;
[0121] Shape error category: Roundness is obtained by statistical analysis of the residuals between the point set and the refined parameters, including roundness peak and valley values.
[0122] ,
[0123] in Straightness peak-valley value
[0124] ,
[0125] in It also outputs the root mean square form to reflect the overall processing consistency.
[0126] Positional correlation quantities, such as concentricity and eccentricity, are directly given by the distance between the centers of the two circles.
[0127] When the system has the capability to estimate parameter variance, it will also simultaneously output the confidence intervals of the dimensional measurements, by using the covariance matrix. The results, obtained by substituting into the error propagation formula, provide a quantitative basis for industrial quality control that combines high precision and high reliability.
[0128] Step S44 is the integration and output stage of the measurement results. Based on the measurement process in step S40, the execution results of each calculation are recorded, and this information is integrated to generate a detailed, structured measurement report. The report includes the following core contents: a basic information section, including the type of part to be measured, measurement time, and equipment model used; a measurement conclusion section, clearly indicating the numerical results of each measurement item and whether they are within tolerance ranges; and a detailed comparison section, listing the refinement results of each geometric parameter, shape error statistics, and uncertainty assessment. The report is presented visually for easy saving and review by users.
[0129] like Figure 7 As shown, an embodiment of the present invention provides an intelligent part size measurement system based on natural language understanding and deep contour representation, specifically including:
[0130] The measurement semantics compilation module is used to receive natural language measurement instructions and convert the natural language measurement instructions into a structured measurement plan;
[0131] The candidate target detection module is used to locate candidate geometric targets corresponding to the measurement command in the image to be tested through a text-guided candidate target detection network, and to determine unique target instances through a semantic-geometric consistency screening mechanism.
[0132] The contour reconstruction module is used to perform continuous representation of the target contour through a contour reconstruction network with a continuous signed distance field, and at the same time, it uses a geometric parameter observation head to regress the initial values of the analytical geometric parameters.
[0133] The size calculation module is used to calculate the pixel domain size and generate a measurement report based on the contour reconstruction results and initial values of geometric parameters, through zero-layer point set extraction and low-step geometric refinement.
[0134] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.
[0135] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions, and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention, and within the spirit and principles of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for generating structured measurement plans based on natural language measurement instructions, characterized in that, Includes the following steps: Receive natural language measurement instructions; The natural language measurement instructions are subjected to sentence segmentation and parallel parsing, alias normalization, unit unification, and referential parsing to obtain a standardized instruction sequence; The normalized instruction sequence is input into the semantic compilation unit, and constrained generation is performed by combining the domain vocabulary, standard unit set, alias mapping rules and structural constraint set, and the structured measurement plan is output. A consistency check is performed on the structured measurement plan. The consistency check at least determines the compatibility and missing relationships among the measurement type, the description of the measured target, the description of the reference datum, the physical unit, the tolerance range, and the measurement method. When the structured measurement plan does not meet the preset consistency requirements, the structured measurement plan is repaired according to the context-determined relationship, task matching relationship and object reference relationship, and an executable structured measurement plan is output. The executable structured measurement plan is output to the downstream target localization stage.
2. The structured measurement plan generation method according to claim 1, characterized in that, The constrained generation includes: The target structural constraints are resolved into a set of progressive state constraints. During the generation process, the set of legal output items is determined based on the currently generated content; Candidate outputs that do not belong to the set of legal output items are masked; Only output items that satisfy the current state constraints are allowed to proceed to subsequent generation steps.
3. The structured measurement plan generation method according to claim 1, characterized in that, The repair includes the following relational processing: Complete the missing fields that can be uniquely identified based on the context; Correct any incompatibilities between measurement type and physical unit, and between measurement method and task type; Replace missing object references due to missing referential or parallel relationships; Re-execute the consistency check on the repaired structured measurement plan and output it after the preset consistency requirements are met.
4. A method for determining unique target instances based on a structured measurement plan, characterized in that, Includes the following steps: Read the structured measurement plan generated by the method according to any one of claims 1 to 3; Extract the target description and reference description from the structured measurement plan and convert them into text query information; The image to be tested is input into the visual feature extraction unit, and the text query information is input into the text feature extraction unit; Image features and text features are fused according to cross-modal correlations to obtain enhanced features corresponding to the structured measurement plan; Output a set of candidate geometric targets based on the enhanced features; Based on the orientation constraints, geometric type constraints, morphological attribute constraints, and reference relationship constraints given in the structured measurement plan, the candidate geometric target set is pruned. The cropped candidate geometric targets are jointly scored based on classification confidence relation, text alignment relation, and geometric consistency relation; Redundancy removal is performed based on the joint scoring results to determine a unique target instance, and the unique target instance is output to the downstream contour representation stage.
5. The unique target instance determination method according to claim 4, characterized in that, The joint score includes: The classification confidence information of the candidate geometric targets is used as the first scoring input; The semantic matching information between candidate geometric targets and text query information is used as the second scoring input; The matching information between candidate geometric targets and geometric constraints in the structured measurement plan is used as the third scoring input; The first, second, and third scoring inputs are comprehensively calculated according to a preset weighting relationship to obtain a joint scoring result for ranking.
6. The unique target instance determination method according to claim 4, characterized in that, After determining the unique target instance, the process also includes: Output the uncertainty information corresponding to the unique target instance; Based on the inverse constraint relationship between uncertainty and geometric inference weights, the uncertainty information is converted into geometric inference weights; The geometric inference weights are output to the downstream geometric parameter refinement stage to control the impact of low-reliability observations on parameter estimation.
7. A method for measuring the dimensions of a part based on continuous contour representation, characterized in that, Includes the following steps: Read the unique target instance determined by the method of any one of claims 4 to 6; A region of interest is constructed based on the location of the unique target instance in the image to be tested, while maintaining the original spatial resolution of the region of interest; The region of interest is sized and aligned, and effective region identification information is generated to distinguish between the real image region and the padded region. The region of interest is input into the contour representation unit, and the continuous band signed distance field representation result of the target is output. The continuous band signed distance field representation result satisfies that the inside and outside of the target region correspond to different symbols, and the boundary corresponds to the zero layer relationship. The global structural features of the region of interest are input into the parameter observation unit, and the initial values of the analytical geometric parameters are output. The zero-layer band point set is extracted based on the continuous band sign distance field characterization results, and a confidence weight is assigned to each point in the zero-layer band point set. Using the initial values of the analytical geometric parameters as initial parameters, and controlling the contribution of each point to the residual calculation with the confidence weights, a fixed number of local geometric refinements are performed to obtain the refined parameters; The refined parameters are input into the analytical geometry calculation step, which outputs pixel domain size results and shape error results. A measurement report is generated based on the pixel domain size results and shape error results.
8. The part dimension measurement method according to claim 7, characterized in that, The generation of the continuous band signed distance field representation results satisfies the following mechanism: The target boundary neighborhood is used as the key characterization region; A truncation constraint is imposed on the range of values of the distance field, so that the contour representation unit focuses on outputting the continuous variation relationship within the boundary neighborhood; The zero-layer zone region is determined based on the aforementioned continuous variation relationship; The zero-layer zone region is used as the input region for boundary point extraction and subsequent geometric refinement.
9. The method for measuring the dimensions of a part according to claim 7, characterized in that, The fixed-step local geometric refinement includes: Establish a weighted residual relationship consisting of the distance residuals from boundary points to the analytic geometric object; The parameter update amount is obtained based on the weighted residual relationship and parameter change relationship; The initial values of the analytical geometry parameters are iteratively updated using the parameter update amount; Limiting the number of iterations to a preset fixed number of steps ensures that parameter updates are used only for local correction.
10. The method for measuring the dimensions of a part according to claim 7, characterized in that, The analytical geometry calculation step outputs measurement results according to the correspondence between the refined parameters and the measurement type. The measurement results include at least one of the following: radius, length, distance, angle, shape error, and position correlation. The refined parameters, error statistics, and tolerance comparison results are then written into the measurement report.