Mechanical processing drawing dimensioning method and device, product and medium
Patent Information
- Application Number
- CN202611086809.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-21
- Publication Date
- 2026-08-18
AI Technical Summary
然而,检索结果往往碎片化,对VLM准确理解工程图纸的尺寸信息帮助有限
本发明实施例按照尺寸标注信息的不同类型(也即,线基标注和圆基标注)分别提取像素尺寸,建立更准确的比例尺。通过识别图纸中的几何特征并判断其属性(也即,已标注尺寸或未标注尺寸),利用已建立的比例尺对未标注尺寸的几何特征推算待标注数据。根据预设规则选择性地将待标注数据标注于待标注图纸,使得到的已标注图纸既具有完整的尺寸信息,又避免了标注密集而影响下游模型(例如,VLM)的视觉认知,从而显著优化了下游模型对机械加工图纸的尺寸信息理解,为后续的工序规划、工艺拆分等下游任务提供了可靠的尺寸数据基础。
Smart Images

Figure CN122597488A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent manufacturing technology, and in particular to a method, device, product, and medium for dimensioning machining drawings. Background Technology
[0002] In the field of machining, accurately understanding product engineering drawings is a prerequisite for process planning, process breakdown, and cost accounting. With the development of artificial intelligence technology, using Vision-Language Models (VLMs) to understand engineering drawings and automatically generate process plans and process steps has become an important means of improving production efficiency.
[0003] However, the dimensions of parts in engineering drawings are often incomplete. In traditional production, for machining features without dimension markings, engineers mainly rely on experience to deduce and supplement them. VLM has significant limitations in understanding engineering drawings: VLM is good at recognizing semantic information (such as shape type and design intent), but it is extremely poor at obtaining quantitative information, that is, it cannot reliably estimate the length of line segments, has difficulty distinguishing the size of circles, and cannot complete the calculation of unmarked dimensions.
[0004] To overcome the aforementioned limitations of VLM, those skilled in the art have attempted to introduce Retrieval-Augmented Generation (RAG) technology, which retrieves process manuals and historical engineering case knowledge as contextual supplements during VLM inference. However, the search results are often fragmented, offering limited assistance to VLM in accurately understanding the dimensional information in engineering drawings. Summary of the Invention
[0005] To address the aforementioned problems, the present invention aims to provide at least one method for dimensioning machining drawings. This method identifies and determines the attributes of geometric features, performs dimensional reasoning on undivided geometric features, and selectively annotates them. This ensures that the drawings output to downstream models (e.g., VLMs) have complete and clear dimensional information, thereby avoiding misunderstandings in the downstream model due to dimensioning issues.
[0006] In a first aspect, the present invention provides a method for dimensioning machining drawings, the method comprising: receiving an original machining drawing, the original machining drawing including at least one view; in response to the original machining drawing including multiple views, segmenting the original machining drawing to obtain multiple drawings to be dimensioned, or, in response to the original machining drawing including one view, using the original machining drawing as the drawing to be dimensioned, wherein the drawing to be dimensioned is consistent with the view included in the original machining drawing. Figure 1One-to-one correspondence; based on a pre-trained target detection model, the dimension annotation information in the drawing to be annotated is identified, and the pixel size of the dimension annotation information is measured based on the type of the dimension annotation information. The type of dimension annotation information includes line-based annotation and circle-based annotation. The line-based annotation includes a pair of leader lines and a dimension line located between the pair of leader lines, and the dimension line indicates the distance between the pair of leader lines. The circle-based annotation includes a leader line and an arrow located at one end of the leader line, and the arrow points to a circle or arc. Based on the dimension annotation information and the pixel size, the scale of the drawing to be annotated is obtained. Geometric features in the drawing to be annotated are identified, and the attributes of the geometric features are determined. The attributes of the geometric features include annotated dimensions and unannotated dimensions. For the geometric features with unannotated dimensions, the data to be annotated is obtained based on the pixel size of the geometric features and the scale. Based on preset annotation rules, the data to be annotated is selectively annotated to obtain an annotated drawing.
[0007] Optionally, measuring the pixel size of the dimension annotation based on the type of the dimension annotation information includes: if the type of the dimension annotation information is line-based annotation, then measuring the pixel distance between the two ends of the dimension line of the line-based annotation as the pixel size of the line-based annotation; if the type of the dimension annotation information is circle-based annotation, then measuring the pixel diameter of the boundary of the circle pointed to by the arrow of the circle-based annotation, or the boundary of the circle obtained by fitting the arc pointed to by the arrow, as the pixel size of the circle-based annotation.
[0008] Optionally, obtaining the scale of the drawing to be annotated based on the dimension annotation information and the pixel size includes: pairing the dimension annotation information with the corresponding pixel size one by one to obtain at least one candidate scale data pair; obtaining a candidate scale based on the dimension annotation information and pixel size in the candidate scale data pair; if the candidate scales obtained by each candidate scale data pair are the same, or the number of candidate scales obtained is one, then the candidate scale is used as the scale; if the candidate scales obtained by each candidate scale data pair are different, then all the candidate scales are filtered to obtain the scale.
[0009] Optionally, the step of filtering all the candidate proportions to obtain the scale includes: removing outlier proportion values and performing numerical fitting on the remaining candidate proportions to obtain the scale.
[0010] Optionally, the step of numerically fitting the remaining candidate ratios to obtain the scale includes: obtaining the weight of each candidate ratio data pair, wherein the weight is positively correlated with the pixel size in the candidate ratio data pair; and performing weighted least squares fitting based on the weights to calculate the scale.
[0011] Optionally, identifying geometric features in the drawing to be annotated and determining the attributes of the geometric features includes: identifying geometric features in the drawing to be annotated; traversing the dimension annotation information and determining whether there are any dimension annotation information and geometric features that satisfy spatial matching conditions and size consistency conditions; if there are, then determining that the attribute of the geometric feature is an annotated dimension; if there are no, then determining that the attribute of the geometric feature is an unannotated dimension; wherein, the spatial matching condition refers to the position of the dimension annotation information in the drawing to be annotated matching the position of the geometric feature, and the size consistency condition refers to the dimension annotation information being consistent with the derivation information of the geometric feature, wherein the derivation information is a theoretical size calculated based on the pixel size of the geometric feature and the scale.
[0012] Optionally, the geometric feature types include straight line segments, arc segments, and complete circles. Determining whether the dimensioning information satisfies both spatial matching and dimensional consistency conditions with the geometric feature includes: for dimensioning information of type line-based annotation, if a pair of leader lines of the line-based annotation intersect the two endpoints of the same straight line segment, or intersect the endpoints of a pair of parallel straight line segments, then the dimensioning information satisfies the spatial matching condition with the straight line segment or the pair of parallel straight line segments; for dimensioning information of type circle-based annotation, if the endpoint of the arrow of the circle-based annotation intersects an arc segment or a complete circle, then the dimensioning information satisfies the spatial matching condition with the arc segment or the complete circle; for straight line segments that satisfy the spatial matching condition, the pixel dimensions of the length of the straight line segment are compared with the ratio. The derivation information is calculated based on the scale. If the derivation information matches the dimension annotation information, then the dimension annotation information and the line segment satisfy the dimension consistency condition. For a pair of parallel line segments that satisfy the spatial matching condition, the derivation information is calculated based on the pixel size of the distance between the pair of parallel line segments and the scale. If the derivation information matches the dimension annotation information, then the dimension annotation information and the pair of parallel line segments satisfy the dimension consistency condition. For an arc segment or a complete circle that satisfies the spatial matching condition, the derivation information is calculated based on the pixel size of the diameter of the arc segment or the complete circle and the scale. If the derivation information matches the dimension annotation information, then the dimension annotation information and the arc segment or the complete circle satisfy the dimension consistency condition.
[0013] Optionally, for the geometric feature without dimension annotation, obtaining the data to be annotated based on the pixel size of the geometric feature and the scale includes: responding to the geometric feature or a combination of geometric features to a preset processing feature; measuring the necessary pixel size according to the measurement template corresponding to the processing feature, wherein the measurement template defines the pixel size of one or more dimensions of the processing feature that need to be measured; and calculating the data to be annotated based on the necessary pixel size and the scale.
[0014] Optionally, selectively annotating the data to be annotated based on preset annotation rules includes: obtaining the criticality level of the processing feature corresponding to the data to be annotated, wherein the criticality level includes at least a first level and a second level, and the criticality level is a level determined based on the importance of the processing feature in machining, wherein the importance is positively correlated with the processing difficulty corresponding to the processing feature and / or the degree of influence on the function of the finished product, and the first level is more important than the second level; annotating the data to be annotated corresponding to the first level on the drawing to be annotated; and outputting the data to be annotated corresponding to the second level in text form.
[0015] Optionally, selectively annotating the data to be annotated based on preset annotation rules includes: obtaining the feature confidence score of the data to be annotated and a preset feature confidence score threshold, wherein the feature confidence score is determined based on the matching degree between the geometric features and the processing features, and the matching degree refers to the degree of conformity between the geometric features or a combination of multiple geometric features and the preset processing features; annotating the data to be annotated with the feature confidence score higher than the preset feature confidence score threshold on the drawing to be annotated; and outputting the data to be annotated with the feature confidence score equal to or lower than the preset feature confidence score threshold in text form.
[0016] Optionally, the dimensioning method further includes: in response to the completion of all dimensioning of the drawings corresponding to the views of the original machining drawings, inputting all the dimensioned drawings into a pre-trained visual language model.
[0017] Secondly, the present invention provides a dimensioning device for machining drawings, comprising: A drawing receiving unit is used to receive original machining drawings, the original machining drawings including at least one view; A view segmentation unit is configured to, in response to the original machining drawing comprising multiple views, segment the original machining drawing to obtain multiple drawings to be annotated; or, in response to the original machining drawing comprising one view, use the original machining drawing as the drawing to be annotated, wherein the drawing to be annotated is related to the view included in the original machining drawing. Figure 1 One-to-one correspondence; A dimension recognition unit is used to identify dimension annotation information in the drawing to be annotated based on a pre-trained target detection model, and to measure the pixel size of the dimension annotation information based on the type of the dimension annotation information. The type of dimension annotation information includes line-based annotation and circle-based annotation. The line-based annotation includes a pair of leader lines and a dimension line located between the pair of leader lines, and the dimension line indicates the distance between the pair of leader lines. The circle-based annotation includes a leader line and an arrow located at one end of the leader line, and the arrow points to a circle or arc. A scale calculation unit is used to obtain the scale of the drawing to be annotated based on the dimension annotation information and the pixel size; The feature recognition and attribute judgment unit is used to identify geometric features in the drawing to be annotated and to judge the attributes of the geometric features, wherein the attributes of the geometric features include annotated dimensions and unannotated dimensions; The dimension reasoning and annotation unit is used to obtain the data to be annotated for the geometric features without dimension annotation based on the pixel size of the geometric features and the scale, and selectively annotate the data to be annotated based on preset annotation rules to obtain an annotated drawing.
[0018] Thirdly, the present invention also provides a computer-readable storage medium, which is a non-volatile or non-transient storage medium, on which a computer program is stored, wherein the computer program is executed by a computer to perform any of the above-described methods for dimensioning machining drawings.
[0019] Fourthly, the present invention also provides a computer program product, including a computer program / instruction, wherein when the computer program / instruction is run by a computer, the dimensioning method for machining drawings described above is executed.
[0020] Compared with the prior art, the present invention has the following beneficial effects: This invention extracts pixel dimensions according to different types of dimensioning information (i.e., line-based and circle-based dimensions) to establish a more accurate scale. By identifying geometric features in the drawing and determining their attributes (i.e., labeled or unlabeled dimensions), the established scale is used to extrapolate the data to be labeled from the geometric features of unlabeled dimensions. The data to be labeled is selectively annotated onto the drawing according to preset rules, ensuring that the resulting annotated drawing has complete dimensional information while avoiding dense annotations that could affect the visual perception of downstream models (e.g., VLM). This significantly optimizes the downstream model's understanding of the dimensional information in machining drawings, providing a reliable dimensional data foundation for subsequent downstream tasks such as process planning and process breakdown.
[0021] Furthermore, by using a dual verification rule of spatial matching conditions and size consistency conditions to determine whether geometric features have been dimensioned, compared to a single verification rule, the probability of mismatch between dimension annotation information and geometric features is significantly reduced, and the determination of whether geometric features have been dimensioned is more accurate.
[0022] Furthermore, by matching unlabeled geometric features or combinations of geometric features to preset processing features, the necessary pixel dimensions are measured according to the measurement template corresponding to the processing feature, and the data to be labeled is calculated. This ensures that the calculated data to be labeled is guided by processing semantics, rather than generating data to be labeled indiscriminately for all geometric features in the drawing, thus avoiding redundant calculations. The data to be labeled has engineering significance in actual processing, enhancing the practicality of the labeled drawings in downstream tasks. Attached Figure Description
[0023] Figure 1 This is a flowchart of a method for dimensioning machining drawings according to an embodiment of the present invention; Figure 2 This is a schematic diagram of a device for dimensioning machining drawings according to an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be clearly and completely described below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0025] As mentioned in the background section, manually reading dimensions from drawings is inefficient. Existing manufacturing execution systems (MES) use pre-trained models (e.g., Virtual Models) to infer dimensions from engineering drawings to improve production efficiency. However, VLMs have insufficient understanding of unannotated geometric features, leading to poor reliability in downstream tasks such as process planning and process breakdown. Therefore, there is an urgent need for methods to identify and complete unannotated dimensions in drawings, providing VLMs with complete and clear annotated drawings to improve their understanding accuracy. This, in turn, enhances the reliability of downstream tasks such as order breakdown and process planning, significantly improving manufacturing efficiency.
[0026] Existing annotation schemes for architectural drawings primarily use line-based annotations, mainly involving line segment-like geometric features. However, machining drawings contain numerous circular features, and their corresponding circular-based annotations differ significantly from line-based annotations in geometric structure and annotation method. This invention employs different pixel size extraction methods for line-based and circular-based annotations, resulting in more accurate scale acquisition. Furthermore, by identifying geometric features and determining their attributes in the drawings, targeted dimension completion can be performed on unannotated geometric features, and annotation can be selectively applied. This allows downstream models to understand machining drawings more accurately without retraining (e.g., VLM).
[0027] To make the above-mentioned objectives, features and beneficial effects of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0028] The dimensioning method for machining drawings provided in this embodiment of the invention can be applied to enterprise management systems, such as Manufacturing Execution Systems (MES) for machining enterprises, or to Computer-Aided Process Planning (CAPP) systems, such as intelligent order splitting and process planning systems for enterprises. This system can be deployed as a functional module of a cloud-based manufacturing collaboration platform. The system's backend can run on a cloud server to process machining drawings, performing operations such as dimensioning information recognition, scale calculation, geometric feature detection and attribute judgment, inference of unannotated feature dimensions, and selective dimensioning, and storing annotated drawings and inference results data. The system's frontend can be implemented based on a webpage or app, allowing users to upload original machining drawings to be processed, view the dimensioning results of annotated drawings, and access subsequent process planning information.
[0029] like Figure 1 As shown, Figure 1 This is a flowchart of a method for dimensioning machining drawings according to the first embodiment of the present invention.
[0030] Specifically, in this embodiment, the method for dimensioning machining drawings includes the following steps: Step S101 receives the original machining drawing, which includes at least one view.
[0031] In the field of machining, engineering drawings typically include one or more views, such as a front view, top view, left view, sectional view, or enlarged partial view. The received original machining drawings can be DWG format files exported from CAD software, PDF format files, or scanned image files.
[0032] Step S102: In response to the original machining drawing including multiple views, the original machining drawing is divided to obtain multiple drawings to be annotated; or, in response to the original machining drawing including one view, the original machining drawing is used as the drawing to be annotated.
[0033] In practice, if the original machining drawing includes multiple views, it is divided into multiple drawings to be annotated, each corresponding to one view in the original machining drawing. If the original machining drawing includes only one view, it is directly used as the drawing to be annotated.
[0034] In some implementations, view segmentation can be achieved using a layout segmentation method based on object detection. For example, a pre-trained layout analysis model (such as the PP-Structure layout analysis module or YOLO series detection model in the prior art) can be used to perform region detection on the original machining drawing, identify and locate the bounding boxes of each view region, and then cut out the sub-images of each view region from the original machining drawing according to the detected bounding boxes as drawings to be annotated.
[0035] This paper briefly describes a pre-trained layout analysis model based on existing technologies. The model employs a convolutional neural network-based object detection architecture, comprising a backbone network, a neck network, and a head. The backbone network extracts multi-scale features from the input image, the neck network fuses and enhances features at different levels, and the head performs dense predictions on the fused feature map, outputting the class probability and bounding box regression parameters for each candidate region. The model's input is the pixel matrix of the original machining drawing, and the output is the bounding box coordinates and corresponding region category labels for each view region (including views, title bars, detail tables, technical requirement text blocks, etc.). Subsequent steps perform appropriate processing on each view region labeled as a view.
[0036] In other implementations, view segmentation can also employ a layout segmentation method based on connected component clustering.
[0037] Specifically, the original machining drawings are processed into grayscale and subjected to adaptive threshold binarization to separate the drawing content from the background, resulting in a binarized image. In this binarized image, graphic elements (lines, contours, etc.) in the drawing are foreground pixels, and blank areas are background pixels. Morphological closing operations (dilation followed by erosion) are performed on the binarized image, using a large structuring element (e.g., a 50×50 pixel rectangular kernel) to bridge pixel gaps caused by broken lines or noise within the same view, connecting geometric elements within the same view into a continuous foreground region. Connectivity analysis is then performed on the binarized image after the closing operation, extracting the bounding rectangles of all connected components and filtering out noisy connected components with an area smaller than a preset threshold (e.g., 1% of the total area of the drawing). Spatial clustering is then performed on the remaining bounding rectangles (using existing hierarchical clustering or DBSCAN algorithms, with the clustering distance threshold set to 15% of the shorter side length of the drawing), grouping multiple bounding rectangles that are spatially adjacent and belong to the same view into one group, with each group corresponding to a view region. For each group, the union of all bounding rectangles is taken, and the boundary is extended outward by a preset margin (e.g., 5%) to preserve the annotation lines and leader lines at the edge of the view, and the overlap between the bounding boxes is detected. If the overlapping area exceeds 20% of the area of the smaller region, they are merged into the same view. The final bounding boxes of each view are thus obtained, and the drawings to be annotated are cut out from the original machining drawings accordingly.
[0038] If the original machining drawing contains only one view, then the original machining drawing can be directly used as the drawing to be annotated, without the need to perform a segmentation operation.
[0039] In multi-view scenarios, different views may use different drawing scales, so each view needs to be processed independently. In single-view scenarios, only that single view needs to be processed. In this way, through view splitting operations, a one-to-one correspondence is established between the views in the drawing to be annotated and the original machining drawings.
[0040] Step S103: Identify the dimension annotation information in the drawing to be annotated based on the pre-trained target detection model, and measure the pixel size of the dimension annotation information based on the type of dimension annotation information. The types of dimension annotation information include line base annotation and circle base annotation.
[0041] Specifically, line-based annotation is a type of annotation for linear geometric features (such as straight line segments or pairs of parallel line segments). It includes a pair of leader lines and a dimension line located between the pair of leader lines. The dimension line indicates the distance between the pair of leader lines and is connected between the pair of leader lines and is perpendicular or approximately perpendicular to them. The two ends of the dimension line usually include a pair of arrows pointing to the pair of leader lines to clearly indicate the start and end positions of the measurement range. Circle-based annotation is a type of annotation for circular or arc-shaped geometric features (such as complete circles or arc segments). It includes a leader line and an arrow at one end of the leader line, with the arrow pointing to the circle or arc. The other end of the leader line is usually connected to annotation text, characters, and / or annotation values (e.g., Φ20, R10, M10×1.5, etc.).
[0042] The pre-trained object detection model can be a convolutional neural network-based model, such as the YOLO series or Faster R-CNN models in existing technologies. The input is the pixel matrix of the drawing to be annotated, and the output is the bounding box coordinates (with the pixel space of the input image as a reference), class labels (i.e., line-based or circle-based labels), and size confidence scores for each size annotation group. The object detection model adopts an anchor-box-based architecture: on the multi-scale feature map output by the backbone network, pre-defined anchor boxes are used as candidate regions. A classification branch predicts whether an annotation group and its class exist within each anchor box, while a regression branch predicts the offset of the bounding box relative to the anchor box. After removing redundant detection boxes using non-maximum suppression (NMS), the final detection result is output.
[0043] The drawing to be annotated is input into an existing target detection model, which outputs the bounding boxes of detected candidate targets and their category labels. In response to the detection of targets within the bounding boxes that are related to dimensioning information, the location of the dimensioning information is obtained, and they are combined and paired according to preset geometric constraint rules. Geometric constraint rules may include: if two detected arrow targets and a straight line segment (i.e., a dimension line) are collinear in space, and this straight line segment is perpendicular to another pair of detected leader lines in the drawing, then this group of elements is determined to be a line-based annotation; if an arrow, a straight line segment (i.e., a leader line), and a circular or arc segment target are detected to be adjacent in space, with the arrow pointing to the boundary of the circle, then this group of elements is determined to be a circle-based annotation.
[0044] In practical implementation, the model can also be trained and fine-tuned on a large dataset of machining drawings. The training and fine-tuning method for the object detection model is as follows: First, manually annotate dimension elements on a large number of machining drawings, including areas of leader lines, dimension lines, leader lines, arrows, annotation values, and characters, as well as type labels for annotation groups (line-based annotations or circle-based annotations). Training samples and labels are constructed using annotation groups as units. An annotation group refers to the organic collection of graphic elements that constitute complete dimension annotation information in space, serving as the basic unit for model detection. Then, the annotated dataset is input into the model for fine-tuning training: the difference between the model's predicted output and the manually annotated labels is used as the training loss (a weighted sum of classification loss and regression loss). The model parameters are iteratively optimized using the backpropagation algorithm until the loss function converges or meets the preset training stopping condition. This allows the model to learn to recognize the visual patterns and spatial relationships of line-based and circle-based annotation elements. After the above fine-tuning, the model can effectively locate and identify dimension annotation information in the drawings to be annotated, and output the bounding box, category label, and dimension confidence score for each annotation group.
[0045] For example, if a detected combination of annotation elements matches a pair of leader lines and a dimension line located between those leader lines, with the dimension line indicating the distance between the leader lines, it is determined to be a line-based annotation. Alternatively, if a detected combination of annotation elements matches a leader line and an arrow at one end of the leader line, with the arrow pointing to a circle or arc, it is determined to be a circle-based annotation. Size confidence refers to the model's degree of certainty regarding the detection result (including category determination and bounding box localization). Its value is determined based on a combination of the model's classification probability output and the localization accuracy of the bounding box regression. The size confidence value ranges from 0 to 1, with higher values indicating more reliable detection results. If the size confidence of a annotation group is lower than a preset confidence threshold (e.g., 0.7), the detection result is discarded and not included in subsequent processing.
[0046] In some implementations, the size confidence threshold can be set to 0.7. Further, the detected groups of annotations with confidence levels higher than this threshold are output and their type (line-based annotations or circle-based annotations) is determined.
[0047] Furthermore, pixel size measurements are performed on annotation groups that exceed the aforementioned size confidence threshold (e.g., 0.7) based on their type.
[0048] For dimension information of type line base annotation, measure the pixel distance between the two ends of the dimension line of the line base annotation, and use it as the pixel size of the line base annotation.
[0049] In some implementations, line segments are detected within the bounding box of a line-based annotation group based on the output bounding box coordinates. Specifically, the Hough Line Transform can be used to detect line segments. Among the detected line segments, the longest segment whose direction is perpendicular to the two leader lines is identified as the main segment of the dimension line. The equation of this dimension line and the coordinates of its coarse positioning endpoints are then extracted. The coarse positioning endpoints refer to the initial positions near the intersections of the dimension line and the leader lines, calculated by intersecting the dimension line and the leader lines.
[0050] Local windows (e.g., 30×30 pixel areas) are selected near the coarse positioning endpoints at both ends of the dimension line, and corner detection is performed within these local windows. Corner points are points in the image where the pixel gradient direction and magnitude change significantly, and they have stable geometric features at the arrow tip. Harris corner detection or Shi-Tomasi corner detection algorithms can be used to calculate the corner response value of each pixel within the local window, and pixels with response values exceeding a preset corner threshold are selected as candidate corner points. Then, the Euclidean distance from each candidate corner point to the coarse positioning endpoint is calculated, and the nearest corner point is selected as the precise pixel coordinate of the arrow tip. Through the above method, the precise pixel coordinates P1(x1,y1) and P2(x2,y2) at both ends of the dimension line are obtained. When the dimension line is horizontal, the pixel distance is the absolute value of the difference between the x-coordinates of the two endpoints; when the dimension line is vertical, the pixel distance is the absolute value of the difference between the y-coordinates of the two endpoints; when the dimension line is inclined, the pixel distance is the square root of the sum of the squares of the differences between the x and y coordinates.
[0051] For dimension information of type circular base annotation, locate the boundary of the circle pointed to by the arrow of the circular base annotation, or the boundary of the circle obtained by fitting the arc pointed to by the arrow, and measure the pixel diameter of the boundary as the pixel size of the circular base annotation.
[0052] In practice, the annotation text within the bounding box of the circular base annotation output by the target detection model is identified. The annotation text may contain prefix characters such as the diameter symbol Φ, the radius symbol R, or the thread symbol M. These prefix characters indicate the type of annotation, such as diameter annotation, radius annotation, or thread annotation.
[0053] Furthermore, the precise pixel coordinates of the arrow endpoint of the circular base annotation are located. Since the arrow in the circular base annotation is located at one end of the leader line, its positioning method is similar to that of the arrow in the line base annotation: the straight line segment containing the leader line is detected within the bounding box of the circular base annotation, and the end where the arrow is located is taken as the coarse positioning endpoint. Then, corner point detection is performed in a local window near this coarse positioning endpoint, and the nearest corner point is selected as the precise pixel coordinate P of the arrow tip. arrow .
[0054] After obtaining the arrow endpoint, use P arrow Centered on a local area around it (e.g., with P) arrow The Hough circle transform is performed within a preset radius (centered on the arrow) to detect circular features spatially adjacent to the arrow's endpoint. If the arrow points to a complete circle, the Hough circle transform can directly detect the complete circle parameters. If the arrow points to an arc segment, edge pixels are first extracted in a local area near the arrow's endpoint. The extracted edge pixels are then clustered to filter out continuous edge segments belonging to the same arc. Then, a three-point circle determination method or a least-squares circle fitting method is used to complete the arc segment into a complete circle, thereby obtaining the center coordinates and pixel diameter of the corresponding arc.
[0055] It should be noted that when the annotation text of a circular base includes the radius symbol "R", the annotation value represents the radius of the circular feature. In this case, the annotation value (radius value) is multiplied by 2 to convert it into a diameter value, and then paired with the pixel diameter. Accordingly, in the subsequent scale calculation, the actual physical size corresponding to this circular base annotation uses the converted diameter value for calculation. If the annotation text of the circular base includes the diameter symbol "Φ" or the thread symbol "M", then the annotation value already represents the diameter value, and no conversion is required.
[0056] The aforementioned character recognition can be based on Optical Character Recognition (OCR) to identify the prefix characters in the annotation text within the bounding box of the circular base annotation to determine the subtype of the circular base annotation. The subtype refers to whether the circular base annotation further belongs to diameter annotation, radius annotation, or thread annotation. Diameter annotation, radius annotation, or thread annotation corresponds to the diameter symbol Φ, radius symbol R, or thread symbol M in the drawing to be annotated, respectively.
[0057] The OCR recognition results may contain unit suffixes (such as mm) or tolerance markings (such as 30±0.1). In this case, only the nominal value part (i.e. 30) is extracted as the actual physical size value of the dimension marking information, and the unit suffix and tolerance suffix are ignored.
[0058] In summary, there is a fundamental difference between the pixel size extraction methods for line-based and circle-based annotations. Specifically, line-based annotation measures the pixel length of the dimension line itself, while circle-based annotation measures the pixel diameter of the circular or arc-shaped boundary pointed to by the arrow, rather than the length of the leader line itself. Therefore, distinguishing the type of dimension annotation information is a prerequisite for accurately obtaining the pixel size.
[0059] Step S104: Based on the dimensioning information and pixel dimensions, obtain the scale of the drawing to be annotated. The scale represents the correspondence between the pixel dimensions in the drawing and the actual physical dimensions of the product in the drawing. Its standard notation is pixel dimensions:actual dimensions. For example, 1:10 means that 1 pixel in the drawing corresponds to 10 mm of the actual physical dimensions of the product.
[0060] To facilitate subsequent calculations, this embodiment stores and calculates the scale as a scaling factor. The scaling factor refers to the actual physical size value corresponding to a unit pixel distance, i.e., scaling factor = actual physical size / pixel size; taking the 1:10 scale as an example, the scaling factor = 10mm / pixel. The scale and scaling factor are reciprocals of each other. In subsequent steps, the scale is mainly used for scale notation and final output, while the scaling factor is used for calculating specific values.
[0061] Specifically, the actual physical dimensions of each obtained dimension annotation are paired one by one with the corresponding pixel dimensions to obtain candidate scale data pairs. For each candidate scale data pair, its actual physical dimension is divided by the pixel dimension to obtain the local candidate scaling factor corresponding to the annotation. This local candidate scaling factor reflects the scale relationship indicated by the candidate scale data pair.
[0062] If there is only one dimension annotation in the drawing to be annotated, the scaling factor value is directly used as the global scaling factor of the drawing to be annotated, and thus the scale is determined.
[0063] When multiple dimensioning information exists in a drawing to be annotated, multiple local candidate scaling factors can be obtained. If all local candidate scaling factors are the same, this scaling factor value is directly used as the global scaling factor of the drawing to be annotated, thereby determining the scale. If there are differences between the local candidate scaling factors, all local candidate scaling factors are filtered and integrated to obtain the global scaling factor of the drawing to be annotated. The scale corresponding to this global scaling factor is the final scale of the drawing to be annotated. The specific processing methods for filtering and integrating will be described in detail below with specific implementation methods.
[0064] For original machining drawings containing multiple views, since each view has been divided into independent drawings to be annotated, the scale of each drawing to be annotated is calculated independently in the manner described above, and the following steps are performed separately.
[0065] Step S105: Identify the geometric features in the drawing to be annotated and determine the attributes of the geometric features, wherein the attributes of the geometric features include annotated dimensions and unannotated dimensions.
[0066] Specifically, for each identified geometric feature, all dimensioning information obtained in the preceding steps is iterated to determine whether any dimensioning information simultaneously satisfies both the spatial matching condition and the dimensional consistency condition with the geometric feature. The spatial matching condition means that the spatial position of the dimensioning information in the drawing to be annotated matches the position of the geometric feature. The dimensional consistency condition means that the dimension value in the dimensioning information matches the theoretical size of the geometric feature calculated based on the current scale (i.e., the global scaling factor calculated in the preceding steps). If a dimensioning information and a geometric feature simultaneously satisfy both conditions, the geometric feature is determined to be an annotated dimension; if no dimensioning information simultaneously satisfies both conditions, the geometric feature is determined to be an unannotated dimension, as will be explained in detail below.
[0067] Step S106: For geometric features without dimensions, obtain the data to be annotated based on the pixel size and scale of the geometric features, and selectively annotate the data to be annotated based on preset annotation rules to obtain an annotated drawing.
[0068] Specifically, the data to be annotated refers to the actual physical dimensions of the geometric feature, calculated as: Data to be annotated = Pixel size × Global scaling factor. The method of measuring pixel size differs for different types of geometric features. For example, the pixel size of a straight line segment is its length, the pixel size of a circle or arc is its diameter or radius, and the pixel size between parallel line segments is its spacing. After obtaining the data to be annotated, based on preset annotation rules, the data is selectively annotated onto the drawing to be annotated, resulting in an annotated drawing. The preset annotation rules specify under what conditions the data to be annotated should be annotated on the drawing and under what conditions it should not be annotated but output in other ways, which will be explained in detail below. Selective annotation refers to annotating the portion of all data to be annotated that conforms to the annotation rules onto the drawing to be annotated.
[0069] In some embodiments, the candidate ratio data for each candidate ratio are different from the calculated candidate ratio, that is, there are differences between the candidate ratio values. The arithmetic mean or median of all candidate ratios can be taken as the scale.
[0070] In some variations, the candidate scale data may differ from the calculated candidate scale. In such cases, all candidate scales are filtered to obtain the scale of the drawing to be annotated.
[0071] Specifically, outlier candidate ratios are removed from the candidate ratios. Outlier candidate ratios refer to those that deviate significantly from the overall distribution of candidate ratios. Causes of outlier candidate ratios include, but are not limited to: OCR recognition errors in dimension annotation information (e.g., misidentifying 30 as 36), and pixel size measurement deviations caused by arrow endpoint positioning errors.
[0072] To remove outlier candidate proportions, an outlier detection method based on median absolute deviation can be used. Specifically, the median value of all candidate proportions is calculated, and then the absolute deviation of each candidate proportion from the median value is calculated. The median of all absolute deviations is taken as the median absolute deviation. Then, an outlier criterion is set based on this median absolute deviation (for example, proportions that deviate from the median by more than 3 times the median absolute deviation are judged as outliers), and candidate proportions judged as outliers are excluded.
[0073] Furthermore, after removing outlier candidate scales, numerical fitting is performed on the remaining candidate scales to obtain the scale of the drawing to be annotated. Numerical fitting refers to comprehensively calculating the remaining candidate scale values according to a certain statistical criterion to obtain a scale that can represent the overall mapping relationship of the drawing to be annotated, and this scale corresponds to the aforementioned global scaling factor.
[0074] In some non-limiting embodiments, numerical fitting may employ the mean method, calculating the arithmetic mean of all remaining candidate proportions as the scale. Numerical fitting may also employ the median method, taking the median value of all remaining candidate proportions as the scale. Numerical fitting may also be performed using the least squares method; preferably, weighted least squares may be used, as will be described in detail below.
[0075] In practice, the weight of each candidate ratio data pair is obtained. This weight is positively correlated with the pixel size in the candidate ratio data pair; that is, the larger the pixel size, the higher the weight of the candidate ratio data pair. The principle is that annotations with larger pixel sizes occupy a larger spatial span in the drawing to be annotated, and the measurement of their pixel distance is less susceptible to interference from factors such as image resolution, edge blurring, and line breaks. Therefore, they have higher measurement reliability and should be given a higher weight.
[0076] For the i-th candidate proportion data pair (D) pi ,L ri ), where D pi Let L be the pixel size of the i-th candidate ratio data pair. ri Let w be the actual physical size of the i-th candidate scale data pair, i.e., the size value in the dimension annotation information. The weight corresponding to the i-th candidate scale data pair is w. i Candidate ratio r i =D pi / L ri The candidate scale is the ratio of pixel size to actual physical size, denoted as R. The objective function for fitting is: ∑w i ×(D pi -R×L ri ) 2The objective function aims to find the optimal scale R that minimizes the sum of the weighted squared errors between the pixel size and the predicted value for all candidate scale data pairs, thus minimizing the objective function's value. The scale R can be obtained by taking the derivative of this objective function and setting it to zero.
[0077] In one variation, after completing the weighted least squares fitting, a numerical parameter is calculated to evaluate the quality of the fit. This parameter reflects the overall consistency between each candidate scale data point and the fitted scale. This parameter is then compared to a preset parameter threshold; if the parameter falls below the threshold, a warning signal is generated.
[0078] Specifically, the numerical parameter for the quality of the fit can be calculated using the goodness-of-fit R. 2 The value is used to evaluate the calibration quality of the scale. R 2 The value R reflects the overall consistency between each candidate scale data point and the fitted scale. 2 The closer the value is to 1, the better the consistency. If R 2 If the value is below a preset threshold (e.g., 0.95), a warning signal is triggered, prompting the user to check for any annotation errors or abnormalities in the drawing to be annotated.
[0079] In some embodiments, identifying geometric features in a drawing to be annotated includes: performing edge detection on the drawing to be annotated (e.g., using the Canny edge detection algorithm in the prior art) to extract edge information of the image; then extracting connected edge contours using a contour tracing algorithm; then simplifying the contour curves into geometric primitives using a polygon approximation algorithm (e.g., the Douglas-Peucker algorithm in the prior art); and finally identifying geometric features from the geometric primitives, wherein the types of geometric features include line segments, complete circles, and arc segments.
[0080] In some embodiments, the spatial matching condition refers to the matching of the position of the dimension information in the drawing to be annotated with the position of the geometric feature. The dimension consistency condition refers to the consistency between the dimension information and the derived information of the geometric feature. If a dimension information and a geometric feature simultaneously satisfy both the spatial matching condition and the dimension consistency condition, then the attribute of the geometric feature is determined to be an annotated dimension, meaning that the geometric feature has been correctly annotated in the original drawing and no dimension inference is required. If, after traversing all dimension information, no dimension information simultaneously satisfies both the spatial matching condition and the dimension consistency condition with the geometric feature, then the attribute of the geometric feature is determined to be an unannotated dimension, meaning that the geometric feature lacks a corresponding dimension in the original drawing and requires dimension inference and completion through subsequent steps.
[0081] In one variation, the order of judging the spatial matching condition and the dimensional consistency condition can be reversed; that is, the dimensional consistency condition is verified first, followed by the spatial matching condition, and both are deemed as labeled dimensions upon passing the verification. In another variation, the spatial matching condition and the dimensional consistency condition can be judged in parallel to improve processing efficiency.
[0082] Furthermore, it is determined whether the dimensioning information and geometric features satisfy the spatial matching condition and the dimensional consistency condition. The specific methods for determining the spatial matching condition are as follows for different types of geometric features and dimensioning information: For dimension information of type line-based dimensioning, if a pair of leader lines of the line-based dimension intersect the two endpoints of the same straight line segment, then the dimension information is determined to satisfy the spatial matching condition with the straight line segment. This case corresponds to the length annotation of a single straight line segment feature. Two leader lines originate from the two endpoints of the straight line segment, and the dimension line is located between the two leader lines, indicating that the annotation measures the length of the straight line segment.
[0083] Alternatively, if a pair of leader lines of the line base annotation intersect the endpoints of a pair of parallel straight line segments, then the dimension annotation information is deemed to satisfy the spatial matching condition with the pair of parallel straight line segments. This case corresponds to the distance annotation between a pair of parallel straight line segments. The two leader lines originate from the corresponding ends of the pair of parallel straight line segments, and the dimension line is located between the two leader lines and perpendicular to the pair of parallel straight line segments, indicating that the annotation measures the distance between two parallel sides.
[0084] For dimensioning information of type circle base, if the endpoint of the arrow of the circle base dimension intersects with the arc segment or the complete circle (i.e., the arrow endpoint falls on the boundary of the arc segment or the complete circle, or the distance from the boundary is within a preset threshold range, which can be set based on the pixel resolution of the drawing, such as 3 pixels), then the dimensioning information is determined to meet the spatial matching condition with the arc segment or the complete circle. This situation corresponds to the diameter or radius dimensioning of a circular feature. The arrowhead of the leader line points to the boundary of the dimensioned circular feature, indicating that the dimension measures the dimension of the circular feature.
[0085] After the above spatial matching conditions are met, the size consistency condition is checked, and the specific method is as follows: For a line segment that satisfies the spatial matching condition, its pixel length is measured. Then, based on the pixel length and scale of the line segment, the theoretical size of the line segment is calculated as derivation information.
[0086] Specifically, the derived information is the theoretical size calculated based on the pixel size of the line segment and the scale obtained in the preceding steps. The specific conversion method is as follows: the value of the derived information equals the pixel size of the line segment multiplied by the global scaling factor (i.e., the reciprocal of the scale). For example, if the scale is 1:10 (i.e., 1 pixel corresponds to 10mm), and the pixel length of a line segment is 15 pixels, then the derived information for that line segment is 15 × 10 = 150mm. If this derived information is equal to the value marked in the dimension annotation information within a preset error tolerance range, then the size consistency condition is met. The calculation method for the derived information of complete circles and arc segments is similar and will not be repeated below.
[0087] If the derived information is consistent with the dimension value in the dimension annotation information, or if it is within the preset error tolerance range, then the dimension annotation information and the line segment are determined to meet the dimension consistency condition.
[0088] For a pair of parallel line segments that satisfy the spatial matching condition, the pixel distance between the pair of parallel line segments is measured. Then, based on this pixel distance multiplied by a scaling factor, the theoretical size of the spacing is calculated as derivation information. If this derivation information is consistent with the labeled value in the dimension annotation information, or if it is within a preset error tolerance range, then it is determined that the dimension annotation information and the pair of parallel line segments satisfy the size consistency condition.
[0089] For an arc segment or a complete circle that meets the spatial matching condition, measure its pixel diameter. For a complete circle, use the Hough circle transform to obtain its pixel diameter; for an arc segment, first fit the arc to a complete circle using three-point fitting or least squares method, and then obtain its pixel diameter. Then, based on the pixel diameter multiplied by a scaling factor, calculate the theoretical size of the circular feature as derivation information. If this derivation information matches the labeled value in the dimension annotation information, then it is determined that the dimension annotation information and the arc segment or complete circle meet the size consistency condition.
[0090] In some implementations, for geometric features without labeled dimensions, the data to be labeled is obtained based on the pixel dimensions and scale of the geometric features.
[0091] Specifically, in response to a geometric feature or a combination of geometric features, a preset machining feature is matched, and the necessary pixel size is measured according to the measurement template corresponding to the machining feature.
[0092] Machining features refer to a set of basic shapes on a workpiece in a machining drawing that possess specific machining semantics. In the field of machining, the geometry of a workpiece can be decomposed into several basic shape units with specific machining semantics, such as through holes, countersunk holes, threaded holes, bosses, grooves, chamfers, and fillets. These machining features each have their own defined geometric rules and dimensional parameter systems in the field of machining.
[0093] The measurement template defines the pixel dimensions of one or more dimensions that need to be measured for a processing feature. Each processing feature corresponds to a predefined measurement template, which specifies the pixel dimensions to be measured in each dimension and the measurement method. For example, the measurement template for a through hole specifies that the pixel diameter needs to be measured, and the measurement method is to obtain the pixel diameter using Hough circle transformation; the measurement template for a countersunk hole specifies that the outer diameter and inner diameter need to be measured, and the measurement method is to perform Hough circle transformation on the outer circle and inner circle respectively; the measurement template for a groove specifies that the width, depth and length need to be measured, which are represented as two of the three dimensions in a certain view, and the measurement method is to detect the parallel line spacing and / or perpendicular distance; the measurement template for a chamfer specifies that the chamfer dimension value needs to be measured, and the measurement method is to measure the projection distance of the endpoint of the oblique line segment in the direction of the edge normal; the measurement template for a fillet specifies that the fillet radius value needs to be measured, and the measurement method is to perform three-point fitting on the arc segment and obtain the radius value.
[0094] In practice, once a single geometric feature (e.g., a complete circle) or a combination of multiple geometric features (e.g., two concentric circles, or a circle combined with an adjacent straight line profile) is identified, it is matched against a pre-defined machining feature library. The machining feature library predefines geometric determination rules for various machining features. For example, a single complete circle without internal filling is matched to a through-hole machining feature; a combination of concentric double circles is matched to a countersunk hole machining feature; a combination of concentric double circles with nearby thread markings (such as "M" or "G" prefixes) is matched to a threaded hole machining feature; a rectangular concave profile is matched to a groove machining feature; a slanted line segment at the corner of a profile is matched to a chamfer machining feature; and a rounded arc at the corner of a profile is matched to a fillet machining feature, etc.
[0095] Once a geometric feature or combination of geometric features is successfully matched to a preset processing feature, the pixel dimensions of each dimension specified in the measurement template corresponding to that processing feature are measured one by one to obtain the necessary pixel dimensions of that processing feature. The necessary pixel dimensions refer to the set of all pixel dimension parameters required to calculate the actual physical dimensions of the processing feature. The number and type of dimensions included in the necessary pixel dimensions vary for different processing features.
[0096] Furthermore, after obtaining the necessary pixel dimensions, the data to be labeled is calculated based on the necessary pixel dimensions and the scale (i.e., the reciprocal of the global scaling factor). The data to be labeled refers to the actual physical size values of each dimension of the processing feature. The specific calculation method is as follows: multiply the pixel values of each dimension in the necessary pixel dimensions by the global scaling factor to obtain the actual physical size values corresponding to each dimension, which are used as the data to be labeled for the processing feature.
[0097] Unlike methods that perform dimensional reasoning on every isolated geometric feature in a drawing, this implementation only performs dimensional reasoning and generates dimensional data for a geometric feature or combination of geometric features when it matches a preset processing feature. In other words, only geometric shapes that can be assigned specific processing semantics and constitute a complete processing feature are included in the scope of dimensional reasoning and generate data to be annotated, achieving selective dimensional reasoning. This avoids redundant calculations and potentially invalid dimensional data resulting from performing dimensional calculations on every geometric feature in a drawing, while ensuring that the dimensional reasoning results directly correspond to feature parameters with engineering significance in actual processing, thus improving the practicality of annotation.
[0098] In other implementations, when a geometric feature or combination of geometric features fails to match any preset processing feature, it is not subjected to size inference; instead, it is directly marked as an unmatchable processing feature and subsequent processing is skipped.
[0099] In some implementations, when a geometric feature or combination of geometric features can match multiple preset processing features, the feature confidence score is output according to the matching degree, and the processing feature with the highest feature confidence score is selected as the final matching result. The feature confidence score is determined based on the matching degree between the geometric feature and the processing feature. The matching degree refers to the degree to which the geometric feature or combination of multiple geometric features conforms to the preset processing features.
[0100] In some embodiments, the specific method for selectively labeling data to be labeled based on preset labeling rules includes: obtaining the criticality level of the processing feature corresponding to the data to be labeled. This criticality level is a grade determined based on the importance of the processing feature in machining, and the importance is positively correlated with the processing difficulty corresponding to the processing feature and / or the degree of influence on the function of the finished product. That is, the higher the processing difficulty and the greater the impact on the function of the finished product, the higher its criticality level.
[0101] Specifically, the criticality level includes at least the first and second levels. The criticality level can also be further subdivided into three or more levels.
[0102] Let's take three levels of criticality as an example. Level 1 is the highest criticality level, corresponding to mandatory labeling, applicable to critical machining features such as holes, threads, and countersunk holes. Missing dimensions for these features directly affect the product's machining quality and assembly functionality, and must be clearly labeled on the drawings. Level 2 is the medium criticality level, corresponding to optional labeling, applicable to features such as chamfers, fillets, and wall thickness. These features have some impact on product machining and assembly, but their dimensions can be inferred from industry conventions or other reference information in the drawings when missing. Level 3 is the lowest criticality level, corresponding to text-only output, applicable to feature spacing, non-critical contour dimensions, etc. This dimensional information has some reference value for understanding the complete dimensional distribution of the drawings, but does not directly affect decisions regarding critical machining processes, therefore it is not visually labeled on the drawings.
[0103] After obtaining the criticality level of the processing features corresponding to the data to be annotated, the data corresponding to the first level is annotated on the drawing to be annotated, for example, by adding dimension lines, leader lines, or other dimensioning methods commonly used in engineering. These are then overlaid on the corresponding feature positions on the drawing as visual annotations, making these critical dimensions readily readable on the drawing.
[0104] Furthermore, the data to be labeled at the second level can be marked in the blank space of the drawing using annotation boxes or bubble numbers with dimension values. Alternatively, the data to be labeled at the second level can be selected using certain methods. For example, in the aforementioned reasoning process, for the processing features corresponding to the data to be labeled, if the feature confidence during the matching process is higher than a certain threshold, the data to be labeled is labeled; otherwise, it is output as text. The third level data is never labeled on the drawing under any circumstances; it is only provided as supplementary information in text form.
[0105] In one variation, the method of selectively labeling data based on preset labeling rules can also be based on feature confidence.
[0106] Specifically, the feature confidence scores of the data to be labeled are obtained and compared with a preset feature confidence threshold. The feature confidence score is determined based on the matching degree between geometric features and processing features. This matching degree refers to the degree to which the geometric features or a combination of multiple geometric features conform to the preset processing features.
[0107] When a geometric feature or combination of geometric features is matched to a preset machining feature, a matching score can be calculated. This matching score reflects the degree of geometrical similarity between the geometric feature or combination of geometric features and the target machining feature. For example, the higher the similarity between the geometric feature and the through-hole machining feature in terms of shape, size ratio, and adjacency, the higher its matching score. After obtaining the matching score, it is quantified as a feature confidence score, which can be a value between 0 and 1, with higher values indicating more reliable matching. The preset feature confidence threshold is a pre-defined criterion used to determine whether the dimensional reasoning result is reliable enough for visual annotation on the drawing.
[0108] In some non-limiting embodiments, after obtaining the feature confidence scores and preset feature confidence thresholds of the data to be labeled, the data with feature confidence scores higher than the preset feature confidence thresholds are labeled on the drawing to be labeled. The data with feature confidence scores equal to or lower than the preset feature confidence thresholds are output in text form, without being visually labeled on the drawing to be labeled.
[0109] In a typical application scenario, all the drawings to be annotated corresponding to the views of the original machining drawings are annotated, that is, each view corresponds to a labeled drawing. All the labeled drawings are then input into the pre-trained visual language model.
[0110] Specifically, after the annotated drawings are input into the visual language model, the model can perform subsequent understanding and reasoning tasks based on the complete dimensional information contained in the annotated drawings (including original annotations and inference-completed annotations). After the above annotation, the visual language model can perform downstream tasks such as process breakdown, processing feature recognition, or processing technology planning based on complete quantitative information, avoiding reasoning errors caused by incomplete drawing dimensional information.
[0111] A visual language model typically includes a vision encoder, a text encoder, and a multimodal fusion module. This solution does not make any changes to existing visual language models.
[0112] In one variation, before inputting the annotated drawings into the visual language model, the data to be annotated, which is eliminated by preset annotation rules, is also input into the visual language model in the form of structured text. In another variation, in addition to inputting the data to be annotated, which is eliminated by preset annotation rules, into the visual language model in the form of structured text, the calculated scales of each view and the data to be annotated derived from each view are also input into the visual language model in the form of structured text, providing the model with additional reference context. This improves the accuracy and reliability of the visual language model in downstream tasks of understanding engineering drawings.
[0113] Based on the above, the scheme of the first embodiment extracts pixel dimensions according to different types of dimension annotation information (i.e., line-based annotation and circle-based annotation) to establish a more accurate scale. By identifying geometric features in the drawing and determining their attributes (i.e., annotated or unannotated dimensions), it achieves the verification of whether a dimension has been annotated based on geometric features, thus enabling precise screening of unannotated geometric features. Using the established scale, the data to be annotated is calculated from the geometric features of unannotated dimensions, and selectively annotated on the drawing according to preset rules. This results in annotated drawings that have complete dimensional information while avoiding dense annotations that could affect the visual perception of downstream models (e.g., VLM), thereby significantly optimizing the downstream model's understanding of the dimensional information in machining drawings and providing a reliable dimensional data foundation for subsequent downstream tasks such as process planning and process breakdown.
[0114] Figure 2 This is a schematic diagram of a dimensioning device 20 for machining drawings according to a second embodiment of the present invention. Those skilled in the art will understand that the dimensioning device 20 for machining drawings in this embodiment can be used to implement the method and technical solutions described in the above embodiments.
[0115] Specifically, refer to Figure 2 The dimensioning device 20 for machining drawings in this embodiment may include: The drawing receiving unit 21 is used to receive original machining drawings, which include at least one view. View segmentation unit 22 is configured to, in response to the original machining drawing comprising multiple views, segment the original machining drawing to obtain multiple drawings to be annotated, or, in response to the original machining drawing comprising one view, use the original machining drawing as the drawing to be annotated, wherein the drawing to be annotated and the view included in the original machining drawing are... Figure 1 One-to-one correspondence; The dimension recognition unit 23 is used to recognize the dimension annotation information in the drawing to be annotated based on a pre-trained target detection model, and to measure the pixel size of the dimension annotation information based on the type of dimension annotation information. The type of dimension annotation information includes line-based annotation and circle-based annotation. Line-based annotation includes a pair of leader lines and a dimension line located between the pair of leader lines, and the dimension line indicates the distance between the pair of leader lines. Circle-based annotation includes a leader line and an arrow located at one end of the leader line, and the arrow points to a circle or arc. The scale calculation unit 24 is used to obtain the scale of the drawing to be annotated based on the dimension annotation information and pixel size; The feature recognition and attribute judgment unit 25 is used to identify geometric features in the drawing to be annotated and to judge the attributes of the geometric features, wherein the attributes of the geometric features include annotated dimensions and unannotated dimensions; The dimension reasoning and annotation unit 26 is used to obtain the data to be annotated for geometric features without dimension annotation based on the pixel size and scale of the geometric features, and selectively annotate the data to be annotated based on preset annotation rules to obtain an annotated drawing.
[0116] In specific implementation, the modules / units included in the various devices and products described in the above embodiments can be software modules / units, hardware modules / units, or a combination of both.
[0117] For example, for various devices and products applied to or integrated into a chip, each module / unit can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs that run on a processor integrated within the chip, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits; for various devices and products applied to or integrated into a chip module, each module / unit can be implemented using hardware methods such as circuits, and different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using hardware methods such as circuits. The components can be implemented using software programs that run on the processor integrated within the chip module. The remaining (if any) modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into the terminal, each of its components / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or in different components within the terminal. Alternatively, at least some modules / units can be implemented using software programs that run on the processor integrated within the terminal, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits.
[0118] Furthermore, embodiments of the present invention also disclose a computer-readable storage medium, which is a non-volatile or non-transient storage medium, on which a computer program is stored, and the computer program is executed by a computer. Figure 1 The method and technical solution in the illustrated embodiment. Preferably, the storage medium may include ROM, RAM, disk, or optical disk, etc.
[0119] Furthermore, embodiments of the present invention also disclose a computer program product, including a computer program / instruction, wherein when the computer program / instruction is executed by a computer, the dimensioning method of any of the above-mentioned machining drawings is executed.
[0120] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the invention; therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.
Claims
1. A method for dimensioning machining drawings, characterized in that, The method includes: Receive original machining drawings, which include at least one view; In response to the original machining drawing including multiple views, the original machining drawing is divided to obtain multiple drawings to be annotated; or, in response to the original machining drawing including one view, the original machining drawing is used as the drawing to be annotated, wherein the drawing to be annotated corresponds one-to-one with the view included in the original machining drawing. The pre-trained target detection model identifies the dimension annotation information in the drawing to be annotated, and measures the pixel size of the dimension annotation information based on its type. The dimension annotation information types include line-based annotation and circle-based annotation. The line-based annotation includes a pair of leader lines and a dimension line located between the pair of leader lines, and the dimension line indicates the distance between the pair of leader lines. The circle-based annotation includes a leader line and an arrow located at one end of the leader line, and the arrow points to a circle or arc. Based on the dimension annotation information and the pixel size, the scale of the drawing to be annotated is obtained; Identify the geometric features in the drawing to be annotated and determine the attributes of the geometric features, wherein the attributes of the geometric features include annotated dimensions and unannotated dimensions; For the geometric features without dimensions, data to be annotated is obtained based on the pixel size of the geometric features and the scale. Based on preset annotation rules, the data to be annotated is selectively annotated to obtain an annotated drawing.
2. The dimensioning method for machining drawings as described in claim 1, characterized in that, Measuring the pixel size of the dimension annotation based on the type of the dimension annotation information includes: If the type of the dimension annotation information is line-based annotation, then the pixel distance between the two ends of the dimension line of the line-based annotation is measured as the pixel size of the line-based annotation; If the type of the dimension annotation information is a circular base annotation, then based on the boundary of the circle pointed to by the arrow of the circular base annotation, or the boundary of the circle obtained by fitting the arc pointed to by the arrow, the pixel diameter of the boundary is measured as the pixel size of the circular base annotation.
3. The dimensioning method for machining drawings as described in claim 2, characterized in that, The process of obtaining the scale of the drawing to be annotated based on the dimension annotation information and the pixel size includes: The size annotation information is paired one by one with the corresponding pixel size to obtain at least one candidate ratio data pair; Based on the dimension annotation information and pixel size in the candidate ratio data pair, the candidate ratio is obtained; If the candidate ratios obtained from each candidate ratio data pair are the same, or if the number of candidate ratios obtained is one, then the candidate ratio is used as the scale. If the candidate ratios obtained from the different candidate ratio data pairs are different, then all the candidate ratios are filtered to obtain the scale.
4. The dimensioning method for machining drawings as described in claim 3, characterized in that, The step of filtering all the candidate scales to obtain the scale bar includes: The outlier scale values are removed, and the remaining candidate scale values are numerically fitted to obtain the scale bar.
5. The dimensioning method for machining drawings as described in claim 4, characterized in that, The step of numerically fitting the remaining candidate scales to obtain the scale bar includes: Obtain the weight of each candidate ratio data pair, wherein the weight is positively correlated with the pixel size in the candidate ratio data pair; The scale is obtained by performing weighted least squares fitting based on the weights.
6. The dimensioning method for machining drawings as described in claim 1, characterized in that, The process of identifying geometric features in the drawing to be annotated and determining the attributes of the geometric features includes: Identify the geometric features in the drawing to be annotated; Iterate through the dimension annotation information and determine whether there are any dimensions annotation information and geometric features that satisfy the spatial matching condition and the size consistency condition; If it exists, then the attribute of the geometric feature is determined to be a dimension that has been labeled; If it does not exist, the attribute of the geometric feature is determined to be unmarked dimension; The spatial matching condition refers to the position of the dimension annotation information in the drawing to be annotated matching the position of the geometric feature. The dimension consistency condition refers to the consistency between the dimension annotation information and the derived information of the geometric feature. The derived information is the theoretical size calculated based on the pixel size of the geometric feature and the scale.
7. The dimensioning method for machining drawings as described in claim 6, characterized in that, The types of geometric features include line segments, arc segments, and complete circles. Determining whether the dimensioning information satisfies both spatial matching and dimensional consistency conditions with the geometric features includes: For the dimension information of type line base annotation, if a pair of leader lines of the line base annotation intersect the two endpoints of the same straight line segment, or intersect the endpoints of a pair of parallel straight line segments, then it is determined that the dimension information and the straight line segment or the pair of parallel straight line segments satisfy the spatial matching condition. For dimensioning information of type circular base annotation, if the endpoint of the arrow of the circular base annotation intersects with the arc segment or the complete circle, it is determined that the dimensioning information and the arc segment or the complete circle satisfy the spatial matching condition. For the line segment that satisfies the spatial matching condition, the derivation information is calculated based on the pixel size of the length of the line segment and the scale. If the derivation information is consistent with the dimension annotation information, it is determined that the dimension annotation information and the line segment satisfy the dimension consistency condition. For the pair of parallel line segments that satisfy the spatial matching condition, the derivation information is calculated based on the pixel size of the distance between the pair of parallel line segments and the scale. If the derivation information is consistent with the size annotation information, it is determined that the size annotation information and the pair of parallel line segments satisfy the size consistency condition. For the arc segment or the complete circle that meets the spatial matching condition, the derived information is calculated based on the pixel size of the diameter of the arc segment or the complete circle and the scale. If the derived information is consistent with the dimension annotation information, it is determined that the dimension annotation information and the arc segment or the complete circle meet the dimension consistency condition.
8. The dimensioning method for machining drawings as described in claim 6, characterized in that, For the geometric features without dimension annotation, the data to be annotated is obtained based on the pixel size of the geometric features and the scale bar, including: In response to the matching of the geometric feature or a combination of geometric features to a preset processing feature, the necessary pixel size is measured according to the measurement template corresponding to the processing feature. The measurement template defines the pixel size of one or more dimensions of the processing feature that need to be measured. The data to be labeled is calculated based on the required pixel size and the scale.
9. The dimensioning method for machining drawings as described in claim 8, characterized in that, The selective annotation of the data to be annotated based on preset annotation rules includes: Obtain the criticality level of the processing feature corresponding to the data to be labeled. The criticality level includes at least a first level and a second level. The criticality level is a level determined based on the importance of the processing feature in machining. The importance is positively correlated with the processing difficulty corresponding to the processing feature and / or the degree of influence on the function of the finished product. The first level is more important than the second level. The data to be annotated corresponding to the first level is annotated on the drawing to be annotated; The data to be labeled corresponding to the second level is output in text form.
10. The dimensioning method for machining drawings as described in claim 8, characterized in that, The selective annotation of the data to be annotated based on preset annotation rules includes: The feature confidence score of the data to be labeled is obtained and a preset feature confidence score threshold is obtained. The feature confidence score is determined based on the matching degree between the geometric feature and the processing feature. The matching degree refers to the degree of conformity between the geometric feature or a combination of multiple geometric features and the preset processing feature. The data to be labeled that have a feature confidence level higher than the preset feature confidence threshold are labeled on the drawing to be labeled; The labeled data whose feature confidence is equal to or lower than the preset feature confidence threshold will be output in text form.
11. The dimensioning method for machining drawings as described in claim 1, characterized in that, Also includes: Once all the drawings to be annotated corresponding to the view of the original machining drawing have been annotated, all the annotated drawings are input into the pre-trained visual language model.
12. A dimensioning device for machining drawings, characterized in that, include: A drawing receiving unit is used to receive original machining drawings, the original machining drawings including at least one view; A view segmentation unit is used to segment the original machining drawing to obtain multiple drawings to be annotated in response to the original machining drawing including multiple views, or to use the original machining drawing as a drawing to be annotated in response to the original machining drawing including one view, wherein the drawings to be annotated correspond one-to-one with the views included in the original machining drawing; A dimension recognition unit is used to identify dimension annotation information in the drawing to be annotated based on a pre-trained target detection model, and to measure the pixel size of the dimension annotation information based on the type of the dimension annotation information. The type of dimension annotation information includes line-based annotation and circle-based annotation. The line-based annotation includes a pair of leader lines and a dimension line located between the pair of leader lines, and the dimension line indicates the distance between the pair of leader lines. The circle-based annotation includes a leader line and an arrow located at one end of the leader line, and the arrow points to a circle or arc. A scale calculation unit is used to obtain the scale of the drawing to be annotated based on the dimension annotation information and the pixel size; The feature recognition and attribute judgment unit is used to identify geometric features in the drawing to be annotated and to judge the attributes of the geometric features, wherein the attributes of the geometric features include annotated dimensions and unannotated dimensions; The dimension reasoning and annotation unit is used to obtain the data to be annotated for the geometric features without dimension annotation based on the pixel size of the geometric features and the scale, and selectively annotate the data to be annotated based on preset annotation rules to obtain an annotated drawing.
13. A computer-readable storage medium, said computer-readable storage medium being a non-volatile storage medium or a non-transient storage medium, having stored thereon a computer program, characterized in that, The computer program is executed by a computer to perform the dimensioning method for machining drawings according to any one of claims 1 to 11.
14. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instruction is executed by the computer, the dimensioning method for machining drawings according to any one of claims 1 to 11 is executed.