A numerical control machine tool machining program automatic generation method and system

By using visual recognition and semantic analysis technologies, CNC machine tool machining programs can be automatically identified and generated, solving the problem of low efficiency in manual interpretation and programming in existing technologies, and realizing efficient and accurate fully automated machining program generation.

CN121165620BActive Publication Date: 2026-03-20QINGDAO BRANCH CO., LTD. OF MECHANICAL SCIENCE RESEARCH INSTITUTE
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511715557.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-21
Publication Date
2026-03-20
Estimated Expiration
2045-11-21

AI Technical Summary

Technical Problem

In the existing technology, the generation of CNC machine tool machining programs relies on manual interpretation of drawings and programming, which has problems such as low efficiency, low accuracy and insufficient intelligence, and is prone to errors, especially when processing complex drawings.

Method used

Visual recognition technology is used to identify geometric shapes and dimension annotations in drawings. Combined with semantic analysis, machining program code is generated. Multi-scale convolution kernels and Transformer models are used for feature extraction and semantic understanding. A mapping relationship library is built to automatically plan tool paths and cutting parameters.

Benefits of technology

It has achieved fully automated generation of CNC machine tool machining programs, improving efficiency and accuracy, reducing manual intervention, adapting to various complex parts and assembly drawings, and enhancing the system's intelligence and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121165620B_ABST
    Figure CN121165620B_ABST
Patent Text Reader

Abstract

The application discloses a numerical control machine tool machining program automatic generation method and system, and the method steps comprise the following: obtaining the image of a target part machining drawing and performing pretreatment; performing image recognition on the pretreated drawing image, recognizing geometric figures and dimension marking information; performing semantic analysis on the text information in the pretreated drawing image, obtaining machining process and parameter information; generating machining program code according to the image recognition result and the semantic analysis result, first generating a preliminary tool path according to each geometric figure and dimension marking information, then matching corresponding initial cutting parameters according to the machining process and adjusting the initial cutting parameters, optimizing the preliminary tool path by using the adjusted cutting parameters, and finally filling program instructions by using the optimized tool path and the adjusted cutting parameters. The application can process various machine tool machining drawings, automatically generate machining program code, and significantly improve the efficiency, precision and flexibility of the machining program.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of intelligent control of numerical control machine tools, and in particular to a numerical control machine tool machining program automatic generation method and system. BACKGROUND

[0002] In the field of industrial machine tool machining, the efficiency and accuracy of the machining preparation stage are crucial to the overall production process. The traditional machine tool machining mode is to manually interpret the machine tool drawing and write the numerical control machining program, which has many drawbacks: on the one hand, when manually interpreting the drawing, since the drawing contains complex geometric shapes, size markings, technical requirements and other information, the staff needs to have rich professional knowledge and experience, which not only consumes time and effort, but also is prone to misinterpretation due to human error; on the other hand, when writing the machining program, the manual writing process is tedious and needs to consider tool path planning, cutting parameter setting and many other details, with a high error rate, and once the program is incorrect, it can result in scrap parts and even damage to the machine tool equipment.

[0003] Automatic programming systems can alleviate the burden of manual programming to some extent, but in the prior art, the automatic programming system is usually manually inputted with key information from the drawing by humans, cannot directly automatically identify and analyze the original drawing, and still needs manual setting of machining strategies and cutting parameters, etc., still needs human involvement, has low intelligence and limited efficiency improvement. Some practitioners have proposed using computer vision technology to assist in identifying the features to be machined in the machining drawing, solving the problem of the traditional automatic programming system needing manual input of key information from the drawing, but it can only achieve identification of machining features, and still needs manual setting of machining strategies and cutting parameters, etc., based on the machining features, and cannot achieve truly automatic programming. SUMMARY

[0004] The technical problem to be solved by the present application is that in view of the above technical problems existing in the prior art, the present application provides a numerical control machine tool machining program automatic generation method and device which is simple to implement, low in cost, high in intelligence and strong in flexibility, can process various machine tool drawings, automatically generate machining program codes, and significantly improve the efficiency, accuracy and flexibility of the machining program.

[0005] To solve the above technical problems, the technical solution provided by the present application is:

[0006] A numerical control machine tool machining program automatic generation method, comprising the steps of:

[0007] Collecting an image of a target part machining drawing and pre-processing to obtain a pre-processed drawing image;

[0008] The image recognition is performed on the pretreated drawing image, and geometric figures and dimension marking information in the drawing are recognized;

[0009] The semantic analysis is performed on the text information in the pretreated drawing image, and processing technology information and technical parameter information in the drawing are obtained;

[0010] The processing program code is generated according to the image recognition result and the semantic analysis result, the initial tool path is generated according to the recognized geometric figures and dimension marking information and the corresponding tool path planning algorithm in the mapping relationship library of the drawing information and the processing program code, the initial cutting parameters are matched from the mapping relationship library according to the dimension marking information and the processing technology information, the initial cutting parameters are adjusted according to the processing technology information and the technical parameter information, the initial tool path is optimized by using the adjusted cutting parameters, the corresponding program instructions are called from the mapping relationship library according to the processing technology information, and the program instructions are filled by using the optimized tool path and the adjusted cutting parameters, and the final processing program code is converted.

[0011] Further, the mapping relationship between the geometric figures and the tool path planning algorithm, the mapping relationship between the dimension marking information and the cutting parameters, and the mapping relationship between the processing technology and the program instructions are stored in the mapping relationship library, the initial tool path is generated according to the recognized geometric figures and the dimension marking information and the corresponding tool path planning algorithm in the mapping relationship library of the drawing information and the processing program code, which includes:

[0012] The target tool path planning algorithm is found and matched from the mapping relationship library according to the recognized geometric figures;

[0013] The coordinate system origin is determined according to the drawing reference point obtained by the image recognition;

[0014] The starting points of the rough turning path and the finish turning path are determined according to the position and size information of the geometric figures obtained by the image recognition;

[0015] The initial tool paths of the rough turning and the finish turning are generated according to the determined starting points of the rough turning path and the finish turning path and the target tool path planning algorithm.

[0016] Further, the cutting parameters include a cutting speed and a feed amount, the machining process information includes a machining process type, a process step and a process requirement, and the adjusting the initial cutting parameters according to the machining process information and the technical parameter information includes: adjusting the cutting speed and the feed amount according to the analyzed process requirement, wherein if the analyzed process requirement includes machining after quenching and tempering treatment, the cutting speed is reduced and the feed amount is reduced; further adjusting the feed amount according to the analyzed technical parameter information, wherein the technical parameter information includes a tolerance range and a surface roughness; and the optimizing the preliminary tool path using the adjusted cutting parameters includes optimizing any one or more of the feed speed, the rough turning cycle number and the tool retracting path in fine turning.

[0017] Further, the program instructions include a program header, a tool and compensation setting program segment, a machining cycle instruction, a fine machining program segment and a program tail, the program header includes a program number and a coordinate system configuration instruction, the tool and compensation setting program segment includes a tool selection instruction and a compensation parameter configuration instruction, the machining cycle instruction includes an instruction of tool walking according to the set tool path, the fine machining program segment is used for setting fine turning path coordinates, and the program tail includes a program end and a reset instruction.

[0018] Further, in the image recognition of the pretreated drawing image, a convolutional neural network based on a multi-scale convolution kernel is used to extract features from the pretreated drawing image, the multi-scale convolution kernel includes a horizontal straight line kernel, a vertical straight line kernel, a ring convolution kernel and a multi-scale straight line kernel, the horizontal straight line kernel is used to extract horizontal lines, the vertical straight line kernel is used to extract vertical lines, the ring convolution kernel is used to extract arcs, and the multi-scale straight line kernel is used to extract lines with a width exceeding a preset threshold, convolution layers of the convolutional neural network include at least two convolution branches, the multi-scale convolution kernel is arranged in each convolution branch to form multi-scale convolution branches, and outputs of the convolution branches are fused to obtain a final feature output.

[0019] Further, the pooling layer of the convolutional neural network determines a pooling result by using an adaptive threshold, and the steps include:

[0020] calculating a pixel mean value μ of each window and a corresponding threshold T = μ + a0×(max_p - μ), max_p represents a maximum pixel value in the window, and a0 represents a preset coefficient less than 1;

[0021] determining whether there is a pixel value > T in each window, and if there is, taking the maximum value of all pixels greater than the threshold T as the pooling result, and if not, taking the window mean value as the pooling result;

[0022] recording coordinates of each pooling result in the original feature map and corresponding to the pooled feature map.

[0023] Further, in the image recognition of the pre-processed drawing image, the features extracted from the pre-processed drawing image are matched by constructing a feature matching branch, the feature matching branch includes a geometric pattern recognition branch and a dimension label recognition branch, the geometric pattern recognition branch is used to extract edge features, shape features and topological relationships of geometric patterns, the topological relationships include inclusion relationship, adjacent relationship and intersection relationship, and a geometric pattern feature library is matched to obtain a geometric pattern recognition result, the dimension label recognition branch is used to extract label line features, the label line features include dimension lines and dimension boundaries, template matching is performed according to the extracted label line features, and character recognition is performed using a character recognition model to recognize dimension values and tolerance symbols, and the tolerance type is determined according to the recognized tolerance symbols.

[0024] Further, a semantic analysis model based on a Transformer model is used to perform semantic analysis on the text information in the pre-processed drawing image, the semantic analysis model based on the Transformer model is provided with a domain knowledge embedding layer to embed machine tool machining domain knowledge into the model, the domain knowledge embedding layer outputs after superimposing the word vectors after text preprocessing with the knowledge vectors corresponding to the word vectors, and the steps include:

[0025] The machining process, technical parameters and process rules are defined as entities in the knowledge graph, and the association relationship between the entities is defined to form a machine tool machining domain knowledge graph;

