Numerical control lathe tool wear real-time detection method and system based on machine vision
By integrating structural consistency factor, phase consistency and path consistency evaluation, and using Bayesian theory to calculate the final boundary probability, the problem of misjudgment and missed detection in wear profile detection under complex CNC lathe environments is solved, and high-precision wear detection is achieved.
Patent Information
- Application Number
- CN202511676192.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-17
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-11-17
AI Technical Summary
Existing edge detection algorithms based on image gradients are prone to misjudging interference and missing weak signal edges in the complex machining environment of CNC lathes, resulting in abnormal wear contours and inaccurate detection results.
The gradient magnitude is nonlinearly modulated by calculating the structural consistency factor and phase consistency. Combined with the path consistency integral of the exploration path, the initial boundary probability and path consistency score are integrated, and the final boundary probability is calculated using Bayesian theory to extract the wear profile.
In environments with strong interference such as coolant and metal chips, high-precision and robust real-time extraction of tool wear profiles was achieved, improving the accuracy and reliability of wear detection.
Smart Images

Figure CN121120656A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for real-time detection of tool wear on CNC lathes based on machine vision. Background Technology
[0002] CNC lathes play a crucial role in modern manufacturing, with their machining accuracy and efficiency directly impacting product quality. During cutting, lathe tools inevitably wear due to intense friction, high pressure, and high temperature. Real-time detection of tool wear is key to ensuring machining quality, extending tool life, and preventing equipment damage. Machine vision-based inspection technology has become a research hotspot due to its non-contact and high-efficiency advantages. Its core principle is to accurately segment wear areas through image processing, laying the foundation for subsequent evaluation.
[0003] In real CNC machining environments, coolant reflection, metal chip adhesion, oil interference, and unstable lighting can cause a large number of false edges and strong noise in tool images. It can also lead to blurred, discontinuous, or even partially obscured true wear boundaries. Clearly distinguishing the wear area from the tool substrate is the core prerequisite for achieving accurate detection.
[0004] In related technologies, edge detection algorithms based on image gradients, such as Canny and Sobel, are used to extract wear contours. The core of this approach is to calculate the pixel grayscale change rate, set a threshold to filter edge points, and then perform post-processing to form the wear contour, laying the foundation for wear assessment. However, in the complex environment of CNC machining, high-grayscale interference blocks formed by coolant reflection and chip adhesion are easily misjudged as true boundaries. Fluctuations in lighting and oil stains weaken grayscale differences, leading to missed detection of weak signal edges and causing contour breaks and deviations. This directly affects the accuracy of calculating parameters such as wear area, resulting in large deviations from reality and making it difficult to use as a reliable basis for tool replacement. Summary of the Invention
[0005] To address the technical problems of insufficient robustness of the aforementioned edge detection algorithms based on image gradients, which are prone to misjudging interference and missing weak signal edges in complex processing environments, resulting in abnormal wear contours and inaccurate detection results, this invention provides solutions in the following aspects.
[0006] In a first aspect, the present invention provides a machine vision-based method for real-time detection of tool wear on CNC lathes, the method comprising the steps of: Images of CNC lathe tools are acquired, and regions of interest (ROIs) are located. For each pixel within the ROI, a structural consistency factor characterizing its local structural anisotropy is calculated. This structural consistency factor is positively correlated with the difference between the maximum and minimum eigenvalues of the structural tensor in the pixel's neighborhood. Based on the structural consistency factor and the pixel's phase consistency, its gradient magnitude is nonlinearly modulated. Combined with the nonlinear amplification of the phase consistency, the initial boundary probability of the pixel is calculated. For each pixel within the ROI, an exploration path is constructed that passes through the pixel and extends along its local boundary direction. Based on the integral of the exploration path with respect to the product of the initial boundary probability and a preset weight, the path consistency score of the pixel is calculated. The initial boundary probability and the path consistency score of the pixel are fused to obtain the final boundary probability of the pixel. Wear contours are extracted based on the final boundary probabilities of each pixel within the ROI, and the tool wear state is evaluated based on the wear contours to achieve real-time detection.
[0007] This invention targets pixels within the region of interest (ROI) of a tool image, fusing their gradient magnitude, phase consistency, and local structural anisotropy to calculate initial boundary probabilities. By constructing an exploration path and weighting the initial boundary probabilities along it, path consistency is evaluated, effectively distinguishing true wear contours from noise. Finally, the initial boundary probabilities and path consistency scores are fused to obtain the final boundary probability, which is used to extract the wear contour and assess the tool wear state. This invention, by fusing initial boundary probabilities based on local features and path consistency scores based on macroscopic continuity, effectively distinguishes true wear contours from isolated pseudo-edges caused by coolant reflections, metal chips, etc., solving the technical problems of insufficient robustness and misjudging noise as boundaries in complex machining environments, thus improving the overall accuracy and reliability of wear detection.
[0008] Preferably, the initial boundary probabilities satisfy the following relationship: ; in, It is a pixel. The initial boundary probability; It is a pixel. The gradient magnitude; It is a pixel. Phase consistency value; It is a pixel. structural consistency factor, It is a standard normalized function; It is the hyperbolic tangent function.
[0009] This invention employs nonlinear modulation of the gradient magnitude via an exponential term, significantly enhancing it only when the gradient information is reliable and the structural information is evident. Simultaneously, it uses a hyperbolic tangent term to nonlinearly amplify phase consistency, compensating for signals at low-contrast true boundaries. This mechanism ensures high response for both high-confidence sharp boundaries and low-contrast true boundaries, achieving comprehensive enhancement of various boundary signals.
[0010] Preferably, obtaining the structural consistency factor includes: calculating the structural tensor within the neighborhood window of the pixel; performing eigenvalue decomposition on the structural tensor to obtain the maximum eigenvalue and the minimum eigenvalue; and recording the ratio of the difference between the maximum eigenvalue and the minimum eigenvalue to the sum as the structural consistency factor.
[0011] This invention provides a reliable evaluation index for gradient information in the neighborhood of a pixel by calculating the normalized difference of the eigenvalues of the structural tensor. This factor can effectively distinguish between real edges with a consistent direction and noisy or flat regions with disordered gradient directions, thus providing a key basis for subsequent probabilistic fusion.
[0012] Preferably, the step of constructing an exploration path that passes through each pixel in the region of interest and extends along its local boundary direction includes: determining the feature vector of the minimum eigenvalue corresponding to the structural tensor of the pixel, using the direction of the feature vector as the initial extension direction of the exploration path; starting from the pixel, performing pixel-by-pixel iterative tracking along the initial extension direction, and updating the forward direction according to the local boundary direction of each tracking node until the path length reaches a preset maximum exploration distance, thereby generating the exploration path.
[0013] This invention determines the initial extension direction of the path by using the eigenvector of the minimum eigenvalue of the structural tensor, ensuring that the exploration path follows the optimal tangent direction of the local boundary from the beginning, thus guaranteeing the accuracy of tracking. Subsequent iterative tracking and direction update mechanisms enable the path to more accurately conform to the actual direction of the boundary, providing a high-quality path foundation for path consistency evaluation.
[0014] Preferably, obtaining the preset weight includes: obtaining the directional deviation between the local boundary direction of any pixel on the exploration path and the initial extension direction of the exploration path; calculating the normalized value of the square of the directional deviation and performing a negative exponentiation operation on it to obtain the preset weight.
[0015] Preferably, the step of fusing the initial boundary probability and the path consistency score of the pixel to obtain the final boundary probability of the pixel includes: fusing the initial boundary probability and the path consistency score based on Bayesian theory to obtain the final boundary probability.
[0016] Preferably, the final boundary probability satisfies the following relationship: ; in, It is a pixel. The final boundary probability; It is a pixel. The initial boundary probability; It is a pixel. Path consistency score; It is a preset micro value.
[0017] This invention calculates the final boundary probability based on Bayesian fusion theory. The numerator reflects the joint probability that two indicators jointly support the boundary, while the denominator serves as a normalization function. This structure ensures that when both the initial boundary probability and the path consistency score are high, the final probability will be non-linearly enhanced to a level closer to 1, thereby widening the contrast between the true boundary and non-boundary regions in the final probability map.
[0018] Preferably, the step of extracting the wear contour based on the final boundary probability of each pixel in the region of interest includes: obtaining the final boundary probability of each pixel in the region of interest to obtain a final boundary probability field; constructing an external potential energy field based on the final boundary probability field; and iterating the active contour model under the drive of the external potential energy field until a preset termination condition is reached to extract the wear contour.
[0019] Preferably, locating the region of interest includes: performing grayscale processing on the CNC lathe tool image to obtain a grayscale image; and using normalized cross-correlation template matching technology to locate the region in the grayscale image that best matches a preset template image, and extracting it as the region of interest.
[0020] In a second aspect, the present invention provides a machine vision-based real-time detection system for CNC lathe tool wear, the machine vision-based real-time detection system for CNC lathe tool wear includes a memory and a processor, the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the machine vision-based real-time detection method for CNC lathe tool wear of the first aspect of the present invention is implemented.
[0021] By adopting the above technical solution, the machine vision-based real-time detection method for CNC lathe tool wear of the first aspect of the present invention is generated into a computer program and stored in a memory so that it can be loaded and executed by a processor. A terminal device can then be made based on the memory and the processor for convenient use.
[0022] The beneficial effects of this invention are as follows: This invention constructs a dual verification mechanism combining pixel-level and path-level verification. At the pixel level, it improves the reliability of local edge detection by fusing multi-dimensional features such as gradient, phase consistency, and structural tensor anisotropy. At the path level, it introduces a macroscopic continuity assessment based on path integrals, effectively distinguishing between real wear contours and isolated pseudo-edges by determining whether boundary points lie on continuous and smooth paths. Finally, Bayesian theory is used to optimally fuse these two different levels of evidence, thereby achieving high-precision and robust real-time extraction of tool wear contours even under strong interference environments such as coolant and metal chips. Attached Figure Description
[0023] Figure 1 A flowchart of a machine vision-based real-time detection method for CNC lathe tool wear provided in an embodiment of the present invention; Figure 2 The structural block diagram of the CNC lathe tool wear real-time detection system based on machine vision provided in the embodiment of the present invention. Detailed Implementation
[0024] The first aspect of this invention provides a method for real-time detection of tool wear on CNC lathes based on machine vision, such as... Figure 1 As shown, the method includes steps S100-S500: Step S100: Acquire images of CNC lathe cutting tools and locate the region of interest.
[0025] It should be noted that tool images acquired at the machining site typically contain a large amount of irrelevant background, such as machine tool chucks, workpieces, and coolant pipes, and the images are also quite large. Direct processing would consume a lot of computational resources and cannot meet the requirements of real-time detection. This step, through preprocessing and target localization, outputs input data with uniform size, excellent signal-to-noise ratio, and only includes wear-related areas, thereby achieving computational focus and improving algorithm efficiency.
[0026] Specifically, firstly, image preprocessing is performed to convert the acquired tool image into a grayscale image; at the same time, illumination normalization processing is performed on the grayscale image and the pre-stored offline template image. The template image is the tip image of a standard new tool or a slightly worn tool. Illumination normalization ensures that the illumination conditions of the two are consistent, laying the foundation for subsequent matching.
[0027] Next, the region of interest (ROI) is located using normalized cross-correlation template matching. A global sliding search for templates is performed in the preprocessed grayscale image. By calculating the similarity score between the template and each region of the image, the region with the highest score is located. Using the center point of this region as a reference, a rectangular area of a preset size is extracted as the ROI. For example, selecting... The pixel size is determined based on the tool model and the typical size of the wear area on the flank face. The region of interest (ROI) must completely cover the flank face of the tool, as tool wear mainly occurs on the flank face. Therefore, it is essential to ensure coverage of the potentially worn portion. All subsequent analyses, such as wear area segmentation, will be performed only within the ROI.
[0028] This completes the image preprocessing and region of interest localization, providing high-quality input data for accurate segmentation of the wear area in the subsequent process.
[0029] Step S200: For each pixel in the region of interest, calculate the structure consistency factor that characterizes its local structural anisotropy, perform nonlinear modulation on its gradient magnitude based on the structure consistency factor and the phase consistency of the pixel, and calculate the initial boundary probability of the pixel by combining the nonlinear amplification result of the phase consistency.
[0030] It should be noted that, considering that wear areas are often accompanied by abrupt changes in grayscale, and gradient features can quickly capture areas of abrupt grayscale changes in an image, they can be used as the basic signal for identifying wear edges; considering that fluctuations in ambient lighting during processing can easily lead to a decrease in the contrast of wear boundaries, and that phase features are not sensitive to changes in lighting, they can still stably reflect the structural information of the edges even in low-contrast scenes. Therefore, based on the complementarity of these two types of features, this invention calculates a preliminary boundary probability value for each pixel within the ROI, characterizing its likelihood of belonging to a real physical boundary, and ultimately enhances the real boundary signal to the greatest extent at the pixel level while effectively suppressing noise and artifacts.
[0031] Specifically, before calculating the initial boundary probability, it is necessary to obtain two required feature data: for the gradient feature, the gradient magnitude of the pixel is obtained through image gradient calculation methods. For phase characteristics, the phase consistency value is calculated. To characterize this, the value can be calculated using a frequency domain analysis method based on a Log-Gabor filter, which is well-known in the art and will not be elaborated upon here. For the local structural anisotropy characteristics, the structural consistency factor is calculated. The consistency and reliability of gradient information within the neighborhood of a pixel are evaluated, and the specific calculation method will be explained later.
[0032] Based on the feature data obtained above, this step constructs a collaborative enhancement fusion formula. This formula can obtain a highly reliable initial boundary probability by combining the local characteristics of the image with gradient magnitude, phase consistency and local structural anisotropy indices.
[0033] Based on the above logic, for any ROI, the number of pixels within it... The initial boundary probabilities satisfy the following relationship: ; in, It is a pixel. The initial boundary probability; It is a pixel. The gradient magnitude; It is a pixel. Phase consistency value; It is a pixel. The structural consistency factor is used to evaluate pixel points. The consistency and reliability of gradient information within the neighborhood will be discussed later; It is a standard normalized function; It is the hyperbolic tangent function.
[0034] This relation is formed by adding two complementary terms. The first part... Using gradient magnitude as a basis, and utilizing the... and The exponential term, which is jointly determined, modulates it, and phase consistency is only achieved when the gradient information itself is reliable. This allows for a significant nonlinear enhancement of the gradient response through an exponential function. It ensures that only clear, high-confidence boundaries yield high response values. Part Two It is used to solve low-contrast boundary problems. For real boundaries where the gradient magnitude is very small due to factors such as lighting, it usually still maintains high phase consistency. The hyperbolic tangent function can handle high-contrast boundaries. Nonlinear amplification is performed to ensure that the true boundary information of low contrast is not lost during the fusion process.
[0035] For the structural consistency factor in the relation The calculation of this equation requires clarification. To achieve adaptive feature fusion in the probabilistic fusion formula, an index capable of evaluating the reliability of local image information is needed. Considering clear, realistic edges, their gradient directions within their neighborhoods should be highly consistent, exhibiting significant anisotropy; while noise points or flat regions exhibit disordered or nonexistent gradient directions, showing isotropy. Based on this, this invention constructs a structural consistency factor by calculating the eigenvalues of the structural tensor. This is used to evaluate the consistency and reliability of local gradient information.
[0036] To achieve the above evaluation, first at the pixel point The gradient components of the pixel are calculated within its neighborhood window. These gradient components can be calculated using methods commonly used in this field, such as the Sobel operator or the Prewitt operator. Subsequently, the structure tensor of the pixel is constructed, and eigenvalue decomposition is performed on the structure tensor to obtain two non-negative eigenvalues. and These two eigenvalues represent the cumulative intensity of the gradient in the principal and secondary directions, respectively. The neighborhood window size can be set according to the typical size of the tool wear region, for example... or The calculation of pixels, the structure tensor, and the two eigenvalues is existing technology and will not be elaborated here. Based on these two eigenvalues, the structure consistency factor constructed in this invention satisfies the following relationship: ; in, It is a pixel. Structural consistency factor; , It is a pixel. The maximum and minimum eigenvalues of the structure tensor within the neighborhood window.
[0037] In this relationship, the numerator reflects the difference in gradient intensity along the principal and secondary directions, while the denominator serves a normalization function. When strong edges with consistent orientation exist within the neighborhood, [the relationship is further simplified]. Much larger , A value close to 1 indicates that the gradient information in that region is highly reliable; when the neighborhood is a noisy region with disordered gradient directions or a flat region without gradients, and Similar in size A gradient value approaching 0 indicates that the gradient information in that region is unreliable.
[0038] Preferably, when When this condition is met, it indicates that the region is a flat region with no gradient change, and at this time, it can be defined as... .
[0039] To more intuitively illustrate how the above fusion mechanism distinguishes between real boundaries and false edges, two representative pixels are selected for analysis from the currently located tool wear ROI: Point A is at coordinates... The pixel at point B is located on a real, continuous, and well-shaped wear boundary; point B is at coordinates... The pixels located on isolated scratches caused by strong interference from metal chip reflections, exhibit characteristics highly similar to real wear boundaries in terms of local grayscale changes.
[0040] Because of point A Located on a real and clear boundary, its local eigenvalues are measured as follows: normalized gradient magnitude is 0.90, phase consistency is 0.95, and due to the high consistency of its gradient directions, its structural consistency factor is 0.98. Substituting these values into the initial boundary probability formula, the initial boundary probability value is obtained. This indicates that point A, viewed locally, is very likely the boundary. As for point B... Located on an isolated but clearly defined scratch, its local features are also very obvious. The measured values of its various local features are as follows: normalized gradient magnitude is 0.92, phase consistency is 0.90, and since the scratch itself also resembles an edge, its gradient direction is also highly consistent, with a structure consistency factor of 0.95. Substituting these values into the initial boundary probability formula, the initial boundary probability value is obtained. This indicates that, based on the calculations in this step, point B is also highly likely to be a boundary in a local context.
[0041] At this point, the initial boundary probabilities of all pixels within the ROI have been obtained.
[0042] Step S300: For each pixel in the region of interest, construct an exploration path that passes through the pixel and extends along its local boundary direction. Calculate the path consistency score of the pixel based on the integral of the product of the initial boundary probability and the preset weight of the exploration path.
[0043] It should be noted that while the initial boundary probability can determine the boundary attributes of pixels based on local features and accurately identify pixels with local boundary features, it cannot distinguish the boundary type to which these boundary points belong: whether they belong to a long, continuous, and smooth wear contour in a tool wear scenario, or to isolated noise points, scratches formed by metal chip reflections, or minor imperfections in non-wear areas of the tool surface. In actual CNC machining, tool wear boundaries are affected by the cutting motion law and usually present a continuous, elongated shape. Isolated boundary points or short segments are usually not part of the true wear contour. Therefore, this step constructs a path consistency evaluation index to determine whether each boundary point is located on a continuous, smooth, high-probability boundary path, thereby filtering out isolated pseudo-boundary points and retaining continuous boundary points corresponding to the true wear contour. At the same time, to ensure real-time detection, this step first introduces a computational efficiency optimization strategy, performing path consistency analysis only on boundary points with high initial boundary probabilities to avoid invalid calculations for low-probability non-boundary points.
[0044] Specifically, for each pixel, an exploration path is constructed that passes through the pixel and extends along its local boundary direction. The initial extension direction of the path is determined by the pixel. The minimum eigenvalue corresponding to the structure tensor The feature vector is used to determine the direction, which represents the optimal tangent direction of the local boundary, ensuring that the starting direction of the path is consistent with the boundary direction. Based on this, a pixel-by-pixel tracking strategy is used to generate a complete exploration path: starting from pixel point... Starting from the initial extension direction, move one unit step and select the nearest pixel as the next node; at the new node, recalculate the local boundary direction and update the forward direction accordingly, iterating until the total path length reaches the preset maximum unidirectional exploration distance. This process is performed once in each of the forward and reverse directions, forming a line centered on the pixel with a total length of [missing information]. The bidirectional exploration path is represented as a parameterized function. , where parameters This represents the distance traveled along the path from the center point. This represents the pixel coordinates of the location corresponding to that distance.
[0045] It should be noted that a point truly belonging to the wear profile should not only have a path composed of high-probability points, but also a smooth and directionally continuous path geometry. Based on this, this invention evaluates the geometric quality of the path by introducing a directional consistency weight into the path integral.
[0046] Based on the above logic, for any ROI, the number of pixels within it... The path consistency score satisfies the following relationship: ; in, It is a pixel. Path consistency score; It is the preset maximum one-way exploration path length; It is along the path from pixel point Distance from the starting point; It is a parameterized path function, whose input is The output is the pixel coordinates of that distance on the path; It is a path function The initial boundary probability at the specified pixel; It is a pixel. The local boundary direction, that is, the pixel point The initial direction of path extension; It is a path function The local boundary direction at the specified pixel; It is a preset directional tolerance coefficient, and its value is greater than 0; It is an integral variable.
[0047] In this relationship, the integral term consists of two parts, which together determine the contribution of each point on the path to the final score: the first term... The first term, the negative exponential function, ensures that the path contributes significantly to the final integral only when it travels through regions with high probability of boundary changes. If the path enters a low-probability region, its contribution is minimal. The second term, the negative exponential function, acts as a dynamic weight to assess the geometric quality of the path. Its core is the deviation-square term in the numerator, which symmetrically tolerates small, smooth bends in the path. However, when the direction changes drastically, the consistency weight decays rapidly and non-linearly, significantly reducing the integral response of such discontinuous paths. The denominator normalizes the deviation-square term, and the entire fraction collectively assesses the curvature of the path at that point. The negative exponential function smoothly maps the fractional value to a consistency weight between 0 and 1. When the fractional value is 0, the weight is 1, and the larger the fractional value, the closer the weight is to 0. This is used to normalize the integration results, ensuring that the score range is independent of path length and uniformly mapped to... Interval.
[0048] It should be noted that the maximum unidirectional exploration path length and directional tolerance coefficient The value needs to be set according to the actual working conditions: for scenarios where the expected wear pattern is long and smooth, It can be set to 15% of the ROI width, such as 40 pixels. It can be set to 0.5 to enhance selectivity for long-range, continuous structures; for scenarios where the wear pattern may be short or the curvature may be high, it can be appropriately reduced. Such as 20 pixels and increase For example, version 1.0, to improve adaptability to local morphology. In this embodiment, 30 pixels is preferred. 0.5 is preferred.
[0049] To more intuitively illustrate the role of path consistency assessment in distinguishing between true boundaries and false edges, the aforementioned point A is calculated using the relational formula. With point B The path consistency score, assuming , Since point A lies on a continuous and smooth wear boundary, when starting from point A and moving along its boundary direction... When tracing the path, all pixels on the path maintain a high initial boundary probability and smooth, continuous orientation. The integration process is illustrated by selecting several representative points on the path: at the starting point, the orientation deviation is 0, and the contribution value of the integrand is... For the midpoint of the path Since the path is smooth and lies on the boundary, its initial boundary probability value is 0.89. When the path has a slight curve and the direction deviation is 0.1, the consistency weight term... At this point, the contribution value of the integrand For the far end of the path Assuming the point is still on the boundary, its initial boundary probability is 0.85. When the path curvature is large and the direction deviation is 0.2, the consistency weight term... At this point, the contribution value of the integrand As can be seen, along the entire integration path from point A (-30 to +30), the value of the integrand remains consistently high. Therefore, the cumulative result of the integral is high. After normalization, we obtain its path consistency score. .
[0050] Since point B is located on an isolated scratch, when starting from point B and following its boundary direction... When tracing the path, the path quickly leaves the high-probability scratch and enters the low-probability background region. The integration process is illustrated by selecting several representative points on the path: at the starting point, the directional deviation is 0, and the contribution value of the integrand is... ; at the midpoint of the path At this point, the path has left the scratched area and entered a flat background region, where its initial boundary probability drops to 0.1. Simultaneously, the background gradient direction is chaotic, with a directional deviation of 1.0, and the consistency weight term... At this point, the contribution value of the integrand For the far end of the path At this point, the path has penetrated deep into the background region, its initial boundary probability value further decreases to 0.05, and the direction deviation increases to 1.5. At this point, the consistency weight term... At this point, the contribution value of the integrand As can be seen, along the entire integration path from -30 to +30 at point B, except for a very few points near the starting point, the contribution value of the integrand in most of the path approaches zero due to the decrease in boundary probability. Therefore, the cumulative result of the entire integration will be very low. After normalization, the path consistency score is obtained. .
[0051] At this point, the path consistency score of each pixel within the ROI has been obtained.
[0052] Step S400: Combine the initial boundary probability and path consistency score of the pixel to obtain the final boundary probability of the pixel.
[0053] It should be noted that, in order to optimally fuse the initial boundary probabilities from the local structure and the path consistency scores from the macroscopic path, simple linear weighting or direct multiplication cannot reflect the mutual reinforcement or weakening relationship between the two indicators. Therefore, this invention employs an indicator fusion formula based on Bayesian theory to calculate the final boundary probability. This formula calculates the final confidence level by the ratio of the joint probability of supporting boundaries to the joint probability of not supporting boundaries. This aligns with the core logic of posterior probability updates in Bayesian theory, significantly enhancing confidence when the two indicators are consistent and effectively suppressing noise when the two indicators contradict each other, ensuring that the fusion process has clear theoretical support.
[0054] Based on the above logic, the final boundary probability satisfies the following relationship: ; in, It is a pixel. The final boundary probability, whose range is: The closer the value is to 1, the higher the confidence that the pixel is a true boundary. It is a pixel. The initial boundary probability; It is a pixel. Path consistency score; It is a preset microvalue used to prevent the denominator from being 0, and can be set to 0.001.
[0055] In this formula, the numerator represents the joint probability of the boundary supported by two indicators, while the denominator plays a normalization role. When both the initial boundary probability and the path consistency score are at a high level, they work together, and the final boundary probability result will be closer to 1 than a single indicator, achieving mutual reinforcement between indicators. When there is a contradictory situation where one indicator is strong while the other is weak, such as noise points with obvious local features but not on a continuous path, the final boundary probability result will be significantly reduced, effectively achieving the goal of eliminating false positives and retaining true positives.
[0056] For example, still using point A as mentioned above With point B Taking point A as an example, its initial boundary probability is... Path consistency score Substituting into the final boundary probability equation, we can obtain: Therefore, the boundary confidence level at point A is significantly enhanced to near 1, further validating the reliability of the true boundary. For point B, its initial boundary probability... Path consistency score Substituting into the final boundary probability equation, we can obtain: Therefore, it can be seen that the boundary confidence of point B is significantly reduced from a local high value, effectively distinguishing its pseudo-boundary attribute.
[0057] Finally, by calculating the final boundary probability of each pixel within the ROI, the final boundary probability field of each pixel within the ROI can be obtained.
[0058] Step S500: Extract the wear profile based on the final boundary probability of each pixel in the region of interest, and evaluate the tool wear state based on the wear profile to achieve real-time detection.
[0059] It should be noted that, in order to extract the contour from the final boundary probability field, the active contour model treats the contour as a curve that minimizes the overall energy while maintaining both elasticity and rigidity. Its advantage lies in the fact that it is not only attracted to obvious features of the image, but its inherent smoothness and continuity constraints can also automatically bridge minor discontinuities on the boundary and suppress noise interference. Therefore, this invention selects this model to leverage its strong overall and geometric constraint capabilities to transform the final probability map into an absolutely closed, smooth, and sub-pixel accurate optimal boundary contour.
[0060] Specifically, firstly, an active contour model is employed, constructing an external potential energy field based on the final boundary probability field. The potential energy is negatively correlated with the boundary probability; regions with higher probabilities have lower potential energy, thus guiding the contour to converge towards a high-probability boundary. Driven by this external potential energy field, an accurate and closed wear boundary contour is extracted through iterative optimization. This iterative optimization continues until the contour energy converges or a preset number of iterations is reached. It should be noted that how the external potential energy field is constructed is existing technology and will not be elaborated upon here.
[0061] Then, based on the extracted contour, a standard geometric measurement algorithm is used, in which the Gauss-Green relation can be used to directly calculate the area of the region through the integration of the closed contour. This algorithm is adapted to the closed wear contour in this step to calculate key wear assessment indicators, such as the wear area and the maximum wear band width. Finally, these calculated quantitative indicators are compared with the preset scrap threshold to determine the current status of the tool, such as: normal, warning, or scrap. Corresponding instructions are then issued to the machine tool CNC system or operator to complete the inspection.
[0062] The setting of the scrap threshold depends on the machining process, workpiece material, and surface quality requirements, and must also consider economic efficiency. As a preferred implementation, the scenarios for setting this scrap threshold can be specifically divided into: High-precision finishing scenarios: For example, when performing final contour finishing on critical load-bearing components in aerospace applications, to ensure extreme dimensional accuracy and surface integrity, such as a surface roughness of 0.8 μm, extremely high tool sharpness is required. In this case, the scrap threshold will be set very strictly, for example, 0.2 mm. Large-margin roughing scenarios: When performing preliminary roughing operations on forging blanks, the main goal is to efficiently remove a large amount of material, and surface quality requirements are not high. In this case, to maximize tool life and reduce costs, the scrap threshold can be set more leniently, for example, 0.6 mm.
[0063] For example, an initial contour line, guided by a potential energy field constructed based on the final boundary probability field, accurately fits the actual wear boundary containing point A, completely ignoring the interference area where point B is located. Based on this extracted optimal contour, the algorithm calculates its wear band width to be 35.4 pixels. After camera calibration based on camera intrinsic parameters and object distance parameters, this is converted to a physical size of 0.35 mm. This value is compared with the preset scrap threshold in the system corresponding to high-precision finishing scenarios. The machine tool will be determined to have reached the scrap standard and a tool replacement command will be issued to the machine tool.
[0064] The second aspect of this embodiment provides a real-time CNC lathe tool wear detection system based on machine vision, such as... Figure 2 As shown, the machine vision-based real-time detection system for CNC lathe tool wear includes a memory and a processor. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, the machine vision-based real-time detection method for CNC lathe tool wear of the first aspect of the present invention is implemented.
[0065] The machine vision-based real-time detection system for CNC lathe tool wear also includes other components well-known to those skilled in the art, such as communication buses and communication interfaces. Their settings and functions are known in the art and will not be described in detail here.
[0066] In this invention, the aforementioned memory can be any tangible medium containing or storing a program that can be used or combined with an instruction execution system, apparatus, or device. For example, a computer-readable storage medium can be any suitable magnetic or magneto-optical storage medium, such as resistive random access memory (DRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (DRAM), high-bandwidth memory, hybrid memory cube, etc., or any other medium that can be used to store desired information and can be accessed by an application, module, or both. Any such computer storage medium can be part of a device or accessible to or connected to a device.
[0067] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A machine vision-based real-time detection method for CNC lathe tool wear, characterized in that, include: Acquire images of CNC lathe cutting tools and locate the region of interest; For each pixel in the region of interest, a structure consistency factor characterizing its local structural anisotropy is calculated. The structure consistency factor is positively correlated with the difference between the maximum and minimum eigenvalues of the structure tensor in the neighborhood of the pixel. The gradient magnitude of the pixel is nonlinearly modulated based on the structural consistency factor and the phase consistency of the pixel, and the initial boundary probability of the pixel is calculated by combining the nonlinear amplification result of the phase consistency. For each pixel in the region of interest, an exploration path is constructed that passes through the pixel and extends along its local boundary direction. The path consistency score of the pixel is calculated based on the integral of the exploration path with respect to the product of the initial boundary probability and the preset weight. The initial boundary probability and path consistency score of the pixel are combined to obtain the final boundary probability of the pixel. The wear profile is extracted based on the final boundary probability of each pixel in the region of interest, and the tool wear state is evaluated based on the wear profile to achieve real-time detection.
2. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1, characterized in that, The initial boundary probabilities satisfy the following relationship: ; in, It is a pixel. The initial boundary probability; It is a pixel. The gradient magnitude; It is a pixel. Phase consistency value; It is a pixel. structural consistency factor, It is a standard normalized function; It is the hyperbolic tangent function.
3. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1 or 2, characterized in that, The acquisition of the structural consistency factor includes: Calculate the structure tensor within the neighborhood window of the pixel; The structure tensor is subjected to eigenvalue decomposition to obtain the maximum and minimum eigenvalues; The ratio of the difference between the largest and smallest eigenvalues to the sum is denoted as the structural consistency factor.
4. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1, characterized in that, The step of constructing an exploration path that passes through each pixel within the region of interest and extends along its local boundary includes: The feature vector corresponding to the minimum eigenvalue of the structure tensor of the pixel is determined, and the direction of the feature vector is used as the initial extension direction of the exploration path. Starting from the pixel, iterative tracking is performed pixel by pixel along the initial extension direction. At each tracking node, the forward direction is updated according to the local boundary direction of the node until the path length reaches the preset maximum exploration distance to generate the exploration path.
5. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1, characterized in that, The acquisition of the preset weights includes: Obtain the directional deviation between the local boundary direction of any pixel on the exploration path and the initial extension direction of the exploration path; Calculate the normalized value of the square of the directional deviation and perform a negative exponentiation on it to obtain a preset weight.
6. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1, characterized in that, The process of fusing the initial boundary probability and path consistency score of the pixel to obtain the final boundary probability of the pixel includes: The initial boundary probability and the path consistency score are fused based on Bayesian theory to obtain the final boundary probability.
7. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 6, characterized in that, The final boundary probability satisfies the following relationship: ; in, It is a pixel. The final boundary probability; It is a pixel. The initial boundary probability; It is a pixel. Path consistency score; It is a preset micro value.
8. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1, characterized in that, The step of extracting the wear contour based on the final boundary probability of each pixel within the region of interest includes: Obtain the final boundary probability of each pixel within the region of interest to obtain the final boundary probability field; An external potential energy field is constructed based on the final boundary probability field; Driven by the external potential energy field, the active contour model is iterated until a preset termination condition is reached in order to extract the wear contour.
9. The method for real-time detection of CNC lathe tool wear based on machine vision according to claim 1, characterized in that, The region of interest is located, including: The image of the CNC lathe tool is processed into a grayscale image. The normalized cross-correlation template matching technique is used to locate the region in the grayscale image that best matches the preset template image, and extract it as the region of interest.
10. A machine vision-based real-time detection system for CNC lathe tool wear, characterized in that, The machine vision-based real-time detection system for CNC lathe tool wear includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the machine vision-based real-time detection method for CNC lathe tool wear according to any one of claims 1-9.
Citation Information
Patent Citations
Mobile wearable monitoring systems
CN107438398A
Bullet train axle box defect detection method, system and equipment based on image recognition
CN120912619A
Vehicular Heads-Up Display System
US20070057781A1
System and method for dynamic multi-objective optimization of machine selection, integration and utilization
US20090210081A1
Cited By
Cable interlayer structure detection method and system based on image processing
CN121998982A
Numerical control machine tool cutter wear identification method and system based on image processing
CN122090171A