Dimension detection method, system and device and medium

By performing image processing and edge detection of the shadow images of the workpiece to be tested, combined with sliding window algorithm and preset reference templates, the existing dimension detection methods are solved in terms of accuracy and efficiency, and high-precision dimension detection and highly adaptable detection system are realized to meet the needs of industrial production.

CN120198480APending Publication Date: 2025-06-24CHENGDU HUAYUAN DEEP INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510273164.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-10
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

The existing dimensional detection methods have problems such as contact measurement tools that cause damage to the surface of the workpiece, low efficiency, and difficulty in detecting workpieces with complex shapes or soft and easily deformed shapes, and machine vision-based methods have problems with insufficient accuracy in noise processing and edge detection.

Method used

By obtaining the shadow image of the workpiece to be tested, performing grayscale conversion or binarization processing, using Gaussian nuclear filter and the improved Canny operator for edge detection, using the interpolation algorithm to improve pixel accuracy, combining the sliding window algorithm and the preset reference template for similarity calculation, integrating the height difference of the local area to obtain the overall size of the workpiece.

Benefits of technology

It realizes high-precision dimensional detection of the workpiece to be tested, improves detection accuracy and efficiency, can adapt to various sizes and shape changes, meets the strict requirements of industrial production, and improves the reliability of product quality through deviation analysis and early warning mechanisms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198480A_ABST
    Figure CN120198480A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of size detection, and provides a size detection method, system and device and a medium, and the method comprises the steps: obtaining a shadow image of a to-be-detected workpiece, carrying out the gray conversion or binarization processing, and smoothing the image through a Gaussian kernel filter, so as to reduce the noise and enhance the edge information; performing edge detection by using an improved Canny operator to extract object contour pixel points, calculating by using an interpolation algorithm to obtain a higher-precision object contour image, gradually traversing the contour image according to a preset track and a reference template by means of a sliding window algorithm, and calculating similarity to select a target local area; and finally, finding the highest point and the lowest point of the object contour image in the target local area, and integrating the data of each target local area according to the height difference, thereby accurately obtaining the overall size of the workpiece to be measured, and improving the accuracy and convenience of size measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of dimensional inspection, and more particularly, to a dimensional inspection method, system, device and medium. Background Art

[0002] The content of this part only provides background information related to the present application, and it may not constitute prior art.

[0003] With the continuous development of industrial manufacturing technology, the requirements for the accuracy and efficiency of workpiece dimensional inspection are getting higher and higher. Traditional dimensional inspection methods mainly rely on contact measurement tools such as calipers and micrometers. Although these methods can provide high measurement accuracy, they have the following deficiencies: First, contact measurement is likely to cause scratches or wear on the workpiece surface, especially for some workpieces with high precision and high surface quality requirements, such damage is unacceptable; Second, contact measurement has low efficiency and is difficult to meet the requirements of high-speed and large-volume inspection in modern industrial production; Finally, for some workpieces with complex shapes or soft and deformable materials, it is difficult to accurately obtain their dimensional information by contact measurement.

[0004] In recent years, dimensional inspection technology based on machine vision has gradually emerged. By acquiring and processing the images of workpieces, non-contact measurement of workpiece dimensions is realized. However, there are still some problems in the existing dimensional inspection methods based on machine vision: On the one hand, in the process of image processing, the removal of noise and details often affects the edge information of the image, resulting in unclear object contours and thus affecting the accuracy of dimensional inspection; On the other hand, existing edge detection algorithms such as the traditional Canny operator may have inaccurate edge detection or missed detection when dealing with complex images, and cannot meet the requirements of high-precision dimensional inspection.

[0005] Therefore, a dimensional inspection method is needed to inspect the workpieces in industrial production, so as to achieve high-precision dimensional inspection of the workpieces to be measured. Summary of the Invention

[0006] In order to solve the above technical problems, the purpose of the present application is to provide a dimensional inspection method, system, device and medium, which realizes high-precision dimensional inspection of the workpiece to be measured by processing and analyzing the shadow of the workpiece to be measured.

[0007] The purpose of the present application is achieved by the following technical solutions:

[0008] In the first aspect, the present invention provides a dimensional inspection method, including:

[0009] Obtaining a shadow image of the workpiece to be measured;

[0010] Perform grayscale conversion or binarization on the shadow image; apply a Gaussian kernel filter to smooth the image, reduce noise and unnecessary details, and enhance object edge information; use a modified Canny operator to perform edge detection on the edge information of the image and extract the pixel points of the object contour in the image;

[0011] Use an interpolation algorithm to perform interpolation calculations on the pixel points to obtain an object contour image with higher pixel accuracy;

[0012] Use the sliding window algorithm to gradually traverse the entire object contour image with a preset reference template as the window along a preset trajectory, and calculate the similarity between the image at the current window position and the preset reference template for each slide; select the region with the highest similarity as the target local region;

[0013] Find the highest and lowest points of the object contour image within the target local region, and based on the height difference between the highest and lowest points; integrate the height differences of each target local region to obtain the overall size of the workpiece to be measured.

[0014] Further, the preset reference template is constructed through the following steps:

[0015] Extract the template region from the standard sample of the workpiece to be measured, and the standard sample includes a shadow image or contour data;

[0016] Based on the template region, model the target region on the workpiece to be measured to obtain the preset reference template.

[0017] Further, the steps for calculating the similarity between the image at the current window position and the preset reference template specifically include:

[0018] Obtain the final similarity by calculating the correlation, mean square error, or gradient similarity between the image at the current window position and the preset reference template.

[0019] Further, the steps for integrating the height differences of each target local region specifically include:

[0020] Label the height differences of each target local region on the same object contour image in a preset format.

[0021] Further, after integrating the height differences of each target local region, it also includes:

[0022] Display the size of the overall workpiece in the form of charts and numbers for further analysis and operation by the user.

[0023] Further, after obtaining the overall size of the workpiece to be measured, it also includes:

[0024] Compare the overall size with the preset standard size and calculate the deviation between the actual size and the standard size of the workpiece;

[0025] According to the results of dimensional deviation analysis, a deviation report is automatically generated, and the report includes information such as the specific value of the deviation, the location of the deviation, and whether the deviation exceeds the acceptable range;

[0026] The deviation report is promptly fed back to the production or quality control department so that they can adjust the production process or inspection process based on the information in the report to reduce or eliminate dimensional deviations and improve product quality.

[0027] Furthermore, after automatically generating the deviation report, it also includes:

[0028] Based on the historical deviation report, a linear regression line is fitted based on time series to obtain the deviation slope value;

[0029] When the deviation slope value is positive and greater than a preset threshold, it is determined that the deviation is gradually increasing, and an early warning signal is automatically triggered to prompt relevant personnel to repair the production line.

[0030] In a second aspect, the present invention provides a dimensional inspection system, including:

[0031] An image acquisition module for acquiring a shadow image of a workpiece to be measured;

[0032] A preprocessing module for performing grayscale conversion or binarization processing on the shadow image; applying a Gaussian kernel filter to smooth the image to reduce noise and unnecessary details and enhance object edge information; using an improved Canny operator to perform edge detection on the edge information of the image to extract pixel points of the object contour in the image;

[0033] A pixel accuracy improvement module for performing interpolation calculation on the pixel points using an interpolation algorithm to obtain an object contour image with higher pixel accuracy;

[0034] A matching module for using a sliding window algorithm to gradually traverse the entire object contour image with a preset reference template as the window along a preset trajectory, and calculating the similarity between the image at the current window position and the preset reference template for each slide; selecting the region with the highest similarity as the target local region;

[0035] A result module for finding the highest point and the lowest point of the object contour image within the target local region, and based on the height difference between the highest point and the lowest point; integrating the height differences of each target local region to obtain the overall size of the workpiece to be measured.

[0036] In a third aspect, the present invention provides a dimensional inspection device, including a control terminal, a base, a light emitter, a lens, and a light receiver sequentially arranged on the base; the light receiver is connected to the lens;

[0037] A fixture table is provided between the light emitter and the lens, and the fixture table is used to fix the workpiece to be measured;