[0026] The entities and association relationships in the constructed knowledge graph are converted into vectors to form knowledge vectors, the knowledge vectors include term vectors formed by vector encoding the terms of the machining process and technical parameters, and rule vectors formed by vector encoding the relationships and constraint conditions of the process rules;

[0027] The pre-processed text word vector sequence is received, and the corresponding knowledge vector is matched from the knowledge graph for each text word vector, the knowledge vector and the text word vector are respectively vector encoded and then fused, and the fused vector sequence is input into a Transformer encoder for semantic encoding.

[0028] Further, the similarity between the text word vector and the matched knowledge vector is calculated, and the weight of the knowledge vector in the fusion process of the text word vector and the knowledge vector is dynamically adjusted according to the similarity, wherein the similarity is positively correlated with the weight of the knowledge vector, and the calculation expression of the fusion of the text word vector and the knowledge vector is V_fused = a x V_text + (1-a) x V_knowledge, wherein a is an attention weight, V_text represents a text vector, and V_knowledge represents a knowledge vector.

[0029] A numerical control machine tool machining program automatic generation system comprises:

[0030] An image acquisition and preprocessing module is configured to acquire an image of a target part machining drawing and perform preprocessing to obtain a preprocessed drawing image.

[0031] A visual recognition module is configured to perform image recognition on the preprocessed drawing image to recognize geometric figures and dimension marking information in the drawing.

[0032] A semantic analysis module is configured to perform semantic analysis on text information in the preprocessed drawing image to obtain machining process information and technical parameter information in the drawing.

[0033] A program automatic generation module is configured to generate a machining program code according to the image recognition result and the semantic analysis result, generate a preliminary tool path according to the recognized geometric figures and dimension marking information, and according to a corresponding tool path planning algorithm in a pre-constructed mapping relationship library, match initial cutting parameters from the mapping relationship library according to the dimension marking information and the machining process information, adjust the initial cutting parameters according to the machining process information and the technical parameter information, optimize the preliminary tool path using the adjusted cutting parameters, call corresponding program instructions from the mapping relationship library according to the machining process information, and fill the program instructions using the optimized tool path and the adjusted cutting parameters to convert the program instructions into a final machining program code.

[0034] Or the numerical control machine tool machining program automatic generation system comprises a processor and a memory, the memory is configured to store a computer program, and the processor is configured to execute the computer program to perform the above method.

[0035] Compared with the prior art, the application has the following advantages:

[0036] 1、The application can fully utilize visual recognition and semantic analysis results, realize full-automatic programming of various types of part numerical control machine tool processing drawings, does not need to rely on manual participation, can greatly improve the intelligent degree, efficiency and precision of machining program, reduce the artificial workload and human error in the process of manual interpretation and programming, and can flexibly process various complex parts and assembly machine tool processing drawings, and can improve the adaptability of the system to various new drawings and new processes.

[0037] 2、The application constructs a multi-dimensional mapping relationship library between drawing information and machining program code, uses the geometric figures and dimension marking information obtained by visual recognition, automatically matches the corresponding tool path planning algorithm to generate an initial tool path, can adapt to different types of geometric figures to match the corresponding path planning algorithm, effectively improves the adaptability and precision of tool path generation, and combines the machining process information and technical parameter information obtained by semantic analysis, automatically matches the corresponding cutting parameters and optimizes the tool path, forms the linkage optimization of "process - parameter - path", can effectively realize the dynamic matching of machining process, technical parameters and tool path, and quickly and accurately realize the full automation of numerical control machine tool processing program generation. BRIEF DESCRIPTION OF DRAWINGS

[0038] Figure 1 is a flowchart of the application embodiment to realize the automatic generation of numerical control machine tool processing program.

[0039] Figure 2 is a flowchart of the image acquisition and preprocessing module of the application embodiment to realize image preprocessing.

[0040] Figure 3 is a flowchart of the visual recognition module of the application embodiment to realize visual recognition.

[0041] Figure 4 is a flowchart of the semantic analysis module of the application embodiment to realize semantic analysis.

[0042] Figure 5 is a flowchart of the program automatic generation module of the application embodiment to realize machining program code generation. DETAILED DESCRIPTION

[0043] The application is further described below in conjunction with the drawings and specific preferred embodiments of the application, but the protection scope of the application is not limited thereto.

[0044] Figure 1is the overall architecture of the system applicable to the present application, including an image acquisition and preprocessing module, a visual recognition module, a semantic analysis module, and a program automatic generation module, each module corresponds to each step of the numerical control machine tool machining program automatic generation method of the present application, wherein the image acquisition and preprocessing module is used to acquire the image of the target part drawing and perform preprocessing to obtain the preprocessed drawing image; the visual recognition module is used to perform image recognition on the preprocessed drawing image, and identify the geometric figures and size annotation information in the drawing; the semantic analysis module is used to perform semantic analysis on the text information in the preprocessed drawing image to obtain the machining process information and technical parameter information in the drawing; the program automatic generation module is used to generate a machining program code according to the image recognition result and the semantic analysis result, first, according to the identified geometric figures and size annotation information, a preliminary tool path is generated according to the corresponding tool path planning algorithm in the mapping relationship library constructed in advance, then the initial cutting parameters are matched from the mapping relationship library according to the size annotation information and the machining process information, and the initial cutting parameters are adjusted according to the machining process information and the technical parameter information, the preliminary tool path is optimized using the adjusted cutting parameters, finally, the corresponding program instructions are called from the mapping relationship library according to the machining process information, and the optimized tool path and the adjusted cutting parameters are used to fill the program instructions to convert into the final machining program code.

[0045] The present application identifies the geometric figures and size annotation information in the machining drawing through visual recognition, simultaneously performs semantic analysis on the machining process and technical parameter information in the machining drawing, and then generates a machining program code according to the visual recognition result and the semantic analysis result, first, generates a preliminary tool path according to the identified geometric figures and size annotation information, then finds out the initial cutting parameters using the size annotation information and the machining process information and adjusts them, then optimizes the tool path using the adjusted cutting parameters, and finally converts the optimized tool path and the adjusted cutting parameters into a machining program code, forming a complete closed loop of "drawing import→information recognition→program generation", which can fully utilize the visual recognition and semantic analysis results, realize automatic programming of machining drawings of numerical control machine tools of various types of parts, and does not need to rely on manual participation, which can greatly improve the intelligent degree, efficiency and precision of the machining program.

[0046] Further, the numerical control machine tool machining program automatic generation system of the present embodiment further comprises a man-machine interaction module for receiving the numerical control machining program and the recognition result output by the program automatic generation module, and feeding back the user editing and modifying instructions to the program automatic generation module to adjust the generated machining program code. The man-machine interaction module can provide functions such as viewing, editing and confirming the system recognition result and the generated program code by the user, as well as system parameter setting, drawing import and export, etc.

[0047] The above-mentioned numerical control machine tool processing program automatic generation system of the embodiment first pre-processes the machine tool processing drawing image by the image acquisition and pre-processing module, and respectively outputs the pre-processed drawing image to the visual recognition module and the pre-processed drawing image containing text information to the semantic analysis module; the visual recognition module recognizes and outputs geometric figures and size marking information, and the semantic analysis module extracts and outputs processing technology and technical parameter information, both of which are jointly input into the program automatic generation module; the program automatic generation module outputs the generated numerical control processing program code and the recognition result to the man-machine interaction module, simultaneously receives the user editing and modification instructions fed back by the man-machine interaction module, forms a complete system working closed loop, and finally outputs a complete processing program.

[0048] The application will be further described below in combination with specific embodiments.

[0049] Referring to Figures 1-5 , the detailed steps of the embodiment for realizing the automatic generation of the numerical control machine tool processing program include:

[0050] Step S01. Image acquisition and pre-processing: acquiring the image of the target part processing drawing and pre-processing to obtain the pre-processed drawing image.

[0051] In the embodiment, after the image of the target part processing drawing is acquired, it is imported into the pre-processing module, and pre-processing such as gray scale processing, noise reduction processing, geometric correction, etc. is sequentially performed, and finally the pre-processed drawing image is output and provided to the visual recognition module and the semantic analysis module.

[0052] In a specific application embodiment, as shown in Figure 2 , the pre-processing step specifically includes:

[0053] Step S101. Gray scale processing: performing gray scale processing on the image, converting the color image into a gray scale image, so as to reduce the data amount, speed up the subsequent processing speed, and eliminate color interference.

[0054] Step S102. Noise reduction processing: performing noise reduction processing by using an adaptive median filter algorithm, and automatically adjusting the filter window size according to the noise density, removing Gaussian noise and salt and pepper noise (impulse noise), preserving the image edge information, and performing a binarization operation. It can be understood that other types of filter algorithms such as a Gaussian filter algorithm can also be used for noise reduction processing to filter out small spots and preserve line edges. When performing the binarization operation, an Otsu adaptive threshold algorithm can be used to automatically distinguish lines from backgrounds, and the threshold range is 120-180 to adapt to different scanning brightness.

[0055] Step S103. Geometric Correction: Identify standard reference points on the drawing (such as corner points, datum marks, etc.), calculate the perspective transformation matrix to correct images with geometric distortions, and ensure that the proportions of geometric figures in the image are accurate.

[0056] Step S02. Visual Recognition: Perform image recognition on the preprocessed drawing image to identify the geometric shapes and dimension annotations in the drawing.

[0057] In this embodiment, the visual recognition module performs feature extraction and matching based on the preprocessed image to identify key information such as geometric shapes and dimension annotations in the drawing.

