Defect detection method and system for machining surface of casting
By constructing a correlation model between machining parameters and tool mark image features, and integrating tool process parameters and image features, the problem of misjudging tool marks and defects on the machining surface of castings is solved, thereby improving inspection efficiency and economic benefits.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WEICHAI POWER CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-05-12
AI Technical Summary
Existing visual inspection systems cannot effectively distinguish between tool marks on the machined surface of castings and actual defects, resulting in a high misjudgment rate and increased production costs.
By integrating the tool process parameters and image features of the machining equipment, a correlation model between machining parameters and tool mark image features is constructed. This model is then used to analyze suspected defect areas and distinguish between tool marks and actual defects.
Accurately distinguish between tool marks and actual defects, reduce the misjudgment rate, improve inspection efficiency, reduce the number of qualified castings being discarded, and lower production costs.
Smart Images

Figure CN122023271A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to a method and system for detecting defects on the machined surface of castings. Background Technology
[0002] In modern machinery manufacturing, casting is a crucial step in producing various mechanical equipment parts. The surface quality of the finished castings directly affects the reliability and lifespan of the products. Therefore, defect detection of the machined surfaces of castings is an important process for ensuring product quality.
[0003] Among related technologies, visual image processing methods are the primary reliance. Deep learning-based surface defect detection systems are particularly common. This technology learns defect features directly from images using deep convolutional neural networks, achieving end-to-end defect detection. Its core principle is to train the model using a large amount of labeled image data, enabling the model to automatically distinguish between defects and normal surface features.
[0004] However, during the casting process, the cutting action of the machining equipment will form tool marks on the machined surface. These tool marks are normal machining traces, but they appear as regular or irregular texture features in the visual image. Existing technologies rely solely on image features for judgment, without considering key information such as tool parameters and cutting conditions during the machining process. This results in traditional visual inspection systems being unable to effectively distinguish between tool marks and actual defects, thereby reducing inspection efficiency and potentially leading to the rejection of qualified castings due to misjudgment, thus increasing production costs. Summary of the Invention
[0005] This application provides a method and system for detecting defects on the machined surfaces of castings. To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This summary is not intended as a general commentary, nor is it intended to identify key / important components or describe the scope of protection of these embodiments. Its sole purpose is to present some concepts in a simple form as a prelude to the detailed description that follows.
[0006] In a first aspect, embodiments of this application provide a method for detecting defects on the machined surface of a casting, the method comprising: During the casting process of the processing equipment based on the current tool process parameters, the image of the casting to be inspected is obtained by pre-setting an industrial camera on the processing equipment to capture the processing surface of the casting. By using a pre-set basic visual defect detection model, each suspected defect area in the image of the casting to be inspected is identified. Extract the image features of each suspected defect area, and fuse the image features with the current tool process parameters to obtain the comprehensive features of each suspected defect area; The comprehensive features are input into a pre-trained processing parameter-tool mark image feature association model, which outputs the probability that each suspected defect region is a tool mark type; suspected defect regions with a probability less than a preset tool mark judgment threshold are selected as real defect regions.
[0007] Optionally, a pre-trained machining parameter-knife mark image feature association model is generated by following these steps: Obtain the historical annotation dataset. The historical annotation dataset is generated during the casting process of the machining equipment based on the key tool process parameters of the current tool. The annotation dataset includes the images of each historical casting machining surface corresponding to the key tool process parameters of the current tool, the key tool process parameters of the current tool, and the annotation labels of each historical casting machining surface image. The images of the machined surfaces of each historical casting are preprocessed to obtain preprocessed images; The knife pattern image features of each preprocessed image are extracted to obtain the knife pattern image features of each preprocessed image; The tool mark image features of each preprocessed image are correlated and fused with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image; Based on the fused feature vectors, a pre-trained processing parameter-knife mark image feature association model is generated.
[0008] Optionally, generate a historical labeled dataset by following these steps: The current tool status and cutting conditions of the cutting tool in the processing equipment are collected as key tool process parameters for the current tool. During the casting process of the machining equipment based on the key tool process parameters of the current tool, the casting machining surface is imaged to obtain the historical casting machining surface images corresponding to the key tool process parameters of the current tool. By associating the images of the machining surfaces of historical castings corresponding to the key tool process parameters of the current tool with the key tool process parameters of the current tool, an image-parameter association dataset is obtained. The tool mark area, actual defect area, and normal area are labeled in the image-parameter association dataset of each historical casting machining surface.
[0009] Optionally, preprocessing can be performed on the images of the machined surfaces of each historical casting, including: The images of the machined surfaces of each historical casting are denoised to clarify the tool marks. The images of the machining surfaces of each historical casting after noise reduction are normalized to convert the color images into grayscale images and normalize the pixel values to the [0,1] range. Enhance the image contrast of each historical casting surface image after grayscale normalization to highlight the texture details of the tool marks.
[0010] Optionally, the knife pattern image features are extracted from each preprocessed image to obtain the knife pattern image features of each preprocessed image, including: Energy, entropy, contrast, and correlation features of each preprocessed image are extracted and used as texture features of each preprocessed image. The width, length, spacing, and direction angle of the knife marks in each preprocessed image are extracted to obtain morphological features that describe the geometric shape and distribution pattern of the knife marks. Calculate the average gray value and gray variance of each preprocessed image to obtain gray features used to characterize the depth and uniformity of the knife marks; Texture features, morphological features, and grayscale features are used as the knife-mark image features of each preprocessed image.
[0011] Optionally, the tool mark image features of each preprocessed image are correlated and fused with the key tool process parameters of the current tool to obtain a fused feature vector for each preprocessed image, including: The tool mark image features of each preprocessed image and the key tool process parameters of the current tool are vectorized to obtain the standardized vector of each image feature and the standardized vector of the machining parameters. The standardized vectors of each image feature and the standardized vectors of the processing parameters are weighted and fused to obtain the fused feature vector of each preprocessed image.
[0012] Optionally, the labels for the machined surface images of each historical casting include labels for tool mark areas and labels for non-tool mark areas; Based on the fused feature vectors, a pre-trained processing parameter-knife mark image feature association model is generated, including: The gradient boosting tree algorithm is used to construct the association model; Using the logarithmic loss function as the target loss function of the association model, a classification model is obtained; Using the fused feature vectors of each preprocessed image as input and the tool mark region labels and non-tool mark region labels of each historical casting machining surface image as output, a classification model is trained to obtain the first loss value. When the loss value of the first model reaches its minimum, a pre-trained processing parameter-knife mark image feature association model is generated.
[0013] Optionally, the labels for the machined surface images of each historical casting include labels for normal areas and labels for actual defect areas; Generate a preset basic visual defect detection model by following these steps: A basic detection model is constructed using object detection algorithms; Using images of the machined surfaces of historical castings as input, and normal area labels and actual defect area labels as output, a basic detection model is trained, and a second loss value is output. When the second loss value reaches its minimum, a preset basic visual defect detection model is generated.
[0014] Optionally, the method also includes: The actual defect area is used to perform secondary annotation on the image of the casting to be inspected, and the current annotation information is obtained; Combine the current tool process parameters, the image of the casting to be inspected, and the current annotation information into an incremental dataset; Using an incremental dataset, the preset basic visual defect detection model and the pre-trained processing parameter-knife mark image feature association model were fine-tuned.
[0015] Secondly, embodiments of this application provide a defect detection system for machined surfaces of castings, the system comprising: The image acquisition module is used to acquire images of the casting to be inspected by using an industrial camera pre-set on the processing equipment to capture the processing surface of the casting during the casting process based on the current tool process parameters. The defect area identification module is used to identify each suspected defect area in the image of the casting to be inspected by using a preset basic visual defect detection model; The feature fusion module is used to extract the image features of each suspected defect area, fuse the image features with the current tool process parameters, and obtain the comprehensive features of each suspected defect area. The real defect region screening module is used to input comprehensive features into a pre-trained processing parameter-tool mark image feature association model, and output the probability that each suspected defect region is a tool mark type; suspected defect regions with a probability less than a preset tool mark judgment threshold are selected as real defect regions.
[0016] The technical solutions provided in this application embodiment may include the following beneficial effects: In this embodiment, on the one hand, a machining parameter-tool mark image feature association model is constructed by fusing the tool process parameters of the machining equipment with image features. During the inspection process, this model is used to analyze suspected defect areas, which can accurately distinguish between tool marks and actual defects. This not only avoids misjudgments caused by tool mark interference but also significantly improves inspection efficiency. On the other hand, during the inspection process, by calculating the probability that a suspected defect area is a tool mark type and selecting areas with a probability lower than a preset threshold as actual defect areas, misjudgments of tool marks are effectively avoided. This not only reduces the rejection of qualified castings due to misjudgments but also lowers production costs and improves the economic benefits of the enterprise.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] Figure 1 This is a schematic flowchart of a defect detection method for the machined surface of a casting provided in an embodiment of this application; Figure 2 This is a system architecture diagram of a real-time scenario for defect detection on the machined surface of a casting, provided in an embodiment of this application. Figure 3 This is a schematic block diagram illustrating a defect detection process for a machined surface of a casting provided in an embodiment of this application; Figure 4 This is a flowchart illustrating a method for training a processing parameter-tool mark image feature association model according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a defect detection system for the machined surface of a casting provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] The following description and accompanying drawings fully illustrate specific embodiments of this application to enable those skilled in the art to practice them.
[0021] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0022] In the following description, when referring to the accompanying drawings, the same numbers in different drawings denote the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of systems and methods consistent with some aspects of this application as detailed in the appended claims.
[0023] In the description of this application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances. Furthermore, in the description of this application, unless otherwise stated, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.
[0024] This application provides a method and system for detecting defects on the machined surfaces of castings to address the problems existing in the aforementioned related technologies. In the embodiments of this application, on the one hand, a machining parameter-tool mark image feature association model is constructed by fusing the tool process parameters of the machining equipment with image features. During the detection process, this model is used to analyze suspected defect areas, accurately distinguishing between tool marks and actual defects. This not only avoids misjudgments caused by tool mark interference but also significantly improves detection efficiency. On the other hand, during the detection process, by calculating the probability that a suspected defect area is a tool mark type and selecting areas with a probability below a preset threshold as actual defect areas, misjudgments of tool marks are effectively avoided. This not only reduces the scrapping of qualified castings due to misjudgments but also lowers production costs and improves the economic benefits of enterprises. The following detailed description uses exemplary embodiments.
[0025] The following will be combined with the appendix Figure 1 -Appendix Figure 4 This application provides a detailed description of the defect detection method for machined surfaces of castings, as provided in the embodiments. This method can be implemented using a computer program and can run on a defect detection system for machined surfaces of castings based on the von Neumann architecture. This computer program can be integrated into applications or run as a standalone utility application.
[0026] Please see Figure 1 This is a flowchart illustrating a method for detecting defects on the machined surface of a casting, as provided in this application embodiment. Figure 1 As shown, the method in this application embodiment may include the following steps: S101, during the casting process of the processing equipment based on the current tool process parameters, the image of the casting to be inspected is obtained by pre-setting an industrial camera on the processing equipment to capture the casting surface of the processed casting; The processing equipment refers to machine tools or other mechanical processing devices used for casting processing, such as CNC lathes and milling machines. These devices perform processing operations on the castings according to preset process parameters. Current tool process parameters are the specific process parameters used by the tool during processing, including but not limited to cutting speed, feed rate, depth of cut, tool type, and tool wear. An industrial camera is a high-precision image acquisition device used for visual inspection in industrial production, capable of capturing image information during processing at high resolution and high frame rate. The casting machined surface is the surface of the casting that is processed during the machining process. After processing, this surface may exhibit features such as tool marks, cracks, and sand holes. Tool marks are normal machining traces, while cracks and sand holes are defects. The image of the casting to be inspected is an image of the casting machined surface acquired by an industrial camera.
[0027] The system architecture diagram for real-time defect detection on the machined surface of castings is shown below. Figure 2 As shown, the system architecture diagram of the real-time scenario includes casting processing equipment (1), casting (2), casting visual image acquisition module (3), industrial control computer (4), and human-machine interface (5). The industrial control computer is an industrial control computer that can collect data (processing information) from the casting processing equipment. The defect detection method of the casting processing surface can be deployed in the industrial control computer software system.
[0028] The system for acquiring data on the machined surfaces of castings includes a 13-megapixel high-definition industrial camera, an LED ring light source, a 3D vision sensor, and an Ethernet image transmission module. The acquisition frame rate is ≥30fps, and the image resolution is ≥4096×3072. During acquisition, a trigger signal is used to link with the processing equipment, ensuring accurate association (ID matching) between the image and the processing conditions. The image data is then transmitted to the data storage module for storage. The data storage module has a storage capacity of ≥10TB and supports reading, writing, querying, and backing up processing parameter datasets, image-data association datasets, labeled datasets, model files, and detection results. The data transmission rate is ≥1Gbps.
[0029] In some embodiments of this application, the user starts the processing equipment and begins processing the casting. During processing, an industrial camera pre-installed on the processing equipment captures images of the processing surface of the casting in real time. The industrial camera synchronizes with the processing equipment via a trigger signal to ensure that the captured images are accurately correlated with the current processing conditions. The captured image data is transmitted to an industrial control computer via Ethernet or other communication modules.
[0030] S102, by using a preset basic visual defect detection model, identify each suspected defect area in the image of the casting to be inspected; The preset basic visual defect detection model is a pre-trained deep learning model used to identify and locate potential defect areas in images. Trained on a large amount of labeled image data, this model automatically learns the feature differences between defects and normal areas, thus achieving preliminary defect detection. Suspected defect areas refer to regions in the image of the casting to be inspected that are preliminarily identified by the basic visual defect detection model as potentially containing defects. These areas are visually significantly different from normal areas in the image.
[0031] In some embodiments of this application, the acquired image of the casting to be inspected is input into a preset basic visual defect detection model. The model automatically extracts features from the image through a network structure. The model outputs the classification result for each pixel or region in the image, identifying regions that may contain defects. The model generates a confidence score for each suspected defect region, representing the probability that the region is a defect. The identified suspected defect regions, their location information, and confidence scores are output.
[0032] For example, the image of the casting to be inspected and current tooling process parameters Pre-set basic visual defect detection model Output a set of suspected defect areas Each suspected area Includes location information and confidence level .
[0033] S103, extract the image features of each suspected defect area, and fuse the image features with the current tool process parameters to obtain the comprehensive features of each suspected defect area; Image features are quantitative information extracted from each suspected defect area that describes the content of the image. Image features include texture features (such as the Gray-Level Co-occurrence Matrix (GLCM), morphological features (such as area, perimeter, and shape factor), and gray-level features (such as average gray value and standard deviation).
[0034] In some embodiments of this application, image features are extracted for each suspected defect region. The extracted image feature vector is standardized with the current tool process parameter vector to ensure that different types of features are on the same scale. The image features and process parameters are fused using a weighted feature concatenation method or other fusion method to obtain a comprehensive feature vector for each suspected defect region.
[0035] For example, for each Extract its image features ,and Fusion .
[0036] S104: Input the comprehensive features into the pre-trained processing parameter-tool mark image feature association model, and output the probability that each suspected defect area is a tool mark type; filter out suspected defect areas with a probability less than the preset tool mark judgment threshold as real defect areas.
[0037] The pre-trained machining parameter-tool mark image feature association model is a pre-trained machine learning model used to analyze the relationship between machining parameters and tool mark image features. This model is trained on a large amount of labeled data (including samples of tool marks and real defects), enabling it to learn how machining parameters affect tool mark formation and distinguish between tool marks and real defects. The probability of a tool mark type is the probability value output by the model for each suspected defect region belonging to the tool mark type. This probability value reflects the likelihood that the region is a tool mark, ranging from 0 to 1. A higher probability value indicates that the region is more likely to be a tool mark; a lower probability value indicates that the region is more likely to be a real defect.
[0038] In some embodiments of this application, the comprehensive feature vector of each suspected defect region is input into a pre-trained machining parameter-tool mark image feature association model. The model analyzes each comprehensive feature vector and outputs a probability value for each suspected defect region as a tool mark type. Based on a preset tool mark determination threshold, suspected defect regions with probabilities less than the threshold are selected. These regions are considered as real defect regions. The location and related information of the selected real defect regions are output.
[0039] For example, get Then, the pre-trained machining parameters-tool mark image feature association model is input. Probability of obtaining knife pattern Set the threshold T for determining the blade pattern. The optimal value is determined through validation set optimization. Integrate all areas identified as "actual defects" and output the final defect detection result. It includes information such as defect type, location, and size.
[0040] In some embodiments of this application, the specific process of generating a pre-trained machining parameter-tool mark image feature association model includes: acquiring a historical annotation dataset, which is generated during the casting process of the machining equipment based on the key tool process parameters of the current tool. The annotation dataset includes images of each historical casting machining surface corresponding to the key tool process parameters of the current tool, the key tool process parameters of the current tool, and the annotation labels of each historical casting machining surface image; preprocessing each historical casting machining surface image to obtain each preprocessed image; extracting tool mark image features from each preprocessed image to obtain tool mark image features of each preprocessed image; fusing the tool mark image features of each preprocessed image with the key tool process parameters of the current tool to obtain a fused feature vector of each preprocessed image; and generating a pre-trained machining parameter-tool mark image feature association model based on the fused feature vector.
[0041] The labels on the machined surface images of each historical casting include labels for tool marks and labels for non-tool mark areas.
[0042] Specifically, the process of generating a pre-trained machining parameter-tool mark image feature association model based on fused feature vectors includes: constructing an association model using a gradient boosting tree algorithm; using the logarithmic loss function as the target loss function of the association model to obtain a classification model; training the classification model with the fused feature vectors of each preprocessed image as input and the tool mark region labels and non-tool mark region labels of each historical casting machining surface image as output to obtain a first loss value; and generating a pre-trained machining parameter-tool mark image feature association model when the first model loss value reaches its minimum.
[0043] The labels on the machined surface images of each historical casting include labels for normal areas and labels for actual defective areas.
[0044] In some embodiments of this application, the specific process of generating a preset basic visual defect detection model includes: constructing a basic detection model using a target detection algorithm; training the basic detection model with images of the machining surfaces of each historical casting as input and normal area labels and actual defect area labels as output, and outputting a second loss value; and generating a preset basic visual defect detection model when the second loss value reaches its minimum.
[0045] For example Figure 3 As shown, Figure 3This application provides a schematic flowchart of a defect detection process for the machined surface of a casting. First, the visual image acquisition module and the machining information acquisition module acquire image data of the machined surface of the casting and key information of the machining process, respectively. Then, the image processing unit preprocesses the image, and the data fusion analysis unit fuses the image features with the machining parameters. Next, the basic visual defect detection model identifies suspected defect areas, and the intelligent decision-making unit further analyzes these areas to determine whether they are tool marks. Finally, the detection results are output through the human-computer interaction interface, and the relevant data is stored for subsequent use.
[0046] Furthermore, in real-world scenarios, it is also necessary to fine-tune the preset basic visual defect detection model and the pre-trained machining parameter-tool mark image feature association model based on real-time data. Specifically, this includes: using real defect areas to perform secondary annotation on the image of the casting to be inspected to obtain the current annotation information; combining the current tool process parameters, the image of the casting to be inspected, and the current annotation information into an incremental dataset; and using the incremental dataset to fine-tune the preset basic visual defect detection model and the pre-trained machining parameter-tool mark image feature association model.
[0047] Specifically, new current tooling process parameters are collected in real time. Image of the casting to be inspected and current annotation information Build an incremental dataset .
[0048] Specifically, an incremental learning algorithm is used to refine the pre-trained machining parameter-tool mark image feature association model. and preset basic visual defect detection model Fine-tuning is performed, and a weight decay factor is used during the fine-tuning process. , To prevent overfitting, the model parameter update formula is: in, in, Let be the model parameters for the t-th iteration. For learning rate , This represents the gradient of the loss function. The model adapts to changes in processing conditions through periodic fine-tuning (e.g., every 1000 incremental data points).
[0049] In this embodiment, on the one hand, a machining parameter-tool mark image feature association model is constructed by fusing the tool process parameters of the machining equipment with image features. During the inspection process, this model is used to analyze suspected defect areas, which can accurately distinguish between tool marks and actual defects. This not only avoids misjudgments caused by tool mark interference but also significantly improves inspection efficiency. On the other hand, during the inspection process, by calculating the probability that a suspected defect area is a tool mark type and selecting areas with a probability lower than a preset threshold as actual defect areas, misjudgments of tool marks are effectively avoided. This not only reduces the rejection of qualified castings due to misjudgments but also lowers production costs and improves the economic benefits of the enterprise.
[0050] Please see Figure 4 This is a flowchart illustrating a method for training a processing parameter-tool mark image feature association model, as provided in this application embodiment. Figure 4 As shown, the method in this application embodiment may include the following steps: S201, Obtain the historical annotation dataset. The historical annotation dataset is generated during the casting process of the machining equipment based on the key tool process parameters of the current tool. The annotation dataset includes the images of each historical casting machining surface corresponding to the key tool process parameters of the current tool, the key tool process parameters of the current tool, and the annotation labels of each historical casting machining surface image. In some embodiments of this application, the specific process of generating a historical annotation dataset includes: collecting the tool state and cutting conditions of the current tool in the processing equipment as key tool process parameters of the current tool; during the casting processing process of the processing equipment based on the key tool process parameters of the current tool, acquiring images of the casting surface of the processed casting to obtain images of each historical casting surface corresponding to the key tool process parameters of the current tool; associating each historical casting surface image corresponding to the key tool process parameters of the current tool with the key tool process parameters of the current tool to obtain an image-parameter association dataset; and annotating the tool mark area, actual defect area, and normal area of each historical casting surface image in the image-parameter association dataset to obtain an annotation dataset.
[0051] Specifically, key process parameters that determine the tool mark pattern are collected from the machining equipment. These parameters include: tool condition: tool type (e.g., end mill, face mill) and wear level; cutting conditions: cutting speed, feed rate, depth of cut, and spindle speed. These parameters are organized into a structured dataset, and a unique machining condition identifier (ID) is assigned to each specific combination of parameters. For example, tool type (e.g., end mill, face mill, ball end mill, etc.) is mapped to quantized values through encoding. (n is the total number of tool types), tool wear degree (wear amount W collected by tool wear sensor, unit: mm), cutting speed (Unit: m / min) Feed rate (Unit: mm / r) Depth of cut (Unit: mm) Spindle speed (Unit: r / min) and other key parameters; the collected processing parameters are organized into a structured parameter dataset. ,in It serves as a unique identifier for processing conditions.
[0052] Specifically, under the corresponding processing conditions, images of the casting processing surface are acquired using visual inspection equipment (such as high-definition industrial cameras and 3D vision sensors). The images must cover the entire processing surface, and the image resolution and lighting conditions must be consistent. At the same time, a corresponding processing condition identifier is associated with each image data. To form an image-parameter association dataset ,in This is image data.
[0053] Specifically, image data I is annotated, including: knife-mark areas (marking the location, shape, texture density, and other features of the knife marks), actual defect areas (marking the defect type, such as cracks, pinholes, dents, etc., and the location and size of the defects), and normal areas without knife marks or defects, forming an annotated dataset. , where L is the label (L=0 represents the normal area, L=1 represents the tool mark area, and L=2 represents the actual defect area).
[0054] S202, preprocess the images of the machined surfaces of each historical casting to obtain each preprocessed image; In some embodiments of this application, the specific process of preprocessing the images of the machined surfaces of each historical casting includes: denoising the images of the machined surfaces of each historical casting to clarify the outline of the tool marks; normalizing the grayscale of the denoised images of the machined surfaces of each historical casting to convert the color image into a grayscale image and normalize the pixel values to the [0,1] range; and enhancing the image contrast of the normalized images of the machined surfaces of each historical casting to highlight the texture details of the tool marks.
[0055] Specifically, the denoising process uses a Gaussian filtering algorithm to suppress image noise, with a filter kernel size of [size missing]. (k takes an odd number, preferred) or The Gaussian filtering formula is: ; in, is the Gaussian standard deviation (range 0.5-2.0), and (x,y) are the pixel coordinates within the filter kernel.
[0056] Specifically, the grayscale normalization process uses the following formula:
[0057] in, These are the pixel values of the original grayscale image. , These are the minimum and maximum grayscale values of the grayscale image, respectively. The normalized gray value (range [0,1]).
[0058] Specifically, the image contrast is enhanced by using a histogram equalization algorithm to improve the recognizability of knife-mark features.
[0059] S203, extract the knife pattern image features of each preprocessed image to obtain the knife pattern image features of each preprocessed image; In some embodiments of this application, the specific process of extracting knife pattern image features from each preprocessed image to obtain the knife pattern image features of each preprocessed image includes: extracting the energy, entropy, contrast, and correlation features of each preprocessed image as the texture features of each preprocessed image; extracting the width, length, spacing, and direction angle of the knife patterns in each preprocessed image to obtain morphological features used to describe the geometric shape and distribution pattern of the knife patterns; calculating the average gray value and gray variance of each preprocessed image to obtain gray features used to characterize the depth and uniformity of the knife patterns; and using the texture features, morphological features, and gray features as the knife pattern image features of each preprocessed image.
[0060] Specifically, during texture feature extraction, the Gray-Level Co-occurrence Matrix (GLCM) is used to extract four features: energy, entropy, contrast, and correlation. The GLCM is defined as follows: ; Where i,j are gray levels, and d is the pixel spacing. For the angle (take) , , , ), } represents the number of pixel pairs that meet the conditions; the formulas for calculating energy E, entropy Ent, contrast Con, and correlation Corr based on GLCM are as follows:
[0061]
[0062]
[0063]
[0064] Where L is the number of gray levels. Minimum value (avoid) ), , They are respectively , The mean, , They are respectively , The standard deviation.
[0065] Specifically, during morphological feature extraction, the width of the knife marks is extracted. ,length ,spacing , Direction Angle It was obtained through morphological skeleton extraction and distance transformation algorithms.
[0066] Specifically, during grayscale feature extraction, the average grayscale value of the knife-mark region is extracted. Gray-scale variance The calculation formula is: ; ; in, The set of pixels representing the knife-mark area. for Number of pixels.
[0067] S204, The tool pattern image features of each preprocessed image are correlated and fused with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image; In some embodiments of this application, the specific process of fusing the tool pattern image features of each preprocessed image with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image includes: performing vector standardization processing on the tool pattern image features of each preprocessed image and the key tool process parameters of the current tool to obtain the standardized vector of each image feature and the standardized vector of the processing parameters; and performing weighted fusion on the standardized vector of each image feature and the standardized vector of the processing parameters to obtain the fused feature vector of each preprocessed image.
[0068] Specifically, the knife-mark image features of each preprocessed image will be analyzed: Key tooling process parameters corresponding to the current tool After standardization, a weighted feature concatenation method is used to fuse the features, constructing a fused feature vector F, as shown in the formula: ; in, , These are the standardized vectors of image features and processing parameters, respectively (using Z-score standardization). , For feature weights ( Determined through cross-validation , ).
[0069] S205 generates a pre-trained processing parameter-knife mark image feature association model based on fused feature vectors.
[0070] The labels on the machined surface images of each historical casting include labels for tool marks and labels for non-tool mark areas.
[0071] In some embodiments of this application, the specific process of generating a pre-trained machining parameter-tool mark image feature association model based on the fused feature vector includes: constructing an association model using a gradient boosting tree algorithm; using the logarithmic loss function as the target loss function of the association model to obtain a classification model; training the classification model with the fused feature vector of each preprocessed image as input and the tool mark region label and non-tool mark region label of each historical casting machining surface image as output to obtain a first loss value; and generating a pre-trained machining parameter-tool mark image feature association model when the first model loss value reaches its minimum.
[0072] Specifically, using the fused feature vector F as input and the knife mark recognition label Y (Y=1 represents the knife mark region, Y=0 represents the non-knife mark region) as output, the gradient boosting tree (GBRT) algorithm is used to construct the association model. The model uses a logarithmic loss function:
[0073] in, This represents the model's predicted probability for the k-th sample (whether it is a knife-mark region). Given the sample size; the loss function is minimized using gradient descent to update the model parameters, resulting in the trained processing parameters - knife mark image feature association model. .
[0074] The labels on the machined surface images of each historical casting include labels for normal areas and labels for actual defective areas.
[0075] In some embodiments of this application, the specific process of generating a preset basic visual defect detection model includes: constructing a basic detection model using a target detection algorithm; training the basic detection model with images of the machining surfaces of each historical casting as input and normal area labels and actual defect area labels as output, and outputting a second loss value; and generating a preset basic visual defect detection model when the second loss value reaches its minimum.
[0076] Specifically, a YOLOv8-based object detection algorithm was selected as the basic detection model. The basic detection model was initialized and trained using a labeled dataset. The training objective is to optimize the defect recognition accuracy of the model by using image data with L=0 (normal region) and L=2 (actual defect region). The model output is the location coordinates of the suspected defect region. Confidence level of defect type .
[0077] In this embodiment, on the one hand, a machining parameter-tool mark image feature association model is constructed by fusing the tool process parameters of the machining equipment with image features. During the inspection process, this model is used to analyze suspected defect areas, which can accurately distinguish between tool marks and actual defects. This not only avoids misjudgments caused by tool mark interference but also significantly improves inspection efficiency. On the other hand, during the inspection process, by calculating the probability that a suspected defect area is a tool mark type and selecting areas with a probability lower than a preset threshold as actual defect areas, misjudgments of tool marks are effectively avoided. This not only reduces the rejection of qualified castings due to misjudgments but also lowers production costs and improves the economic benefits of the enterprise.
[0078] The following are system embodiments of this application, which can be used to execute the method embodiments of this application. For details not disclosed in the system embodiments of this application, please refer to the method embodiments of this application.
[0079] Please see Figure 5 This illustration shows a schematic diagram of a defect detection system for the machined surface of a casting provided in an exemplary embodiment of this application. This defect detection system can be implemented as all or part of an electronic device through software, hardware, or a combination of both. The system 1 includes an image acquisition module 10, a defect area recognition module 20, a feature fusion module 30, and a real defect area screening module 40.
[0080] Image acquisition module 10 is used to acquire the image of the casting to be inspected by acquiring the casting surface of the casting processed by the industrial camera of the processing equipment during the casting processing based on the current tool process parameters. The defect area identification module 20 is used to identify each suspected defect area in the image of the casting to be inspected by using a preset basic visual defect detection model; The feature fusion module 30 is used to extract the image features of each suspected defect area, fuse the image features with the current tool process parameters, and obtain the comprehensive features of each suspected defect area. The real defect region screening module 40 is used to input comprehensive features into a pre-trained processing parameter-tool pattern image feature association model and output the probability that each suspected defect region is a tool pattern type; suspected defect regions with a probability less than a preset tool pattern judgment threshold are selected as real defect regions.
[0081] It should be noted that the defect detection system for machined casting surfaces provided in the above embodiments is only illustrated by the division of the above functional modules when executing the defect detection method for machined casting surfaces. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the electronic device can be divided into different functional modules to complete all or part of the functions described above. In addition, the defect detection system for machined casting surfaces and the defect detection method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.
[0082] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0083] In this embodiment, on the one hand, a machining parameter-tool mark image feature association model is constructed by fusing the tool process parameters of the machining equipment with image features. During the inspection process, this model is used to analyze suspected defect areas, which can accurately distinguish between tool marks and actual defects. This not only avoids misjudgments caused by tool mark interference but also significantly improves inspection efficiency. On the other hand, during the inspection process, by calculating the probability that a suspected defect area is a tool mark type and selecting areas with a probability lower than a preset threshold as actual defect areas, misjudgments of tool marks are effectively avoided. This not only reduces the rejection of qualified castings due to misjudgments but also lowers production costs and improves the economic benefits of the enterprise.
[0084] This application also provides a computer-readable medium having program instructions stored thereon, which, when executed by a processor, implement the defect detection method for the machined surface of a casting provided in the above-described method embodiments.
[0085] This application also provides a computer program product containing instructions that, when run on a computer, causes the computer to execute the defect detection method for the machined surface of a casting according to the various method embodiments described above.
[0086] Please see Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6 As shown, the electronic device 1000 may include: at least one processor 1001, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002.
[0087] The communication bus 1002 is used to realize the connection and communication between these components.
[0088] The user interface 1003 may include a display screen and a camera. Optionally, the user interface 1003 may also include a standard wired interface and a wireless interface.
[0089] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0090] The processor 1001 may include one or more processing cores. The processor 1001 connects to various parts within the electronic device 1000 using various interfaces and lines. It executes various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 1005, and by calling data stored in the memory 1005. Optionally, the processor 1001 may be implemented using at least one hardware form selected from Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), and Programmable Logic Array (PLA). The processor 1001 may integrate one or more of the following: a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), and a modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content to be displayed on the screen; and the modem handles wireless communication. It is understood that the modem may also be implemented as a separate chip, without being integrated into the processor 1001.
[0091] The memory 1005 may include random access memory (RAM) or read-only memory. Optionally, the memory 1005 may include a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, code, code sets, or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 1005 may also be at least one storage system located remotely from the aforementioned processor 1001. Figure 6 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a defect detection application for the machined surface of the casting.
[0092] exist Figure 6 In the illustrated electronic device 1000, the user interface 1003 is mainly used to provide an input interface for the user and to acquire user input data; while the processor 1001 can be used to call the defect detection application for the machined surface of the casting stored in the memory 1005, and specifically perform the following operations: During the casting process of the processing equipment based on the current tool process parameters, the image of the casting to be inspected is obtained by pre-setting an industrial camera on the processing equipment to capture the processing surface of the casting. By using a pre-set basic visual defect detection model, each suspected defect area in the image of the casting to be inspected is identified. Extract the image features of each suspected defect area, and fuse the image features with the current tool process parameters to obtain the comprehensive features of each suspected defect area; The comprehensive features are input into a pre-trained processing parameter-tool mark image feature association model, which outputs the probability that each suspected defect region is a tool mark type; suspected defect regions with a probability less than a preset tool mark judgment threshold are selected as real defect regions.
[0093] In one embodiment, when the processor 1001 executes the generation of a pre-trained machining parameter-knife mark image feature association model, it specifically performs the following operations: Obtain the historical annotation dataset. The historical annotation dataset is generated during the casting process of the machining equipment based on the key tool process parameters of the current tool. The annotation dataset includes the images of each historical casting machining surface corresponding to the key tool process parameters of the current tool, the key tool process parameters of the current tool, and the annotation labels of each historical casting machining surface image. The images of the machined surfaces of each historical casting are preprocessed to obtain preprocessed images; The knife pattern image features of each preprocessed image are extracted to obtain the knife pattern image features of each preprocessed image; The tool mark image features of each preprocessed image are correlated and fused with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image; Based on the fused feature vectors, a pre-trained processing parameter-knife mark image feature association model is generated.
[0094] In one embodiment, when the processor 1001 generates the historical labeled dataset, it performs the following operations: The current tool status and cutting conditions of the cutting tool in the processing equipment are collected as key tool process parameters for the current tool. During the casting process of the machining equipment based on the key tool process parameters of the current tool, the casting machining surface is imaged to obtain the historical casting machining surface images corresponding to the key tool process parameters of the current tool. By associating the images of the machining surfaces of historical castings corresponding to the key tool process parameters of the current tool with the key tool process parameters of the current tool, an image-parameter association dataset is obtained. The tool mark area, actual defect area, and normal area are labeled in the image-parameter association dataset of each historical casting machining surface.
[0095] In one embodiment, when the processor 1001 performs preprocessing on the images of the machined surfaces of each historical casting, it specifically performs the following operations: The images of the machined surfaces of each historical casting are denoised to clarify the tool marks. The images of the machining surfaces of each historical casting after noise reduction are normalized to convert the color images into grayscale images and normalize the pixel values to the [0,1] range. Enhance the image contrast of each historical casting surface image after grayscale normalization to highlight the texture details of the tool marks.
[0096] In one embodiment, when the processor 1001 extracts the knife pattern image features of each preprocessed image to obtain the knife pattern image features of each preprocessed image, it specifically performs the following operations: Energy, entropy, contrast, and correlation features of each preprocessed image are extracted and used as texture features of each preprocessed image. The width, length, spacing, and direction angle of the knife marks in each preprocessed image are extracted to obtain morphological features that describe the geometric shape and distribution pattern of the knife marks. Calculate the average gray value and gray variance of each preprocessed image to obtain gray features used to characterize the depth and uniformity of the knife marks; Texture features, morphological features, and grayscale features are used as the knife-mark image features of each preprocessed image.
[0097] In one embodiment, when the processor 1001 performs feature fusion by associating the tool mark image features of each preprocessed image with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image, the processor 1001 specifically performs the following operations: The tool mark image features of each preprocessed image and the key tool process parameters of the current tool are vectorized to obtain the standardized vector of each image feature and the standardized vector of the machining parameters. The standardized vectors of each image feature and the standardized vectors of the processing parameters are weighted and fused to obtain the fused feature vector of each preprocessed image.
[0098] In one embodiment, when the processor 1001 executes a pre-trained processing parameter-knife mark image feature association model based on fused feature vectors, it specifically performs the following operations: The gradient boosting tree algorithm is used to construct the association model; Using the logarithmic loss function as the target loss function of the association model, a classification model is obtained; Using the fused feature vectors of each preprocessed image as input and the tool mark region labels and non-tool mark region labels of each historical casting machining surface image as output, a classification model is trained to obtain the first loss value. When the loss value of the first model reaches its minimum, a pre-trained processing parameter-knife mark image feature association model is generated.
[0099] In one embodiment, when the processor 1001 generates a preset basic visual defect detection model, it specifically performs the following operations: A basic detection model is constructed using object detection algorithms; Using images of the machined surfaces of historical castings as input, and normal area labels and actual defect area labels as output, a basic detection model is trained, and a second loss value is output. When the second loss value reaches its minimum, a preset basic visual defect detection model is generated.
[0100] In one embodiment, the processor 1001 also performs the following operations: The actual defect area is used to perform secondary annotation on the image of the casting to be inspected, and the current annotation information is obtained; Combine the current tool process parameters, the image of the casting to be inspected, and the current annotation information into an incremental dataset; Using an incremental dataset, the preset basic visual defect detection model and the pre-trained processing parameter-knife mark image feature association model were fine-tuned.
[0101] In this embodiment, on the one hand, a machining parameter-tool mark image feature association model is constructed by fusing the tool process parameters of the machining equipment with image features. During the inspection process, this model is used to analyze suspected defect areas, which can accurately distinguish between tool marks and actual defects. This not only avoids misjudgments caused by tool mark interference but also significantly improves inspection efficiency. On the other hand, during the inspection process, by calculating the probability that a suspected defect area is a tool mark type and selecting areas with a probability lower than a preset threshold as actual defect areas, misjudgments of tool marks are effectively avoided. This not only reduces the rejection of qualified castings due to misjudgments but also lowers production costs and improves the economic benefits of the enterprise.
[0102] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program for detecting defects on the machined surface of castings can be stored in a computer-readable storage medium. When executed, the program can include the processes of the embodiments of the above methods. The storage medium for the program for detecting defects on the machined surface of castings can be a magnetic disk, optical disk, read-only memory, or random access memory, etc.
[0103] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A method for detecting defects on the machined surface of a casting, characterized in that, The method includes: During the casting process of the processing equipment based on the current tool process parameters, the processing surface of the casting is captured by the industrial camera preset on the processing equipment to obtain the image of the casting to be inspected; By using a preset basic visual defect detection model, each suspected defect area in the image of the casting to be inspected is identified. Extract the image features of each suspected defect area, and fuse the image features with the current tool process parameters to obtain the comprehensive features of each suspected defect area; The comprehensive features are input into a pre-trained processing parameter-tool mark image feature association model, which outputs the probability that each suspected defect region is a tool mark type; suspected defect regions with a probability less than a preset tool mark determination threshold are selected as real defect regions.
2. The method according to claim 1, characterized in that, Generate a pre-trained machining parameter-knife mark image feature association model according to the following steps: Obtain a historical annotation dataset, which is generated during the casting process of the machining equipment based on the key tool process parameters of the current tool. The annotation dataset includes images of each historical casting machining surface corresponding to the key tool process parameters of the current tool, the key tool process parameters of the current tool, and annotation labels of each historical casting machining surface image. The images of the machined surfaces of each historical casting are preprocessed to obtain preprocessed images; The knife pattern image features of each preprocessed image are extracted to obtain the knife pattern image features of each preprocessed image; The tool mark image features of each preprocessed image are correlated and fused with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image; Based on the fused feature vector, a pre-trained processing parameter-knife mark image feature association model is generated.
3. The method according to claim 2, characterized in that, To generate a historical labeled dataset, follow these steps: The tool status and cutting conditions of the current tool in the processing equipment are collected as key tool process parameters for the current tool. During the casting process of the processing equipment based on the key tool process parameters of the current tool, the casting surface of the processed casting is imaged to obtain images of each historical casting surface corresponding to the key tool process parameters of the current tool. The key tool process parameters of the current tool are associated with the historical casting machining surface images corresponding to each tool process parameter to obtain an image-parameter association dataset. The tool mark area, actual defect area, and normal area are labeled in the image-parameter association dataset for each historical casting machining surface image to obtain the labeled dataset.
4. The method according to claim 2, characterized in that, The preprocessing of the machined surface images of each historical casting includes: The images of the machined surfaces of each historical casting are subjected to noise reduction processing to clarify the tool marks. The images of the machining surfaces of each historical casting after noise reduction are normalized to convert the color images into grayscale images and normalize the pixel values to the [0,1] range. Enhance the image contrast of each historical casting surface image after grayscale normalization to highlight the texture details of the tool marks.
5. The method according to claim 2, characterized in that, The step of extracting knife pattern image features from each preprocessed image to obtain the knife pattern image features of each preprocessed image includes: The energy, entropy, contrast, and correlation features of each preprocessed image are extracted and used as the texture features of each preprocessed image. The width, length, spacing, and orientation angle of the knife marks in each preprocessed image are extracted to obtain morphological features that describe the geometric shape and distribution pattern of the knife marks. The average gray value and gray variance of each preprocessed image are calculated to obtain gray features used to characterize the depth and uniformity of the knife marks. The texture features, morphological features, and grayscale features are used as the knife-mark image features of each preprocessed image.
6. The method according to claim 2, characterized in that, The step of fusing the tool mark image features of each preprocessed image with the key tool process parameters of the current tool to obtain the fused feature vector of each preprocessed image includes: The tool mark image features of each preprocessed image and the key tool process parameters of the current tool are vectorized to obtain the standardized vectors of each image feature and the standardized vectors of the processing parameters. The standardized vectors of the image features and the standardized vectors of the processing parameters are weighted and fused to obtain the fused feature vectors of the preprocessed images.
7. The method according to claim 2, characterized in that, The labels on the processed surface images of each historical casting include labels for tool mark areas and labels for non-tool mark areas; The step of generating a pre-trained processing parameter-knife mark image feature association model based on the fused feature vector includes: The gradient boosting tree algorithm is used to construct the association model; Using the logarithmic loss function as the target loss function of the association model, a classification model is obtained; Using the fused feature vectors of each preprocessed image as input and the tool mark region labels and non-tool mark region labels of each historical casting machining surface image as output, a classification model is trained to obtain the first loss value; When the loss value of the first model reaches its minimum, a pre-trained processing parameter-knife mark image feature association model is generated.
8. The method according to claim 2, characterized in that, The labels on the processed surface images of each historical casting include labels for normal areas and labels for actual defective areas; Generate a preset basic visual defect detection model by following these steps: A basic detection model is constructed using object detection algorithms; Using the images of the machined surfaces of each historical casting as input, and the labels of normal areas and actual defect areas as output, the basic detection model is trained, and a second loss value is output. When the second loss value reaches its minimum, a preset basic visual defect detection model is generated.
9. The method according to claim 1, characterized in that, The method further includes: The image of the casting to be inspected is annotated again using the actual defect area to obtain the current annotation information; The current tool process parameters, the image of the casting to be inspected, and the current annotation information are combined into an incremental dataset; Using the incremental dataset, the preset basic visual defect detection model and the pre-trained processing parameter-knife mark image feature association model are fine-tuned.
10. A defect detection system for machined surfaces of castings, characterized in that, The system includes: The image acquisition module is used to acquire images of the casting surface of the casting during the casting process based on the current tool process parameters by using an industrial camera preset on the processing equipment; The defect area identification module is used to identify each suspected defect area in the image of the casting to be inspected by using a preset basic visual defect detection model; The feature fusion module is used to extract image features of each suspected defect area, fuse the image features with the current tool process parameters, and obtain the comprehensive features of each suspected defect area. The real defect region screening module is used to input the comprehensive features into a pre-trained processing parameter-tool mark image feature association model, output the probability that each suspected defect region is a tool mark type, and screen the suspected defect regions with the probability less than a preset tool mark judgment threshold as real defect regions.