[0038] The control terminal is electrically connected to the light emitter and the light receiver respectively;

[0039] In response to the emission signal of the control terminal, the light emitter emits light. After being blocked by the workpiece to be measured, the lens receives the blocked light and conveys the blocked light to the light receiver to obtain a shadow image of the workpiece to be measured. The control terminal, based on the shadow image, implements the steps corresponding to the method in the first aspect based on the computer program built into the control terminal.

[0040] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the steps corresponding to the method in the first aspect.

[0041] In summary, the technical solutions of the embodiments of the present application at least have the following advantages and beneficial effects:

[0042] By obtaining the shadow image of the workpiece to be measured, the present invention provides basic data for subsequent dimension detection. Then, the shadow image is subjected to grayscale conversion or binarization processing to remove the redundancy and interference brought by color information, simplify the image information, and facilitate subsequent analysis. Then, a Gaussian kernel filter is applied to smooth the image, effectively reducing noise and unnecessary details, while enhancing the edge information of the object and providing better image quality for edge detection. Subsequently, an improved Canny operator is used to perform edge detection on the edge information of the image, extracting the pixel points of the object contour in the image. This process can detect the contour of the object more accurately and completely, providing key data for subsequent dimension calculation. Next, an interpolation algorithm is used to perform interpolation calculation on the pixel points to obtain an object contour image with higher pixel accuracy, further improving the accuracy of dimension detection. After that, the sliding window algorithm uses a preset reference template as the window and gradually traverses the entire object contour image along a preset trajectory. Each time it slides, the similarity between the image at the current window position and the preset reference template is calculated, and the region with the highest similarity is selected as the target local region. This process can accurately locate the target local region, efficiently identify feature patterns, adapt to various size and shape changes, and improve the detection accuracy. Finally, the highest point and the lowest point of the object contour image in the target local region are found, and the height differences of each target local region are integrated according to the height difference between the highest point and the lowest point to obtain the overall size of the workpiece to be measured. High-precision dimension detection of the workpiece to be measured is realized, with high detection accuracy and reliability, and can meet the strict requirements for dimension detection in industrial production. Description of the Drawings

[0043] Figure 1 It is a flowchart of a dimension detection method provided by the present invention;

[0044] Figure 2 Schematic structural diagram of a size detection system provided by the present invention;

[0045] Figure 3 Schematic structural diagram of a size detection device provided by the present invention.

[0046] Icons: 1, light emitter; 2, fixture table; 3, lens; 4, light receiver. Specific embodiments