[0058] Considering the high noise levels, complex lines, and dense annotations in industrial machine tool drawings, directly using traditional image processing algorithms and feature extraction methods for identification would result in insufficient accuracy, making high-precision identification difficult and failing to meet actual processing requirements. This embodiment utilizes an improved convolutional neural network (CNN). Based on classic CNN models (such as ResNet), it adds convolutional and pooling layers adapted to the characteristics of machine tool processing drawings, enabling accurate extraction of features such as lines, contours, and intersections from the image.

[0059] Specifically, machine tool processing drawings have features such as regular geometric lines (straight lines and arcs accounting for >80%), standardized dimension annotations (annotation lines + arrows + fixed font numbers / tolerance symbols), low noise (only scanning spots / slight creases), and high contrast (mainly black and white), which are significantly different from natural images (complex textures and rich colors). In this embodiment, a convolutional neural network based on multi-scale convolution kernels is used to extract features from the preprocessed drawing image. That is, multi-scale convolution kernels are used in the convolutional layer to form multi-scale convolution branches. The multi-scale convolution kernels specifically include horizontal straight line kernels, vertical straight line kernels, circular convolution kernels, and multi-scale straight line kernels. The horizontal straight line kernel is used to extract horizontal lines, the vertical straight line kernel is used to extract vertical lines, the circular convolution kernel is used to extract arcs, and the multi-scale straight line kernel is used to extract lines whose width exceeds a preset threshold (thick lines). The convolutional layer of the convolutional neural network includes at least two convolution branches. Multi-scale convolution kernels are set in each convolution branch to form multi-scale convolution branches. The outputs of each convolution branch are fused to obtain the final feature output. By using customized multi-scale convolutional kernels, a dedicated kernel is adopted for "straight lines / arcs-dominated" patterns, replacing the general 3×3 convolutional kernel. This avoids the feature redundancy and loss of key information problems of general CNNs. Furthermore, the multi-scale convolutional branching approach can adapt to lines of different thicknesses in drawings; for example, 0.1-0.5mm corresponds to 1-5px pixels. In specific application examples, the multi-scale convolutional kernel configuration information is shown in Table 1.

[0060] Table 1: Multi-scale convolutional kernel configuration

[0061]

[0062] In a specific application embodiment, the multi-scale convolution branch specifically includes two branches and a feature fusion module:

[0063] Branch 1 (thin line branch): preprocessed image → horizontal 3x3 convolution (16 channels) → BN layer (γ = 1, β = 0, momentum = 0.9) → ReLU activation → vertical 3x3 convolution (32 channels) → BN → ReLU;

[0064] Branch 2 (thick line / arc branch): preprocessed image → ring 5x5 convolution (16 channels) → BN → ReLU → multi-scale 5x5 convolution (32 channels) → BN → ReLU;

[0065] Feature fusion: the outputs (each 32 channels) of the two branches are spliced to obtain a 64-channel feature map (dimension: HxWx64, H / W is the height / width of the drawing pixels), and different types of line features are retained.

[0066] It can be understood that the specific parameters of each layer can be configured according to actual needs.

[0067] Considering that the drawing features have low dimensions and do not require deep networks, the embodiment can further configure the total number of convolution layers to be 6 layers (2 layers in each branch + 2 subsequent general convolution layers), and the subsequent 2 layers use 3x3 convolution (64→128 channels) to avoid exceeding 8 layers. By controlling the depth of convolution, overfitting can be avoided.

[0068] The traditional maximum pooling method has the problem of easily losing key features such as "line endpoints, intersection points of labeled lines", etc. The embodiment improves the traditional pooling layer, uses a combination of threshold filtering and maximum pooling to realize pooling, which can effectively retain effective features. At the same time, by recording the positioning information, it can also provide accurate coordinate basis for subsequent topological relationship matching.

[0069] Specifically, the step of determining the pooling result by the adaptive threshold of the pooling layer of the convolutional neural network of the embodiment includes:

[0070] Step S201. Calculate the pixel mean μ of each window and the corresponding threshold T = μ + a0x(max_p - μ), max_p represents the maximum pixel value in the window, a0 represents a preset coefficient less than 1, for example, it can be 0.1;

[0071] Step S202. Determine whether there is a pixel value > T in each window, if there is, take the maximum value of all pixels greater than the threshold T as the pooling result, if not, take the window mean as the pooling result;

[0072] Step S203. Record the coordinates of each pooling result in the original feature map and correspond to the pooled feature map.

[0073] In a specific application embodiment, the size of the pooling window can be set to 2x2 to balance the dimension reduction efficiency and feature preservation, the line density of the drawing is moderate, and 2x2 can avoid confusion of adjacent line features; the step size is set to 2, which can ensure no overlap and reduce the amount of calculation, and the output feature map size is 1 / 2 of the input; in the process of calculating the adaptive threshold, for each 2x2 window, the pixel mean μ=(p1+p2+p3+p4) / 4 is calculated, where p1-p4 are the pixel values in the window, and the corresponding threshold T can be calculated, if there is a pixel value > T in the window, the maximum value of these pixels is taken as the pooling result, to preserve strong features such as line edges and endpoints; if there is no pixel value > T in the window, the window mean is taken as the pooling result to avoid loss of background area features. For each pooling result, further record its coordinates (x, y) in the original feature map (x=window top-left x coordinate+1, y=window top-left y coordinate+1, based on 1-based index), store as coordinate matrix Coord (dimension: H / 2xW / 2x2), and correspond to the pooled feature map Feat (H / 2xW / 2x128), which can be called when calculating the topological relationship later.

[0074] After feature extraction according to the above steps, the extracted features are further matched by constructing a feature matching branch. The feature matching branch includes a geometric pattern recognition branch and a dimension label recognition branch. The geometric pattern recognition branch is used to extract edge features, shape features, and topological relationships of geometric patterns, including inclusion relationships, adjacent relationships, and intersection relationships. After matching with a pre-set geometric pattern feature library, geometric pattern recognition results are obtained. The dimension label recognition branch is used to extract label line features, including dimension lines and dimension boundaries. Template matching is performed according to the extracted label line features, and character recognition is performed using a character recognition model to finally recognize dimension values and tolerance types.

[0075] As Figure 3As shown, the detailed steps of the visual recognition module for image recognition of the pre-processed drawing image in this embodiment include: after receiving the pre-processed drawing image, using an improved convolutional neural network to extract features such as lines, contours, and intersection points in the image, then entering a feature matching branch, for geometric pattern recognition, extracting edge features, shape features (such as area, perimeter, internal angle, etc.), and topological relationship (containment, intersection, tangency, etc.) features of the geometric pattern, then matching the extracted features with a pre-set geometric pattern feature library to recognize geometric patterns such as circles, end faces, and keyways; for dimension marking recognition, extracting features such as marking lines, dimension numbers, and tolerance symbols, using a template matching-based character recognition algorithm (such as an OCR algorithm, etc.) to recognize dimension values and tolerance types; finally, summarizing the recognition results of geometric patterns (including shape and position information) and dimension markings (including numerical values and tolerances), outputting the final recognized geometric patterns and dimension marking information to provide for a subsequent program automatic generation module.

[0076] In a specific application embodiment, the detailed steps of the geometric pattern recognition branch for extracting edge features, shape features, and topological relationships are as follows:

[0077] (1) Edge feature extraction

[0078] Specifically, edge features can be extracted using a Canny edge detection algorithm, and further edge connection can be performed in combination with a double-threshold processing method, for example, retaining edges with a gradient amplitude > high threshold H, connecting weak edges with a gradient amplitude between low threshold L-high threshold H and connected to strong edges, and removing isolated weak edges to eliminate scanning noise. The high threshold H and the low threshold L can be determined according to the contrast statistical results of the drawing, for example, H can be taken as the G value of 90% of the edge pixels, and L = H / 2.

[0079] The drawing lines can be broken by 1px due to scanning, and after extracting the edge features using a Canny edge detection algorithm, morphological optimization can be further performed, for example, performing a dilation operation: using a 3x3 rectangular kernel [[1,1,1], [1,1,1], [1,1,1]] as a structure element, iterating 1 time to fill the gap between edges.

[0080] Further, a binary image thinning algorithm such as the Zhang-Suen algorithm can be used for skeleton extraction to thin the edges to 1px in width, thereby facilitating subsequent shape calculation.

[0081] (2) Shape feature extraction

[0082] Specifically, a connected region labeling method can be adopted to extract shape features in combination with a shape descriptor. For example, a 4-neighborhood labeling method (pixels adjacent to each other are labeled as the same region if they are not labeled) can be adopted to obtain a pixel set of each connected region . Further, a shape descriptor is used to quantify the shape type of each connected region, and the shape descriptor includes a minimum circumscribed rectangle, a circularity, a Fourier descriptor, etc. The minimum circumscribed rectangle descriptor can be used to distinguish a rectangle from a long strip, the circularity descriptor can be used to distinguish a circle, an ellipse, and a polygon, and the Fourier descriptor can be used to match similar shapes (such as circular holes of different sizes).

[0083] (3) Topological relationship extraction

[0084] The topological relationship specifically includes a containing relationship, an adjacent relationship, and an intersecting relationship, and the determination methods of various relationships are as follows:

[0085] ① Containing relationship determination

[0086] The centroid of the region A is calculated as follows: where nA is the number of pixels of A; if all the pixels of A are within the minimum circumscribed rectangle of the region B, and the centroid (xA, yA) is inside the edge of B (determined by the ray method: if the number of intersection points of the ray drawn from the centroid to the right with the edge of B is odd, the centroid is inside), it is determined that A is contained in B (for example, a circular hole is contained in a rectangular workpiece).

[0087] ② Adjacent relationship determination

[0088] The minimum Euclidean distance of the edge pixels of A and B is calculated as follows: where xi, yi ∈ A edge, xj, yj ∈ B edge; if d_min < 2px (the line width of the drawing paper is usually 1-2px), it is determined that A and B are adjacent (for example, two adjacent rectangular grooves).

[0089] ③ Intersecting relationship determination

[0090] For the edge line segments of A and B (each continuous 2 edge pixels form a line segment), the “crossing experiment” is adopted to determine the intersection: a. Let the line segment P1P2 (the edge of A) and Q1Q2 (the edge of B); b. Calculate the cross product cross1 = (P2-P1) x (Q1-P1), cross2 = (P2-P1) x (Q2-P1); c. Calculate the cross product cross3 = (Q2-Q1) x (P1-Q1), cross4 = (Q2-Q1) x (P2-Q1); d. If cross1 x cross2 < 0 and cross3 x cross4 < 0, the two line segments intersect; if the number of intersecting line segments is greater than or equal to 1, A and B intersect (for example, intersecting contour lines).

[0091] In a specific application embodiment, the detailed steps of the dimension label recognition branch for label line feature extraction (dimension line + dimension boundary line) are as follows:

[0092] Step S211. Dimension line detection

[0093] The input CNN pooled feature map is used to detect straight lines in the image by using the Hough straight line detection method, and a straight line parameter set Lines = {(p1, q1), (p2, q2),..., (p k, q k)} is output. Then, dimension line screening (including arrow recognition) is performed to screen horizontal / vertical straight lines: q e [0°±5°] (horizontal) or q e [90°±5°] (vertical), and length > 20px (the label line is longer than the width of the number, and the number is 5-8px wide).

[0094] For the 10x10px window at both ends of the straight line, the connected region is detected, and the area and circularity of the region are judged to identify the arrow, for example, the area of the arrow is a small triangle (such as 20-50px²) and the circularity is low (such as C<0.3). If both ends are identified as arrows, the current straight line is determined to be a dimension line, and its parameters (p, q, L) are recorded (L is the length of the straight line).

[0095] Step S212. Dimension boundary line screening

[0096] The straight line perpendicular to the dimension line is screened: q and the dimension line q differ by 90°±5°, and one end is in the geometric figure connected region (the distance can be determined by the centroid distance, such as distance <5px), and the other end is near the dimension line (such as distance <5px), then it is determined to be a dimension boundary line.

[0097] Step S213. Dimension number / tolerance symbol region positioning

[0098] With the size line as the center, a region with a specified range (e.g., 10px) above and below the size line is located, a window with a specified size is used to traverse the region, and the pixel variance Var in the window is calculated. If Var is greater than a preset threshold, the region is marked as a candidate region, otherwise it is marked as background. The distance between adjacent candidate windows is calculated. If the horizontal distance and the vertical distance are less than a preset threshold, the adjacent candidate windows are merged into a bounding box. The region in the bounding box is binarized (e.g., the Otsu algorithm can be used), the color is reversed (the character is black and the background is white), and the isolated regions with an area less than a preset threshold are deleted to remove scanning noise. Then, the projection method is used to segment each character. First, horizontal projection is used to segment multi-line characters (e.g., tolerance symbols above and numbers below), and then vertical projection is used to segment each line of characters into multiple single characters. If there is no 0 column in the vertical projection (the characters are connected), the watershed algorithm or the like can be used for connected processing. Finally, the distance of each character pixel to the background is calculated, a specified proportion of the distance transform result is taken as a threshold, and the marked points are obtained according to the threshold. The connected characters are segmented by taking the marked points as seeds, and the segmented characters are obtained.

[0099] Step S214. OCR character recognition

[0100] A character set is constructed: 0-9 (digits),. (decimal point), ±, ∠, Φ, R, ∥, ⊥, ≤, ≥ (a total of 20 types, covering more than 95% of machine tool drawing tolerance symbols) and a training sample set. An OCR character recognition model is trained. The model structure includes an input layer, a convolution layer 1, a pooling layer 1, a convolution layer 2, a pooling layer 2, a flattening layer, a bidirectional LSTM layer, and a fully connected layer in sequence. The model inputs the segmented single character image, outputs the character probability, and takes the character with the maximum probability. The size value (e.g., “12.5”) and the tolerance symbol (e.g., “±0.02”) are obtained by concatenating all the characters.

[0101] Further, the type of tolerance is determined according to the recognized tolerance symbol. If a tolerance symbol containing “±” is recognized and there is no size prefix, it is determined as a linear symmetric tolerance. If a tolerance symbol containing “±” is recognized and there is a size prefix “Φ”, it is determined as a diameter symmetric tolerance. If a tolerance symbol not containing “±” is recognized and there is a size prefix “R”, it is determined as a radius tolerance. If a tolerance symbol containing “∥” is recognized and there is no size prefix, it is determined as a parallelism tolerance. If a tolerance symbol containing “∠” is recognized and there is no size prefix, it is determined as an angle tolerance. The specific determination is shown in Table 2.

[0102] Table 2: Tolerance type determination

[0103]

[0104] Step S03. Semantic analysis: Perform semantic analysis on the text information in the preprocessed drawing image to obtain the processing technology and parameter information in the drawing. The processing technology includes the processing technology type, process steps and process requirements.

[0105] The textual information in machining drawings is highly specialized, containing machine tool processing terminology (such as "heat treatment 220-250HBW", "rough turning / semi-finish turning") and process logic (such as "semi-finish turning is required after rough turning"). Existing natural language processing models (such as the general Transformer model) struggle to accurately understand this meaning, leading to semantic analysis bias and hindering the effective extraction of key information. In this embodiment, the semantic analysis module understands and parses the textual descriptions in the drawings to extract machining process information and technical parameter information. Machining process information includes machining process requirements, machining process steps, and accuracy requirements, while technical parameter information includes tolerance ranges and surface roughness. This process can lead to semantic analysis bias.

[0106] like Figure 4 As shown, the text descriptions in the drawings (such as machining process requirements, tolerance ranges, etc.) are first input. After text preprocessing (word segmentation, stop word removal, word vector conversion), the text is input into the semantic analysis model based on Transformer. This model embeds professional terms and process rules in the machine tool machining field into the text through a domain knowledge embedding layer to enhance model understanding. Then, the encoder (Transformer component) encodes the text sequence of embedded knowledge to capture the context and semantic relationship. Finally, the decoder (Transformer component) converts the encoded semantics into a structured representation (such as machining process steps, cutting parameters, etc.), and finally outputs the parsed structured machining information, which is provided to the program's automatic generation module.

[0107] In this embodiment, the Transformer-based semantic analysis model consists of an encoder and a decoder. The encoder encodes the input text sequence, capturing contextual information and semantic relationships within the text; the decoder converts the encoded information into a structured semantic representation. A domain knowledge embedding layer is added to the model, embedding professional terminology and process rules from the machine tool processing field into the model. This domain knowledge embedding layer superimposes the preprocessed word vectors with their corresponding knowledge vectors before outputting the result, improving the model's ability to understand professional texts and solving problems such as poor understanding of professional terminology and inaccurate parsing of process rules in existing technologies.

[0108] The semantic analysis model needs to be trained before use. During the model training process, a machine tool processing drawing text corpus is constructed, including a large amount of structured text with annotations (processing technology requirements, tolerance range, etc.), process specification text data, the corpus is preprocessed (including word segmentation, stop word removal, word vector conversion, etc.) to obtain a customized machine tool processing text corpus, and based on the corpus, a hierarchical training strategy of "pre-training + domain fine-tuning" is adopted to train the model in a combination of pre-training and fine-tuning. First, the model is pre-trained using general text corpus, and then the pre-trained model is used as the basis to fine-tune the machine tool processing domain corpus, so that the model learns the semantic association of domain terminology and the logic of process rules. Through the back propagation algorithm, the model parameters are optimized until the accuracy of the model on the validation set reaches the preset threshold.

[0109] Specifically, the training corpus of the traditional NLP model is mostly general text (such as news, novels), which lacks professional text in the machine tool processing field, resulting in low accuracy of the model in analyzing texts such as "processing technology requirements, tolerance range". This embodiment collects structured text and process specification text to construct a machine tool processing field exclusive corpus. The structured text can use the "technical requirements" text of the machine tool processing drawing (such as "quenching and tempering treatment 220-250 HBW, rough turning after semi-finishing turning, finishing turning feed rate 0.1 mm / r"), and mark out "process steps (quenching and tempering → rough turning → semi-finishing turning → finishing turning)", "parameter values (feed rate 0.1 mm / r, hardness 220-250 HBW)" and the like. The process specification text can use the professional description in the industry standard (such as GB / T 1804-2000 tolerance standard, JB / T 9934-2015 machine tool processing specification), and mark out "terminology definition (such as 'parallelism tolerance' refers to the parallel deviation of two planes ≤0.01 mm)", "rule constraints (such as 'the rough turning cutting speed should be 80-100 m / min')".

[0110] After constructing the corpus, further corpus preprocessing is performed. This embodiment can optimize the word segmentation, stop word filtering and word vector conversion in the preprocessing process according to the characteristics of the domain text. For example, in the word segmentation process, "domain dictionary priority word segmentation" can be used (such as "quenching and tempering treatment" as a whole word segmentation, avoiding splitting into "quenching" and "treatment"), in the stop word filtering process, general stop words (such as "de", "he" and the like) can be removed, and domain-specific virtual words (such as "after", "preferably" and the like to reflect the process order or constraints) can be retained, and in the word vector conversion process, a domain-specific Word2Vec model can be used to ensure that the vector distance of terms such as "rough turning" and "finishing turning" can reflect the process correlation, such as the vector similarity of "rough turning" and "semi-finishing turning" > "rough turning" and "quenching".

[0111] The pre-training corpus of the general Transformer model (such as BERT) does not contain domain knowledge, and the accuracy is low when directly used for machine tool text analysis. Through the hierarchical training strategy of "pre-training + domain fine-tuning", the general applicability and domain adaptability of the model can be balanced, and the specific steps are as follows:

[0112] Step 1, general pre-training: use large-scale general text corpus (such as Wikipedia, Chinese general corpus) to pre-train the Transformer model, so that the model can master the basic grammar rules and context association ability (such as identifying that "0.1mm / r" in "feed rate 0.1mm / r" is a parameter value).

[0113] Step 2, domain fine-tuning: use the above-mentioned machine tool text corpus to fine-tune the pre-trained model as the basis, so that the model learns the semantic association of domain terminology (such as the binding relationship between "quenching treatment" and "hardness") and the logic of process rules (such as "rough turning" must be followed by "semi-finishing turning / finishing turning").

[0114] Specifically, the detailed steps of embedding machine tool processing domain knowledge in the Transformer-based semantic analysis model in this embodiment are as follows:

[0115] Step S301. Obtain the professional terminology library and process rule library of the machine tool processing domain.

[0116] The professional terminology library covers processing art terms (such as quenching, hardening, rough turning, finishing turning, milling), tolerance terms (such as symmetric tolerance, parallelism tolerance), parameter terms (such as cutting speed, feed rate, hardness HBW), etc.; The process rule library defines the logical relationship between terms, such as the processing sequence of "quenching treatment→rough turning→semi-finishing turning→finishing turning", the parameter constraint of "finishing turning feed rate ≤0.2mm / r", and the process requirement of "hardness 220-250HBW must be completed before rough turning".

[0117] Step S302. Set a domain knowledge embedding layer after the text preprocessing module and before the Transformer encoder, that is, after the text is segmented and converted into word vectors, the domain knowledge embedding layer is used to fuse domain knowledge before entering the encoder for encoding. The domain knowledge embedding layer outputs the word vectors after superimposing the knowledge vectors corresponding to the word vectors, so as to supplement the knowledge vectors to the preprocessed text word vectors.

[0118] As the word vector after text preprocessing "quenching", after the domain knowledge embedding layer, the label vector of "process type = heat treatment", "hardness requirement = 220-250HBW", "processing stage = rough turning before" is superimposed, so that the model not only captures the context during coding, but also associates with the domain rules.

[0119] Further, the implementation steps of the domain knowledge embedding layer include:

[0120] Step S321. Knowledge graph construction: define the machining process, technical parameters and process rules as entities in the knowledge graph, and define the association relationship between entities to construct the machine tool machining domain knowledge graph, so as to convert scattered domain knowledge into machine understandable structured graph.

[0121] Specifically, the machining process includes quenching, rough turning, and finish turning, the attributes of the machining process entity include process type and processing stage, the process type includes heat treatment and cutting processing, the processing stage includes presequence, intermediate and terminal sequence, etc., the technical parameters include cutting speed, feed rate and hardness, etc., the attributes of the technical parameter entity include parameter unit and value range, etc., the process rules include execution rules between rough turning, semi-finish turning, finish turning and heat treatment procedures, etc., and the attributes of the process rule entity include preconditions and constraint values. In a specific application embodiment, the definition of entities in the graph is shown in Table 3.

[0122] Table 3: Entity definition

[0123]

[0124] After defining the entity, the relationship between the entities is defined (such as "quenching"→ "associated parameter"→ "hardness", "rough turning"→ "subsequent process"→ "semi-finish turning"), forming a structured knowledge graph. Further, the knowledge graph can be stored in JSON format to facilitate model calling.

[0125] Step S322. Vector encoding of domain knowledge: convert the entities and association relationships in the constructed knowledge graph into vectors to form knowledge vectors, so that the knowledge can be calculated, and then ensure that it can be integrated with the text semantics, wherein the knowledge vector includes the term vector formed by vector encoding the terms of the machining process and technical parameters, and the rule vector formed by vector encoding the relationships and constraints of the process rules.

[0126] Specifically, in the term vector encoding process, for terms such as "rough turning" and "tempering and conditioning," a "word vector + attribute vector" concatenation method is adopted. The word vector can be the term vector generated by the "customized Word2Vec model" (such as the vector V1 of "rough turning"). The attribute vector is formed by converting the attributes of the term into one-hot vectors. For example, the attributes of the term "rough turning" are "process type = cutting" and "processing stage = intermediate", which are converted into one-hot vectors: "cutting" corresponds to [1,0] and "intermediate stage" corresponds to [0,1]. Then, it is compressed into a 512-dimensional attribute vector V2 through a fully connected layer. Finally, normalization is performed to obtain the term vector: V_term = (V1 + V2) / 2. Normalization can avoid dimensional bias.

[0127] For process rules (such as "roughing → semi-finishing"), a "relationship vector + constraint vector" fusion method is used for vector encoding. The relationship vector is the relationship description in the rule (such as "subsequent process") converted into a relationship vector V_rel, and the constraint vector is the constraint condition in the rule (such as "roughing cutting speed 80-100m / min") converted into a numerical vector V_const (such as [80,100] expanded to 512 dimensions). Finally, the relationship vector V_rel and the constraint vector V_const are combined to obtain the rule vector: V_rule = V_rel + V_const.

[0128] Step S323. Fusion of knowledge and text: In the embedding layer, the preprocessed text word vector sequence is received, and the corresponding knowledge vector is matched from the knowledge graph for each text word vector. The knowledge vector and text word vector are fused after vector encoding. The fused vector sequence is input to the Transformer encoder for semantic encoding.

[0129] Specifically, upon receiving the preprocessed text word vector sequence, a term matching algorithm (such as string fuzzy matching, vector similarity matching, etc.) can be used to match the corresponding knowledge vector for each text word vector. For example, after receiving the word vector sequence [V_tempering, V_220-250HBW] for "tempering treatment 220-250HBW", for the word vector V_tempering treatment, the term vector V_term1 of "tempering treatment" in the knowledge graph is matched; for the word vector V_parameter of the hardness specification "220-250HBW", the attribute vector V_term2 of the term "hardness" (associated with "unit = HBW") is matched.

[0130] In this embodiment, the similarity between the text word vector and the matched knowledge vector is also calculated, and the weight of the knowledge vector in the fusion process of the knowledge vector and the text word vector is dynamically adjusted according to the similarity, wherein the similarity is positively correlated with the weight of the knowledge vector, that is, the higher the similarity, the greater the weight of the knowledge vector. The calculation expression for fusing the text word vector and the knowledge vector is: V_fused = a x V_text + (1-a) x V_knowledge, wherein V_text represents the text vector, V_knowledge represents the knowledge vector, a is the attention weight, and 0≤a≤1. For example, the a of "conditioning treatment" is 0.4, and the knowledge weight is higher. The a of "of" and other general words is 0.9, and the knowledge weight is lower. By dynamically adjusting the weight of the knowledge vector in the attention fusion process, the interference of irrelevant knowledge can be avoided.

[0131] After constructing the domain knowledge embedding layer in the above manner, the domain knowledge embedding layer can be further optimized in cooperation with model training to further ensure effectiveness and improve the accuracy of knowledge embedding. The specific steps include:

[0132] In the pre-training stage, the embedding layer only loads the basic term vector (such as the vector of general technical terms), and does not load the complex rule vector, so as to avoid interfering with the learning of the basic syntax of the model. In the fine-tuning stage, when the domain corpus is fine-tuned, the knowledge vector and the fusion weight of the embedding layer are optimized simultaneously. When the specified process step is identified but the process sequence relationship is not identified, the term vector in the process step, the rule vector of the subsequent process step, and the fusion weight a of the term vector and the rule vector are adjusted through back propagation, so that the fused vector sequence can accurately reflect the domain semantics.

[0133] For example, when the model analyzes "rough turning and finish turning", if the process sequence relationship between "rough turning" and "finish turning" is not identified (i.e., the prediction is wrong), the term vectors of "rough turning" and "finish turning" can be adjusted respectively through back propagation: ① the term vectors of "rough turning" and "finish turning"; ② the rule vector of "subsequent process"; and ③ the fusion weight a of the two, so that the encoder can identify the sequence relationship in "rough turning and finish turning".

[0134] Compared with the traditional natural language processing model which only relies on the text context for analysis, the domain knowledge embedding layer can be set in this embodiment to realize dual-driven analysis of text semantics and domain knowledge, improve the accuracy of term recognition, effectively analyze the sequence logic of process steps (such as "rough turning and semi-finish turning"), and accurately identify the association between the processing technology and the parameters, for example, "220-250 HBW" can be identified as the associated parameter of "conditioning treatment", and the problem of "parameter mismatch" (such as misjudging the hardness value as the feed rate) can be avoided.

[0135] Step S04. Generating a machining program code according to the image recognition result and the semantic analysis result, first, according to the recognized geometric figures and the corresponding dimension marking information, a matching tool path planning algorithm is searched from a pre-constructed mapping relationship library to generate a preliminary tool path, then according to the machining process type obtained by analysis, a corresponding initial cutting parameter is matched from the mapping relationship library, and the initial cutting parameter is adjusted according to the parameter information obtained by analysis and process requirements, the preliminary tool path is optimized using the adjusted cutting parameter, finally the corresponding program instruction is called from the mapping relationship library, and the optimized tool path and the adjusted cutting parameter are used to fill the program instruction to convert and generate the final machining program code.

[0136] By constructing a multi-dimensional mapping relationship library between drawing information and machining program code, the geometric figures and dimension marking information obtained by visual recognition are combined to automatically match the corresponding tool path planning algorithm to generate an initial tool path, which can adapt to different types of geometric figures to match the corresponding path planning algorithm. Compared with the traditional fixed path template, the adaptability and precision of the tool path generation can be effectively improved, and the machining process information (process type, process requirements, precision requirements, etc.) and technical parameter information (tolerance range, surface roughness, etc.) obtained by semantic analysis are combined to automatically match the corresponding cutting parameter and optimize the tool path, forming a "process - parameter - path" linkage optimization, which can effectively realize the dynamic matching of machining process, technical parameter and tool path, and quickly and accurately realize the full automation of the generation of the numerical control machine tool machining program.