[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. Usually, the components of the embodiments of the present application described and illustrated herein can be arranged and designed in various different configurations.

[0048] Embodiment 1:

[0049] As Figure 1 shown, a size detection method proposed in an embodiment of the present application includes:

[0050] S101, obtaining a shadow image of a workpiece to be measured.

[0051] S102, performing grayscale conversion or binaryzation processing on the shadow image; applying a Gaussian kernel filter to smooth the image, reducing noise and unnecessary details, and enhancing the edge information of the object; using a modified Canny operator to perform edge detection on the edge information of the image and extract the pixel points of the object contour in the image.

[0052] Specifically, first, performing grayscale conversion or binaryzation processing on the shadow image is a basic operation in image processing, and its purpose is to remove the redundancy and interference brought by color information, making subsequent analysis and calculation more accurate. Grayscale conversion is to convert the RGB (red, green, blue) three color channels of a color image into a single-channel grayscale value. Usually, the grayscale value is obtained by weighted average processing according to the importance of each color channel and the sensitivity of the human eye to different colors. The calculation formula is as follows:

[0053] W g = 0.2989R + 0.587G + 0.114B

[0054] where R, G, and B respectively correspond to the red, green, and blue components of the image pixel point, and the result W g represents the grayscale value of the pixel point. Through this conversion, the color difference in the image is converted into a grayscale difference, simplifying the image information.

[0055] Binarization further simplifies the grayscale information in the image, dividing the pixel points in the image into two categories: black or white. A threshold T is set. When the grayscale value in the image is greater than this threshold, the pixel point will be marked as white (usually represented by 1); conversely, if the grayscale value is less than or equal to the threshold T, it will be marked as black (represented by 0). This process helps to highlight the contour and shape information in the image, making the boundary between the target object and the background clearer and facilitating subsequent operations such as edge detection. However, the selection of the threshold T needs to be adjusted according to the specific image characteristics and detection requirements to ensure accurate segmentation of the target area and the background area.

[0056] After completing the grayscale conversion or binarization, the Gaussian kernel filter is then applied to smooth the image. The Gaussian kernel filter is a filter based on the Gaussian function. Its core idea is to use a smoothing window to perform weighted averaging on the pixel points in the image, thereby reducing the noise and unnecessary details in the image while retaining the main features of the object, especially the edge information of the object. The formula for the Gaussian kernel function is:

[0057]

[0058] where G(x,y) is the value of the Gaussian kernel function at the position (x,y), and x and y are the distances of the pixel points in the image from the center of the Gaussian kernel in the horizontal and vertical directions respectively. The weight of the center point is the largest, and the weight decreases as the distance increases. σ is the standard deviation of the Gaussian kernel, which determines the degree of smoothing. A larger σ value will result in a smoother image but may blur the object edges; while a smaller σ value retains more details but may not effectively remove the noise. Through the processing of the Gaussian kernel filter, the noise points and small irregular details in the image are weakened, and the contour of the object becomes smoother and more prominent, which is beneficial to the accurate performance of subsequent edge detection.

[0059] Finally, after completing the image smoothing, the improved Canny operator is used to perform edge detection on the image. The Canny operator is a gradient-based edge detection algorithm that determines the edge points in the image by calculating the gradients in the horizontal and vertical directions of the image. The improved Canny operator is optimized based on the traditional Canny operator, and the detected object contour pixel points are more accurate and complete. The purpose of this process is to extract the key pixel points of the object contour in the image as the basis for subsequent sub-pixel processing and size analysis.

[0060] Furthermore, the steps for calculating the similarity between the image at the current window position and the preset reference template specifically include:

[0061] The final similarity is obtained by calculating the correlation, mean square error, or gradient similarity between the image at the current window position and the preset reference template. Taking gradient similarity as an example, the specific calculation is as follows:

[0062] The Canny operator detects edges by calculating the gradient of the image. A common gradient operator is the Sobel operator. The Sobel operator calculates the gradients G x and G y in the x and y directions of the image to obtain edge information:

[0063]

[0064] where w represents the gray value of the image.

[0065] The edge intensity G and the gradient direction θ are calculated by the following formulas:

[0066]

[0067] S103, Use the interpolation algorithm to perform interpolation calculations on pixel points to obtain an object contour image with higher pixel accuracy.

[0068] Specifically, based on the known data points, new data points are generated between the data points to more finely depict the contour of the object. The interpolation algorithm can use quadratic interpolation or cubic interpolation, etc. It estimates the gray values at the sub-pixel level between pixel points by weighted averaging the gray values of adjacent pixel points or more complex mathematical operations, and then determines a more accurate edge position. Taking the gradient method as an example, its specific calculation process is as follows:

[0069] Fit a more accurate edge position in the neighborhood according to the direction and magnitude of the gradient. Use the quadratic interpolation method to calculate the exact position between pixel points.

[0070] Assume that I(x,y) is the gray value of the object contour image. An edge point is detected at (x,y). Use the gradient direction information θ to interpolate the surrounding pixel points to determine a more accurate edge position. The form of quadratic interpolation is:

[0071] I(x,y) = ax 2 + by 2 + c

[0072] By fitting with the least squares method and correcting the edge points according to the gradient information, sub-pixel level accuracy can be obtained.

[0073] S104, Use the sliding window algorithm to gradually traverse the entire object contour image with the preset reference template as the window along the preset trajectory. Calculate the similarity between the image at the current window position and the preset reference template for each slide; Select the region with the highest similarity as the target local region;

[0074] Specifically, first, a sliding window with the same size as the preset reference template is defined, and this window will gradually move on the entire object contour image along a preset trajectory. The preset trajectory usually moves uniformly horizontally and vertically. For example, it moves 1 pixel horizontally and 1 pixel vertically each time, and the moving step size can also be adjusted according to actual needs. At each window position, the system calculates the similarity between the image area covered by the current window and the preset reference template. There are various methods for calculating similarity, including cross-correlation, normalized cross-correlation coefficient, mean square error, and gradient-based similarity, etc. For example, cross-correlation evaluates the matching degree by calculating the correlation between the area to be measured and the template area. The higher the correlation value, the better the matching; the normalized cross-correlation coefficient can eliminate the influence of image brightness differences on the matching result, and the value closer to 1 indicates higher similarity; the mean square error measures the difference degree between the area to be measured and the template, and the smaller the error, the higher the similarity; the gradient-based similarity uses the gradient information of the image to judge the matching degree. If the gradient change trends of the two are the same, the similarity is high. By continuously sliding the window on the image and calculating the similarity, the region with the highest similarity is finally selected as the target local region. This method can accurately locate the target local region, efficiently identify the feature pattern, adapt to various size and shape changes, and improve the detection accuracy, providing an accurate basis for subsequent size detection.

[0075] Furthermore, the preset reference template is constructed through the following steps: extract the template area from the standard sample of the workpiece to be measured, and the standard sample includes a shadow image or contour data; according to the template area, model the target area on the workpiece to be measured to obtain the preset reference template.

[0076] Specifically, the construction of the preset reference template is achieved by selecting the standard sample of the workpiece to be measured and determining the size and shape of the template according to its geometric shape and dimensional requirements. For example, if the workpiece to be measured has a groove with a specific shape, the template will select the area corresponding to the groove and set the corresponding length and width parameters. These parameters are obtained by analyzing the characteristics of the standard sample to ensure that the template can cover the key parts of the target features.

[0077] Next, extract the image data or contour information of the template region from the standard sample, such as obtaining shadow contour data through threshold segmentation, or extracting contour data from the two-dimensional image generated by projecting the three-dimensional model. Then, preprocess the extracted template data, including operations such as denoising and edge enhancement, to improve the quality of the template. For example, use median filtering to remove noise points, or enhance the contrast through gray-scale transformation. In addition, other attributes of the template can also be defined, such as gray-scale range, texture features, etc., to further improve the matching accuracy of the template. The constructed preset reference template can accurately guide the sliding window to locate the target region in the actual image. Since the shape and size of the template match the characteristics of the target local region, when the sliding window traverses the image, only the regions with high similarity to the template will be selected as the target local regions, improving the accuracy of positioning. At the same time, the preset reference template can also suppress interference because the template is highly targeted and only sensitive to target features. Interference factors such as background noise and other irrelevant shadows have low similarity to the template and will be excluded. In addition, the preset reference template provides a fast screening mechanism for the sliding window matching process, improving the detection efficiency and reducing the computational complexity. The sliding window can quickly skip the regions that do not meet the conditions and only perform fine similarity calculations in the potential target regions. Finally, the construction of the preset reference template endows the entire detection method with a certain degree of adaptability and robustness. By selecting appropriate standard samples and extracting the characteristic attributes of the template, it can adapt to the size changes and slight shape differences of the target object to a certain extent. Even if there are certain deviations in the actual detection, the preset reference template can ensure a high detection success rate and improve the reliability of the entire detection method.

[0078] S105, find the highest point and the lowest point of the object contour image within the target local region, and according to the height difference between the highest point and the lowest point; integrate the height differences of each target local region to obtain the overall size of the workpiece to be measured.

[0079] Specifically, after determining the target local region, the system will deeply analyze the change of the gray value of the object contour image within this region. The change of the gray value in the contour image directly reflects the height information of the object surface. The convex part of the object surface appears as a brighter region in the shadow image, while the concave part appears as a darker region. By analyzing these gray values, the highest point and the lowest point in the contour image can be accurately found. The highest point corresponds to the highest position of the object surface, and the lowest point corresponds to the lowest position of the object surface.

[0080] After determining the highest point and the lowest point, the system will calculate the height difference between these two points. The calculation of the height difference is achieved by comparing the grayscale value of the highest point with that of the lowest point and combining the pre-set correspondence between the grayscale value and the actual height, thereby obtaining an accurate height difference value. This height difference value directly reflects the dimensional information of the target local area, that is, the height change of the object within this local area.

[0081] To obtain the overall dimensions of the workpiece to be measured, the system will integrate the height differences of each target local area. By comprehensively analyzing and calculating the height differences of all local areas, the overall dimensions of the workpiece to be measured can be accurately restored. That is, the height difference of each target local area on the contour image of the same object is marked on the object contour image in a preset format. Then, the dimensions of the entire workpiece are presented in the form of charts and numbers for further analysis and operation by the user.

[0082] Furthermore, after obtaining the overall dimensions of the workpiece to be measured, it also includes:

[0083] Compare the overall dimensions with the preset standard dimensions to calculate the deviation between the actual dimensions and the standard dimensions of the workpiece; according to the results of the dimensional deviation analysis, automatically generate a deviation report, which includes information such as the specific value of the deviation, the location where the deviation occurs, and whether the deviation exceeds the acceptable range; promptly feedback the deviation report to the production or quality control department so that they can adjust the production process or inspection process based on the information in the report to reduce or eliminate the dimensional deviation and improve product quality.

[0084] Specifically, compare the overall dimensions with the preset standard dimensions. By calculating the difference between the two, the deviation between the actual dimensions and the standard dimensions of the workpiece is obtained. This comparison process can intuitively show whether there are dimensional deviations in the workpiece during the production process and the specific values of the deviations. Then, according to the results of the dimensional deviation analysis, the system automatically generates a deviation report. The report details information such as the specific value of the deviation, the location where the deviation occurs, and whether the deviation exceeds the acceptable range. This information provides a clear basis for subsequent production adjustments. Finally, promptly feedback the deviation report to the production or quality control department so that they can make targeted adjustments to the production process or inspection process based on the detailed information in the report, thereby reducing or eliminating the dimensional deviation and improving product quality.

[0085] Furthermore, after automatically generating the deviation report, it also includes:

[0086] Fit a linear regression line based on the historical deviation reports according to the time series to obtain the deviation slope value; when the deviation slope value is positive and greater than the preset threshold, it is determined that the deviation is gradually increasing, and an early warning signal is automatically triggered to prompt relevant personnel to repair the production line.

[0087] Specifically, through the time series analysis of historical deviation reports, a linear regression model is used to model and predict the deviation change trend, so as to achieve early warning and timely intervention for potential problems in the production process. That is to say, after the system automatically generates deviation reports, these reports will be arranged in chronological order to form a time series of deviation data. Based on this time series, the system fits a linear regression line, and calculates the deviation slope value. This slope value reflects the trend of deviation changing with time. When the deviation slope value is positive and greater than the preset threshold, it indicates that the deviation shows a gradually increasing trend, and the increasing speed exceeds the acceptable range. At this time, the system will automatically trigger a warning signal to prompt relevant personnel to timely repair the production line to avoid further expansion of the deviation and the production of more unqualified products. By analyzing historical data, the future development trend of deviation is predicted, and measures are taken in advance to effectively reduce product quality problems caused by deviation, improve the stability of the production process and the reliability of product quality. At the same time, it also provides a more scientific and forward-looking decision-making basis for production management and quality control.

[0088] Embodiment 2:

[0089] Based on the same inventive concept, the present invention provides a size detection device, which includes a control terminal, a base, a light emitter 1, a lens 3 and a light receiver 4 sequentially arranged on the base; the light receiver 4 is connected to the lens 3; a fixture table 2 is provided between the light emitter 1 and the lens 3, and the fixture table 2 is used to fix the workpiece to be measured; the control terminal is electrically connected to the light emitter 1 and the light receiver 4 respectively; in response to the emission signal of the control terminal, the light emitter 1 emits light, after being blocked by the workpiece to be measured, the lens 3 receives the blocked light and conveys the blocked light to the light receiver 4 to obtain a shadow image of the workpiece to be measured; the control terminal realizes the steps corresponding to the method according to any one of claims 1 to 7 based on the computer program built in the control terminal.

[0090] Specifically, the light emitter 1 emits light under the instruction of the control terminal. When the light passes through the workpiece to be measured fixed on the fixture table 2, it will be blocked. The lens 3 receives the blocked light and transmits it to the light receiver 4, thereby obtaining the shadow image of the workpiece to be measured. Based on this shadow image, the control terminal, through a series of image processing and analysis steps, including grayscale conversion or binarization, Gaussian kernel filter smoothing, improved Canny operator edge detection, interpolation algorithm processing, sliding window algorithm matching, and dimension calculation, finally obtains the overall dimension of the workpiece to be measured. This device and method have the advantages of high-precision detection, high automation, and strong adaptability. It can effectively reduce noise and unnecessary details, enhance object edge information, and improve the accuracy and efficiency of dimension detection. In addition, by constructing a preset reference template and using the sliding window algorithm for matching, it can adapt to workpieces to be measured with different sizes and shapes, and has strong versatility and adaptability. At the same time, this device and method can also perform deviation analysis and early warning. Through the time series analysis of historical deviation reports, it can early warn of possible problems in the production process, take timely measures, effectively reduce product quality problems caused by deviations, and improve the stability of the production process and the reliability of product quality.

[0091] Among them, the function of the lens 3 is first to converge the light emitted by the light emitter 1 and blocked by the workpiece to be measured, so that the originally possibly divergent light can be accurately transmitted to the light receiver 4. This process not only improves the light transmission efficiency but also ensures the accuracy of the light signal. At the same time, the lens 3 is also responsible for focusing these converged lights and forming the shadow image of the workpiece to be measured. This shadow image clearly presents the dimension and shape information of the workpiece to be measured, providing a basis for subsequent dimension detection. In addition, by optimizing the light transmission and imaging process, the lens 3 can reduce the distortion of light, improve the resolution and contrast of the image, thereby further improving the quality of the shadow image, ensuring that the control terminal can more accurately extract the dimension information of the workpiece to be measured from the image, and improving the accuracy and reliability of the entire detection device.

[0092] Based on the same inventive concept, the present invention provides a dimension detection system, including:

[0093] An image acquisition module 201 for acquiring the shadow image of the workpiece to be measured;

[0094] A preprocessing module 202 for performing grayscale conversion or binarization on the shadow image; applying a Gaussian kernel filter to smooth the image, reducing noise and unnecessary details, and enhancing object edge information; using an improved Canny operator to perform edge detection on the edge information of the image and extract the pixel points of the object contour in the image;

[0095] The pixel accuracy improvement module 203 is used to perform interpolation calculation on pixel points by using an interpolation algorithm to obtain an object contour image with higher pixel accuracy;

[0096] The matching module 204 is used to gradually traverse the entire object contour image with a preset reference template as the window according to a preset trajectory by using a sliding window algorithm, and calculate the similarity between the image at the current window position and the preset reference template for each slide; select the region with the highest similarity as the target local region;

[0097] The result module 205 is used to find the highest point and the lowest point of the object contour image within the target local region, and according to the height difference between the highest point and the lowest point; integrate the height differences of each target local region to obtain the overall size of the workpiece to be measured.

[0098] Based on the same inventive concept, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned size detection method is implemented.

[0099] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.

Claims

1. A size detection method, characterized in that: include: Acquire a shadow image of the workpiece to be measured; Performing grayscale conversion or binarization processing on the shadow image; Apply Gaussian kernel filter to smooth the image, reduce noise and unnecessary details, and enhance the edge information of the object; use the improved Canny operator to detect the edge information of the image and extract the pixel points of the object contour in the image; Using an interpolation algorithm to perform interpolation calculation on the pixel points to obtain an object contour image with higher pixel accuracy; The sliding window algorithm is used to traverse the entire object contour image step by step along the preset trajectory with the preset reference template as the window. Each sliding operation calculates the similarity between the image at the current window position and the preset reference template; the area with the highest similarity is selected as the target local area; The highest point and the lowest point of the object contour image in the target local area are found, and according to the height difference between the highest point and the lowest point, the height difference of each target local area is integrated to obtain the overall size of the workpiece to be measured.

2. A size detection method according to claim 1, characterized in that: The preset reference template is constructed by the following steps: Extracting a template area from a standard sample of the workpiece to be tested, wherein the standard sample includes a shadow image or contour data; According to the template area, a target area on the workpiece to be measured is modeled to obtain a preset reference template.

3. A size detection method according to claim 1, characterized in that: The step of calculating the similarity between the image at the current window position and the preset reference template specifically includes: The final similarity is obtained by calculating the correlation, mean square error or gradient similarity between the image at the current window position and the preset reference template.

4. A size detection method according to claim 1, characterized in that: The step of integrating the height difference of each target local area specifically includes: The height difference of each target local area on the same object contour image is marked on the object contour image in a preset format.

5. A size detection method according to claim 4, characterized in that: After integrating the height difference of each target local area, the method further includes: The dimensions of the overall workpiece are displayed in the form of diagrams and numbers for users to further analyze and operate.

6. A size detection method according to claim 1, characterized in that: After obtaining the overall size of the workpiece to be measured, the method further includes: Comparing the overall size with a preset standard size, and calculating the deviation between the actual size of the workpiece and the standard size; Automatically generate a deviation report based on the results of the dimensional deviation analysis, the report includes information such as the specific value of the deviation, the location of the deviation, and whether the deviation exceeds the acceptable range; Feedback the deviation report to the production or quality control department in a timely manner so that they can adjust the production process or testing process based on the information in the report to reduce or eliminate dimensional deviations and improve product quality.

7. A size detection method according to claim 6, characterized in that: After the deviation report is automatically generated, it also includes: According to the historical deviation report, a linear regression line is fitted based on the time series to obtain the deviation slope value; When the deviation slope value is positive and greater than the preset threshold, it is determined that the deviation is gradually increasing, and an early warning signal is automatically triggered to prompt relevant personnel to inspect the production line.

8. A size detection system, characterized in that: The system comprises: An image acquisition module, used for acquiring a shadow image of a workpiece to be measured; A preprocessing module is used to perform grayscale conversion or binarization processing on the shadow image; apply a Gaussian kernel filter to smooth the image, reduce noise and unnecessary details, and enhance the edge information of the object; use a modified version of the Canny operator to perform edge detection on the edge information of the image and extract pixel points of the object contour in the image; A pixel precision improving module, used for performing interpolation calculation on the pixel points by using an interpolation algorithm to obtain an object contour image with higher pixel precision; The matching module is used to use a sliding window algorithm to gradually traverse the entire object contour image according to a preset trajectory with a preset reference template as the window, and each sliding calculates the similarity between the image at the current window position and the preset reference template; and selects the area with the highest similarity as the target local area; The result module is used to find the highest point and the lowest point of the object contour image in the target local area, and integrate the height difference of each target local area according to the height difference between the highest point and the lowest point to obtain the overall size of the workpiece to be measured.

9. A size detection device, characterized in that: It includes a control terminal, a base, a light transmitter, a lens and a light receiver which are sequentially arranged on the base; the light receiver is connected to the lens; A fixture table is provided between the light emitter and the lens, and the fixture table is used to fix the workpiece to be measured; The control terminal is electrically connected to the light transmitter and the light receiver respectively; In response to the transmission signal of the control terminal, the light transmitter emits light, and after being blocked by the workpiece to be measured, the lens receives the blocked light and transmits the blocked light to the light receiver to obtain a shadow image of the workpiece to be measured; the control terminal implements the steps corresponding to the method according to any one of claims 1 to 7 based on the computer program built into the control terminal according to the shadow image.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps corresponding to the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Method and system for digitally detecting size of thin plate of rolling mill

    CN120421338A

  • Multi-scale template matched rail vehicle body spot welding quality detection method and system

    CN121366122A

  • Product size detection method and system, terminal equipment and storage medium

    CN121677579A