[0137] The embodiment first establishes a mapping relationship library of drawing information and machining program code, including the corresponding relationship between geometric figures and tool path planning algorithms, the corresponding relationship between dimension markings and cutting parameters, the corresponding relationship between machining processes and program instructions, etc., covering the whole chain of "geometry - path - parameter - instruction", as shown in Table 4; after receiving the geometric dimensions and marking information output by the visual recognition module and the machining process and technical parameter information output by the semantic analysis module, the visual recognition result and the semantic analysis result are combined to automatically generate the machining program code by calling the mapping relationship library, first, according to the recognized geometric figures (such as an outer circle, a key groove, etc.) and the size and position information, a preliminary tool path is generated according to the corresponding tool path planning algorithm (such as clockwise or counterclockwise tool walking for contour machining, spiral or zigzag tool walking for cavity machining, etc.), then according to the machining process requirements (such as cutting speed, feed rate) and the tolerance range and size obtained by semantic analysis, the corresponding cutting parameters (cutting speed, feed rate, etc.) are matched from the parameter database as initial cutting parameters and are adjusted, the cutting parameters after adjustment are used to optimize the tool path, finally, according to the programming language specifications (such as G code, M code) of the numerical control system, the tool path, cutting parameters, etc. Information is converted into a machining program code, such as Figure 5

[0138] Table 4: Mapping relationship library

[0139]

[0140] In a specific application embodiment, by collecting the corresponding specifications of geometric machining and path, parameters and precision, and the corresponding relationship between G / M code and machining operation (such as G71 corresponding to rough turning cycle, G81 corresponding to drilling), and collecting the "cutting parameter range of rough turning / finishing" and the "tolerance and machining frequency correlation" and other practical operation rules, the mapping relationship library can be established by corresponding storage of each rule and parameter information, and the geometric figure type (such as an outer circle) and the precision level (such as IT8) can be used as a joint index, which can ensure the professionalism and adaptability of the rules. Subsequently, the rules in the database can be dynamically updated according to the adjustment frequency of the rules to adapt to new machining scenarios.

[0141] Step S401. According to the recognized geometric figures and the corresponding dimension marking information, a matching tool path planning algorithm is found from the mapping relationship library to generate a preliminary tool path.

[0142] In the embodiment, the detailed steps of generating a preliminary tool path according to the recognized geometric figures and combining the size and position information according to the tool path planning algorithm include:

[0143] Step S411. According to the recognized geometric figures, a matching target tool path planning algorithm is found from the mapping relationship library;​

[0144] Step S412. Determine the coordinate system origin according to the image recognition obtained drawing reference point;

[0145] Step S413. Determine the rough turning path and the fine turning path starting point according to the image recognition obtained geometric figure position and size information;

[0146] Step S414. According to the determined rough turning path and fine turning path starting point, generate the preliminary tool path according to the target tool path planning algorithm.

[0147] In this embodiment, based on the geometric figure type (such as circle, keyway, cavity) output by the visual recognition module, the preset tool path planning algorithm is automatically matched, for example, circle / face corresponds to linear interpolation algorithm (G01), keyway (rectangle) corresponds to Z-shaped reciprocating algorithm, cavity (circle) corresponds to spiral interpolation algorithm (G02), round hole corresponds to drilling - reaming - tapping combination algorithm. In specific application examples, the correspondence between geometric figures and tool path planning algorithms is specifically configured as shown in Table 5.

[0148] Table 5: Correspondence between geometric figures and planning algorithms

[0149]

[0150] Taking "shaft part circle machining" as an example, the steps of calculating path coordinates based on the size values and position information obtained by visual recognition are as follows:

[0151] Part coordinate system establishment: set the "drawing reference point (such as the left end face center of the shaft)" recognized by vision as the coordinate system origin (X0, Z0);

[0152] Key coordinate extraction: including circle diameter, shaft length and rough turning allowance, wherein the circle diameter: the visual recognition output is "50±0.02mm", then the circle radius R=25mm; the shaft length: the visual recognition output is "50mm", then the right end face Z coordinate of the shaft is Z-50; the rough turning allowance: call "IT8 precision rough turning allowance = 2mm" from the mapping relationship library, then the rough turning circle radius R_rough = 25+1=26mm (X direction coordinate X52);

[0153] ​Path coordinate generation: rough turning path: start point (X52, Z2) → linear interpolation to (X52, Z-50) → radial feed to (X50, Z-50) → retreat to start point (X52, Z2), cycle 2 times (mapping relationship library setting IT8 precision rough turning cycle 2 times); finish turning path: start point (X50.2, Z2) → linear interpolation to (X50.2, Z-50) → radial feed to (X50, Z-50) → retreat to start point, with a margin of 0.1 mm.

[0154] After generating the preliminary path, the embodiment can further include path collision detection and correction. By automatically detecting the collision between the tool and the non-machining area of the part, when a collision is detected, the correction is performed. The correction logic is as follows: if the X coordinate of a point in the path is < tool radius (such as tool radius 5 mm, X coordinate 8 mm < 10 mm), then automatically adjust the X coordinate to “tool radius x 2 + 0.2 mm” (to avoid tool interference); if the Z direction path exceeds the length of the part (such as part Z-50, path Z-51), then automatically cut off the Z coordinate to the end face of the part (Z-50), and prompt the user to confirm whether “over-travel machining” is needed.

[0155] Step S402. According to the size marking information and the machining process information, the corresponding initial cutting parameters are matched from the mapping relationship library, and the initial cutting parameters are adjusted according to the machining process information and the technical parameter information. The optimized tool path is obtained by optimizing the preliminary tool path using the adjusted cutting parameters.

[0156] In this embodiment, the cutting parameters include cutting speed and feed rate, and adjusting the initial cutting parameters according to the machining process information and the technical parameter information includes: adjusting the cutting speed and the feed rate according to the analyzed process requirements, wherein if the analyzed process requirements include machining after quenching and tempering, the cutting speed is reduced and the feed rate is reduced; further adjusting the feed rate according to the analyzed parameter information, the parameter information including tolerance range and surface roughness; in the optimization of the preliminary tool path using the adjusted cutting parameters, including optimization of any one or more of the feed speed, the rough turning cycle number and the tool retreat path of the finish turning.

[0157] Specifically, from the structured machining information output by the semantic analysis module, the machining process type (such as “rough turning after quenching and tempering → semi-finish turning → finish turning”), process requirements (such as “surface roughness Ra1.6 μm”, “no vibration marks”), and technical parameter information (such as tolerance range) are extracted. Based on the mapping relationship library, the above information is used to match and adjust the cutting parameters. Taking the outer circle machining of the shaft part with a diameter of 50±0.02 mm as an example, the specific process of parameter optimization is as follows: ​

[0158] Initial parameter call: call the initial cutting parameters corresponding to "IT8 precision + fine turning" from the mapping relationship library: cutting speed v = 120 m / min, feed amount f = 0.1 mm / r, spindle speed n = 1000 r / min, then n = 1000v / (pi d) = 1000 x 120 / (pi x 50)

[0159] ≈764 r / min, can be rounded to 750 r / min;

[0160] Based on the adjustment of the semantic process: if the semantic analysis output is "quenching and tempering processing" (material hardness after tempering 220-250 HBW), the cutting speed is reduced by 10% (v = 120 x 0.9 = 108 m / min), and the feed amount is reduced by 5% (f = 0.095 mm / r); if the semantic analysis output is "surface roughness Ra1.6 pm", the feed amount is further reduced to 0.08 mm / r (mapping relationship library "Ra1.6 corresponds to f≤0.1 mm / r"); further, parameter constraint verification can be performed to ensure safety and reliability, for example, verifying "spindle speed n = 1000 x 108 / (pi x 50)≈688 r / min" whether it is within the range of machine tool spindle speed (such as 50-3000 r / min), if it is, it is retained, if it is exceeded, the nearest rated speed (such as 700 r / min) is taken; and verify "feed speed v_f = f x n = 0.08 x 700 = 56 mm / min" whether it is within the range of machine tool feed speed (such as 1-1000 mm / min), if it is, it is confirmed.

[0161] Linkage optimization of tool path: based on the adjusted cutting parameters, the preliminary tool path is optimized as follows: 1) tool path speed optimization: the feed speed is adjusted from "100 mm / min of preliminary path" to "56 mm / min" (matching the optimized feed amount); 2) cycle number optimization: if the semantic analysis output is "tolerance ±0.02 mm (IT8)", the rough turning cycle number is adjusted from "2 times" to "3 times" (to ensure uniform allowance and improve accuracy); 3) tool path optimization: if the semantic analysis output is "no vibration", a "slow tool retraction" (G01 retraction, speed 50 mm / min) is added after fine turning to avoid vibration caused by fast retraction (G00).

[0162] Step S403. Find the corresponding target program instruction from the mapping relationship library, and fill the optimized tool path and adjusted cutting parameters into the target program instruction to convert and generate the final machining program code output.

[0163] In this embodiment, the program instructions include program header, tool and compensation setting program segment, machining cycle instruction, finishing program segment, and program tail code modules. The program header includes program number and coordinate system configuration instructions. The tool and compensation setting program segment includes tool selection instructions and compensation parameter configuration instructions. The machining cycle instruction includes instructions for following the set tool path. The finishing program segment is used to set the finish machining path coordinates. The program tail includes program end and reset instructions. The standardized code structure can be defined according to Table 6.

[0164] Table 6: Definition of standardized code structure

[0165]

[0166] The mapping relationship between the machining process and the program instructions is stored in the mapping relationship library, that is, different machining processes (such as “rough turning after quenching and tempering → finish turning” and “drilling a round hole → hole expansion → hole reaming”) are bound with the program instruction combination including the program header, the tool and compensation setting program segment, the machining cycle instruction, the finishing program segment, and the program tail. Then, after identifying the machining process information, the corresponding program instructions can be called by using the mapping relationship library. For example, if the machining process is “finish turning of shaft parts with IT8 precision”, the instruction set of “program header (O0001+G54) + tool compensation (T0101+G41) + machining cycle (G70) + finishing program segment (G01 path) + program tail (M05+M30)” is called.

[0167] The adjusted cutting parameters and the optimized tool path are code-mapped and filled to convert and generate the final machining program code. The detailed steps include:

[0168] Step S431. The adjusted cutting parameters and the optimized tool path data are divided according to functions, and corresponding code modules are matched for each divided data array.

[0169] Specifically, the optimized tool path (including path type, start / endpoint coordinates, tool direction, etc.) and the adjusted cutting parameters (spindle speed, feed rate, back engagement amount, compensation value, etc.) are disassembled into corresponding data groups according to the function of the code module to ensure that each type of data can be accurately matched to the target module. The corresponding relationship between different function data groups and code modules is shown in Table 7. If it is a path coordinate data group, it corresponds to the finishing program segment. If it is a path type data group, it corresponds to the machining cycle instruction. If it is a cutting parameter, it corresponds to the machining cycle instruction / program header. If it is a tool / compensation parameter, it corresponds to the tool and compensation setting program segment. If it is a safety retreat coordinate data group, it corresponds to the program tail.

[0170] Table 7: Corresponding relationship between different function data groups and code modules.

[0171]

[0172] Step S432. According to the mapping relationship between the machining process and the program instruction in the mapping relationship library, the specific instructions of each code module are generated.

[0173] Specifically, for each code module, the divided data groups are converted into instructions conforming to the numerical control syntax through the mapping relationship library:

[0174] 1. Program header instruction generation: For example, the program number is automatically generated as "O+4-bit incremental number" (such as O0001) to avoid duplication; when the coordinate system / spindle limit is matched, "machining reference" data such as "drawing reference point as origin" corresponds to G54 (workpiece coordinate system), "spindle maximum speed 2000 r / min" corresponds to G50 S2000, and "feed amount unit mm / r" corresponds to G99, to generate O0001 G50 S2000 G99 G54 program header instruction.

[0175] 2. Tool and compensation setting instruction generation: For example, when selecting a tool, match "tool type" data such as "No. 1 external turning tool + No. 1 tool compensation" corresponding to T0101 (the first two digits are tool numbers, and the last two digits are tool compensation numbers); in the compensation parameter, match "compensation value" data such as "radius compensation 3mm" corresponding to G41 D01 (G41 is left compensation, and D01 pre-stores a 3mm compensation value), to generate T0101 G41 D01 tool and compensation setting instruction.

[0176] 3. Machining cycle instruction generation: For example, in the cycle type, match "machining process" data such as "rough turning" corresponding to G71, and "finishing turning" corresponding to G70 cycle parameters: match "cutting parameters + path data" such as "back engagement amount 2mm, retreat amount 1mm" corresponding to G71 U2 R1, "finishing allowance X0.1, Z0.05" corresponding to G71 P10 Q20 U0.1 W0.05, and "feed amount 0.2mm / r" corresponding to F0.2. Further generate machining cycle instruction (rough turning): G71 U2 R1 G71 P10 Q20 U0.1 W0.05 F0.2.

[0177] 4. Finishing program segment instruction generation: For example, in the starting point positioning, by matching the "finishing starting point coordinates", the G00 (rapid positioning) instruction is used, such as "(X50.2,Z2)" corresponding to N10 G00 X50.2 Z2 S700 M03 (S700 is the spindle speed, and M03 is the forward spindle rotation); in the toolpath, by matching the "finishing ending point coordinates + toolpath type", the G01 (linear interpolation) instruction is used, such as "(X50,Z-50)" corresponding to N15 G01 X50 Z-50 F0.08, to generate the finishing program segment instruction: N10 G00 X50.2 Z2S700 M03 N15 G01 X50 Z-50 F0.08.

[0178] 5. Program end command generation: For example, when retracting the tool, the "safe retraction coordinates" are matched using the G00 command, such as "(X100,Z100)" corresponding to G00 X100 Z100; when resetting, the "spindle stop + program end" command is matched in a fixed way, i.e., M05 M30, and the program end command is generated as: G00 X100 Z100 M05 M30.

[0179] Step S433. Concatenate the programs of each code module according to the CNC program syntax to form a complete machining program code. For example, concatenate the module instructions in a fixed order of "program head → tool and compensation settings → machining cycle instructions → finishing program segment → program tail", while following the CNC syntax rules specified in the file. For example, the instruction order: M03 (spindle forward rotation) must be after the S (spindle speed) instruction, and G71 (roughing cycle) must be before G00 / G01, etc. An example of the code for finishing a certain shaft part is shown in Table 8.

[0180] Table 8: Code Examples for Precision Turning of Shaft Parts

[0181]

[0182] Shaft-type parts Taking the machining of an outer diameter of 50±0.02mm as an example, the specific steps for filling in the program instructions to generate the machining program code include:

[0183] (1) Program header filling

[0184] Program number: Automatically generated O0001 (incremented by "O + 4 digits" to avoid duplication);

[0185] Coordinate system: Based on the reference point of visual recognition, fill G54 (workpiece coordinate system 1) and X0 Z0 (coordinate system origin).

[0186] (2) Tool and compensation filling

[0187] Tool selection: Retrieve "T0101 corresponding to external diameter machining" from the mapping relationship library and fill in T0101;

[0188] Compensation parameters: "Tool radius 3mm" as recognized by vision, filled with G41 D01 (D01 is the 3mm radius compensation value);

[0189] (3) Filling in processing cycle instructions

[0190] Roughing cycle: G71 U2 R1 (depth of cut 2mm, retraction 1mm), G71 P10 Q20 U0.1 W0.05F0.2 (finishing allowance X0.1, Z0.05, feed rate 0.2mm / r).

[0191] Finishing cycle: G70 P10 Q20 (call the finishing program segment).

[0192] (4) Filling the finishing program segment

[0193] Starting coordinates: N10 G00 X50.2 Z2 S700 M03 (optimized spindle speed 700r / min, spindle forward rotation);

[0194] Path coordinates: N15 G01 X50.2 Z-50 F0.08 (finish turning outer diameter, feed rate 0.08mm / r); N20 G01X50 Z-50 F0.08 (radial feed to dimension).

[0195] (5) Sequence end filling:

[0196] Retract tool: G00 X100 Z100 (Safe position, based on machine travel setting);

[0197] Reset: M05, M30.

[0198] According to the above steps, the preliminary code can be generated, and further, the verification, correction or risk can be automatically performed to ensure compliance with the syntax of the numerical control system, and then the code can be directly used for machine tool processing. For example, syntax rule verification can be performed to check the order of instructions (such as M03 needs to be after S instruction, G71 needs to be after G00 / G01, M05 needs to be after G00 tool retract, etc.), and check the completeness of parameters (such as G71 needs to include U, R, P, Q, U, W parameters, and if one is missing, it is prompted to complete); parameter verification can also be performed to check whether the cutting parameters are within the rated range of the machine tool (such as spindle speed 700 r / min needs to be within "50-3000 r / min", and if it exceeds, the closest rated value is taken); further path verification can be performed to check whether the tool path has collision risk (such as when X coordinate < tool diameter, automatically adjust X coordinate to "tool diameter + 0.2 mm"); further format correction can be performed: unify coordinate value format (unify decimal places, etc., such as X50.2→X50.20) and unify instruction case (such as g01→G01); and then the verified code is previewed on the human-computer interaction interface, and "key parameters" (such as cutting speed, feed rate) are marked to facilitate the user to quickly check. In the human-computer interaction module, the parameters can also be modified and adjusted to meet the actual processing requirements.

[0199] It can be understood that the order of the above steps of the embodiment can also be adjusted according to actual needs, and the order of the steps is not limited, for example, the visual recognition and semantic analysis steps can be executed in parallel.

[0200] In another embodiment, the numerical control machine tool processing program automatic generation system of the present application can also include a processor and a memory, the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above method.

[0201] It can be understood that the above method of the embodiment can be executed by a single device, such as a computer or a server, etc., and can also be applied to a distributed scenario to be completed by multiple devices cooperating with each other. In the case of a distributed scenario, one of the multiple devices can only execute one or more steps in the above method of the embodiment, and the multiple devices interact with each other to complete the above method. The processor can be implemented in the form of a general-purpose CPU, a microprocessor, an application-specific integrated circuit, or one or more integrated circuits, etc., for executing related programs to implement the above method of the embodiment. The memory can be implemented in the form of a read-only memory ROM, a random access memory RAM, a static storage device, and a dynamic storage device, etc. The memory can store an operating system and other application programs, and when the above method of the embodiment is implemented by software or firmware, the related program code is saved in the memory and executed by the processor.

[0202] The above merely describes the preferred embodiments of the present application, and is not intended to limit the present application in any form. Although the present application has been disclosed with the preferred embodiments as above, it is not intended to limit the present application. Therefore, any simple modification, equivalent change and modification made to the above embodiments without departing from the technical solution of the present application, and according to the technical essence of the present application, should fall within the scope of protection of the technical solution of the present application.

Claims

1. A method for automatically generating CNC machine tool machining programs, characterized in that the steps include: include: Acquire images of the target part's machining drawings and preprocess them to obtain preprocessed drawing images; Image recognition is performed on the preprocessed drawing image to identify the geometric shapes and dimension annotations in the drawing; Semantic analysis is performed on the text information in the preprocessed drawing image to obtain the processing technology information and technical parameter information in the drawing. The processing technology information includes the processing technology type, process steps and process requirements, and the technical parameter information includes the tolerance range and surface roughness. Based on the image recognition and semantic analysis results, machining program code is generated. First, based on the identified geometric shapes and dimension annotations, a preliminary toolpath is generated according to the toolpath planning algorithm corresponding to the mapping relationship library between drawing information and machining program code. Then, based on the dimension annotations and machining process information, initial cutting parameters are matched from the mapping relationship library, and the initial cutting parameters are adjusted according to the machining process information and technical parameter information. The adjusted cutting parameters are used to optimize the preliminary toolpath. Finally, based on the machining process information, the corresponding program instructions are called from the mapping relationship library, and the optimized toolpath and adjusted cutting parameters are used to fill the program instructions, which are then converted into the final machining program code. A semantic analysis model based on the Transformer model is used to perform semantic analysis on the text information in the preprocessed drawing image. This model includes a domain knowledge embedding layer to embed machine tool processing domain knowledge into the model. The domain knowledge embedding layer then superimposes the preprocessed word vectors with their corresponding knowledge vectors and outputs the result. The steps include: The processing technology, technical parameters, and process rules are defined as entities in the knowledge graph, and the relationships between entities are defined to construct a knowledge graph in the field of machine tool processing. The entities and relationships in the constructed knowledge graph are converted into vectors to form knowledge vectors. The knowledge vectors include term vectors formed by vector encoding the terms of processing technology and technical parameters, and rule vectors formed by vector encoding the relationships and constraints of process rules. The system receives a preprocessed sequence of text word vectors and matches the corresponding knowledge vector from the knowledge graph for each text word vector. The knowledge vector and the text word vector are then fused after being encoded separately. The fused vector sequence is then input into the Transformer encoder for semantic encoding. It also includes calculating the similarity between text word vectors and matched knowledge vectors, and dynamically adjusting the weight of knowledge vectors during the fusion process of knowledge vectors and text word vectors based on the similarity. The similarity is positively correlated with the weight of knowledge vectors. The calculation expression for fusing text word vectors and knowledge vectors is: V_fused = α×V_text + (1-α)×V_knowledge, where α is the attention weight, V_text represents the text vector, and V_knowledge represents the knowledge vector.

2. The method for automatically generating CNC machine tool machining programs according to claim 1, characterized in that, The mapping relationship library stores the mapping relationship between geometric figures and tool path planning algorithms, the mapping relationship between dimension annotation information and cutting parameters, and the mapping relationship between machining process and program instructions; The step of generating a preliminary toolpath based on the identified geometric shapes and dimension information, according to the toolpath planning algorithm in the mapping relationship library between drawing information and machining program code, includes: Based on the identified geometric shapes, a matching target toolpath planning algorithm is used to search the mapping database. Determine the origin of the coordinate system based on the reference points on the drawing obtained from image recognition; The starting points of the roughing and finishing paths are determined based on the position and size information of the geometric shapes obtained from image recognition. Based on the determined starting points of the roughing and finishing paths, the preliminary toolpaths for roughing and finishing are generated according to the target toolpath planning algorithm.

3. The method for automatically generating CNC machine tool machining programs according to claim 1, characterized in that, The cutting parameters include cutting speed and feed rate. Adjusting the initial cutting parameters based on machining process information and technical parameter information includes: adjusting the cutting speed and feed rate according to the analyzed process requirements, wherein if the analyzed process requirements include machining after heat treatment, the cutting speed and feed rate are reduced; further adjusting the feed rate according to the analyzed technical parameter information; optimizing the preliminary toolpath using the adjusted cutting parameters includes optimizing any one or more of the following: feed rate, number of roughing cycles, and tool retraction path for finishing.

4. The method for automatically generating CNC machine tool machining programs according to claim 1, characterized in that, The program instructions include a program header, a tool and compensation setting program segment, a machining cycle instruction, a finishing program segment, and a program tail code module. The program header includes a program number and coordinate system configuration instructions. The tool and compensation setting program segment includes tool selection instructions and compensation parameter configuration instructions. The machining cycle instruction includes instructions to perform tool movement according to the set toolpath. The finishing program segment is used to set the finishing path coordinates. The program tail includes program end and reset instructions.

5. The method for automatically generating CNC machine tool machining programs according to claim 1, characterized in that, In the image recognition of the preprocessed drawing image, a convolutional neural network based on multi-scale convolutional kernels is used to extract features from the preprocessed drawing image. The multi-scale convolutional kernels include horizontal line kernels, vertical line kernels, circular convolutional kernels, and multi-scale line kernels. The horizontal line kernels are used to extract horizontal lines, the vertical line kernels are used to extract vertical lines, the circular convolutional kernels are used to extract arcs, and the multi-scale line kernels are used to extract lines whose width exceeds a preset threshold. The convolutional layer of the convolutional neural network includes at least two convolutional branches, and the multi-scale convolutional kernels are respectively set in each convolutional branch to form a multi-scale convolutional branch. The outputs of each convolutional branch are fused to obtain the final feature output.

6. The method for automatically generating CNC machine tool machining programs according to claim 5, characterized in that, The pooling layer of the convolutional neural network uses an adaptive threshold to determine the pooling result, and the steps include: Calculate the pixel mean μ for each window and the corresponding threshold T = μ + a0 × (max_p - μ), where max_p represents the maximum pixel value within the window and a0 represents a preset coefficient less than 1. Determine whether there is a pixel value greater than T in each window. If it exists, take the maximum value among all pixels greater than the threshold T as the pooling result. If it does not exist, take the average value of the window as the pooling result. Record the coordinates of each pooling result in the original feature map and correlate them with the pooled feature map.

7. The method for automatically generating CNC machine tool machining programs according to any one of claims 1 to 6, characterized in that, In the image recognition of the preprocessed drawing image, feature matching branches are constructed to perform feature matching on the features extracted from the preprocessed drawing image. The feature matching branches include a geometric shape recognition branch and a dimension annotation recognition branch. The geometric shape recognition branch is used to extract the edge features, shape features, and topological relationships of the geometric shapes. The topological relationships include inclusion relationships, adjacency relationships, and intersection relationships. The extracted edge features of the geometric shapes are matched with a preset geometric shape feature library to obtain the geometric shape recognition result. The dimension annotation recognition branch is used to extract annotation line features. The annotation line features include dimension lines and dimension boundaries. Template matching is performed based on the extracted annotation line features, and character recognition is performed using a character recognition model to identify the dimension values ​​and tolerance symbols. The tolerance type is determined based on the identified tolerance symbols.

8. An automatic CNC machine tool machining program generation system, characterized in that, include: The image acquisition and preprocessing module is used to acquire images of the target part's machining drawings and perform preprocessing to obtain preprocessed drawing images. The visual recognition module is used to perform image recognition on the preprocessed drawing image, and to identify the geometric shapes and dimension annotations in the drawing; The semantic analysis module is used to perform semantic analysis on the text information in the preprocessed drawing image to obtain the processing technology information and technical parameter information in the drawing. The processing technology information includes the processing technology type, process steps and process requirements, and the technical parameter information includes the tolerance range and surface roughness. The automatic program generation module is used to generate machining program code based on image recognition and semantic analysis results. First, based on the identified geometric shapes and dimension annotations, a preliminary toolpath is generated according to the toolpath planning algorithm corresponding to the pre-built mapping relationship library. Then, based on the dimension annotations and machining process information, initial cutting parameters are matched from the mapping relationship library, and the initial cutting parameters are adjusted according to the machining process information and technical parameter information. The adjusted cutting parameters are used to optimize the preliminary toolpath. Finally, based on the machining process information, the corresponding program instructions are called from the mapping relationship library, and the optimized toolpath and adjusted cutting parameters are used to fill the program instructions, converting them into the final machining program code. In the semantic analysis module, a Transformer-based semantic analysis model is used to perform semantic analysis on the text information in the preprocessed drawing image. This Transformer-based semantic analysis model includes a domain knowledge embedding layer to embed machine tool processing domain knowledge into the model. The domain knowledge embedding layer then superimposes the preprocessed word vectors with their corresponding knowledge vectors and outputs the result, including: The processing technology, technical parameters, and process rules are defined as entities in the knowledge graph, and the relationships between entities are defined to construct a knowledge graph in the field of machine tool processing. The entities and relationships in the constructed knowledge graph are converted into vectors to form knowledge vectors. The knowledge vectors include term vectors formed by vector encoding the terms of processing technology and technical parameters, and rule vectors formed by vector encoding the relationships and constraints of process rules. The system receives a preprocessed sequence of text word vectors and matches the corresponding knowledge vector from the knowledge graph for each text word vector. The knowledge vector and the text word vector are then fused after being encoded separately. The fused vector sequence is then input into the Transformer encoder for semantic encoding. It also includes calculating the similarity between text word vectors and matched knowledge vectors, and dynamically adjusting the weight of knowledge vectors during the fusion process of knowledge vectors and text word vectors based on the similarity. The similarity is positively correlated with the weight of knowledge vectors. The calculation expression for fusing text word vectors and knowledge vectors is: V_fused = α×V_text + (1-α)×V_knowledge, where α is the attention weight, V_text represents the text vector, and V_knowledge represents the knowledge vector. Alternatively, the automatic generation system for CNC machine tool machining programs may include a processor and a memory, wherein the memory is used to store computer programs, and the processor is used to execute the computer programs to perform the method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • CAM system for automatically controlling machining center according to drawings

    CN117348524A

  • Part 3D drawing intelligent price checking method and system

    CN120258918A

  • Method and system for adjusting CAD drawing segmentation parameters in combination with region recognition

    CN120374991A