A Defect Detection Algorithm Based on Line Scan Spectral Confocal Camera

CN115222730BActive Publication Date: 2025-10-31WUHAN JUNYING FUSION INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211054237.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-31
Publication Date
2025-10-31
Estimated Expiration
2042-08-31

Smart Images

  • Figure CN115222730B_ABST
    Figure CN115222730B_ABST
Patent Text Reader

Abstract

This invention discloses a defect detection algorithm based on a line-scan spectral confocal camera, comprising the following steps: S1, acquiring point cloud data of the surface of the object under test using a line-scan spectral confocal camera; S2, fitting a standard planar template based on the point cloud data; S3, comparing the point cloud data with the standard planar template obtained in step S2, and calculating the absolute difference of each point; S4, performing a threshold judgment based on the absolute difference calculated in step S3. If the absolute difference of all points is not greater than a preset threshold, it is determined that there is no defect on the surface of the object under test; if there are points with an absolute interpolation greater than the preset threshold, it is determined that there is a defect on the surface of the object under test. This invention uses line-scan spectral confocal imaging to acquire information from the surface of the object under test, which can effectively obtain depth information, thereby more accurately determining whether it is a defect and the type of defect. It has a good detection effect and good real-time performance, which can meet the inspection needs of production lines.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of defect detection technology, and in particular to a defect detection algorithm based on a line scan spectral confocal camera. Background Technology

[0002] In industrial production, surface defects not only affect the appearance of products but can also impact their performance and lifespan, potentially leading to incalculable losses in severe cases. Therefore, it is essential to inspect for surface defects during the production process.

[0003] Currently, machine vision is used to inspect products for surface defects to avoid the problems of low accuracy, high cost, and excessive subjectivity associated with manual inspection. Specifically, current computer vision inspection equipment first uses a 2D industrial camera (area scan or line scan) to capture images of the product surface. Then, threshold segmentation is performed based on the grayscale difference between the defect and the background in the image to locate the product. The image is then preprocessed, and feature extraction algorithms are used to determine the location of the defect within the image. However, for some highly reflective metal parts, the inspected area may be too reflective to be identified under illumination, and 2D industrial cameras (area scan or line scan) cannot capture depth information. When depth information is required for defect quantification, these cameras exhibit significant limitations.

[0004] Line scan spectral confocal cameras can capture the uneven features and depth information of the surface of the object being measured. Currently, this camera is only used in the field of measuring and scanning the object being measured for modeling. It is still a blank in the field of defect detection, and there is no corresponding defect detection algorithm. Summary of the Invention

[0005] To address the problems mentioned in the background section, the present invention provides the following technical solution:

[0006] A defect detection algorithm based on a line-scan spectral confocal camera includes the following steps:

[0007] S1. Acquire point cloud data of the surface of the object under test using a line scan spectral confocal camera;

[0008] S2. Fit a standard planar template based on point cloud data;

[0009] S3. Compare the point cloud data with the standard planar template obtained in step S2, and calculate the absolute difference of each point.

[0010] S4. Based on the absolute difference calculated in step S3, a threshold judgment is made. If the absolute difference of all points is not greater than the preset threshold, it is determined that there is no defect on the surface of the object being tested. If there are points with an absolute interpolation greater than the preset threshold, it is determined that there is a defect on the surface of the object being tested.

[0011] In some embodiments, after step S1 and before step S2, the following steps are further included:

[0012] S1' Reconstruct the point cloud data collected in step S1;

[0013] Furthermore, in subsequent steps, the point cloud data used are all the reconstructed point cloud data from step S1'.

[0014] In some embodiments, step S1', the step of reconstructing the point cloud data specifically includes:

[0015] Since the point cloud data is acquired by a line-scan spectral confocal camera, the point cloud data F is represented as a line set:

[0016] F = {L1, L2, L3, ..., L...} n-2 L n-1 L n}

[0017] L1, L2, L3, ..., L n Each line in the line set refers to a line L. i It consists of several points, so it can be represented as a point set:

[0018] L i ={x i1 x i2 x i3 ,..,x im-2 x im-1 x im}

[0019] x i1 x i2 x i3 ,..,x im Each point in the point set is pointed to individually;

[0020] For any two adjacent lines L i and L i+1 The compensation value Δ is calculated using the following formula:

[0021] Δ=MEDIAN{x i1 -x (i+1)1 x i2 -x (i+1)2 x im -x (i+1)m}

[0022] Where MEDIAN represents the mean value;

[0023] Then, the compensated line L′ is obtained according to the following formula. i:

[0024] L′ i ={x i1 +Δ, x i2 +Δ, x i3 +Δ,..,x im-1 +Δ, x im +Δ}

[0025] The final reconstructed point cloud data F′ is obtained:

[0026] F′={L′1, L′2, L′3, .., L′ n-1 , L′ n}

[0027] In some embodiments, step S2, the step of fitting a standard planar template based on point cloud data, specifically includes:

[0028] S21. Randomly select three non-collinear points on the point cloud data, take the plane containing these three points as the plane to be determined, and calculate its plane equation.

[0029] S22. Calculate the distance from each point in the point cloud data to the undetermined template plane in step S21. If the distance is less than a preset threshold, the point is considered to be on the undetermined plane. The total number of points in the point cloud data that are on the undetermined plane is obtained.

[0030] S23. Repeat steps S21 and S22 multiple times until the number of repetitions reaches a preset value, thereby obtaining multiple undetermined planes. Select the undetermined plane with the largest total number of points on the plane in the point cloud data as the standard plane template.

[0031] In some embodiments, if there are defects on the surface of the object being tested in step S4, the following steps are further included:

[0032] S5. Map the corresponding positions of all points with defects to a binary map. Find the connected component contour of each defect region based on the binary map, and calculate the bounding rectangle of each connected component contour. Determine the specific type of each defect based on the bounding rectangle and the connected component.

[0033] In some embodiments, step S5, mapping the locations of all defective points to a binary image, specifically includes the following steps:

[0034] First, start traversing from the top left edge of the point cloud data from left to right and from top to bottom;

[0035] Points with defects in point cloud data are called defect points. When the first defect point is encountered, it is saved as the starting point and the data is traversed and grown in the surrounding directions. If an adjacent defect point is found in any direction, it is saved as a point in the same connected component as the first defect point, and the traversal and growth continues until there are no adjacent defect points, thus obtaining a connected component.

[0036] Then, continue traversing, but no longer traversing points that are already in the connected components, until all points in the point cloud data have been traversed, all connected components have been found, and the corresponding positions of all connected components have been mapped to the binary graph.

[0037] In some embodiments, step S5, which involves finding the bounding rectangle of each connected component contour and determining the specific type of each defect based on the bounding rectangle and the connected component, specifically includes:

[0038] For any connected component, find the points corresponding to the maximum x-coordinate Xmax, minimum xmin, maximum y-coordinate Ymax, and minimum ymin in the connected component. Then the circumscribed rectangle is the rectangle that passes through these four points and has side lengths of Xmax-Xmin and Ymax-Ymin.

[0039] Let L and W represent the length and width of the circumscribed rectangle, respectively, and let N represent the number of points in the connected region.

[0040] If W / L is less than a preset threshold, or N / (W*L) is less than a preset threshold, then the defect type of the connected component is determined to be a scratch; otherwise, the defect type of the connected component is determined to be a dent.

[0041] In some embodiments, if the object under test has multiple surfaces, defect detection is performed on each surface separately.

[0042] In some embodiments, if the object under test has multiple surfaces, in step S3, for any point located at the boundary of adjacent surfaces, the absolute difference between that point and the standard plane template corresponding to each adjacent surface is calculated, the minimum value among the multiple calculation results is taken as the final determined absolute difference, and the point is assigned to the surface corresponding to the minimum value.

[0043] Compared with the prior art, the beneficial effects of the present invention are:

[0044] Unlike existing technologies that suffer from instability, non-quantitative production, and low efficiency in surface defect visual inspection, and conventional defect inspection equipment that primarily uses industrial cameras for data acquisition, the defect detection algorithm based on a line-scan spectral confocal camera provided in this invention uses line-scan spectral confocal imaging to acquire information about the surface of the object being inspected. This allows for excellent acquisition of depth information, leading to more accurate determination of whether a defect exists and its type. It exhibits excellent detection performance and is applicable to various object surfaces. Furthermore, this invention does not involve deep learning or require high-end hardware configurations, thus providing excellent real-time performance and meeting the inspection needs of production lines. Attached Figure Description

[0045] Figure 1 This is a flowchart illustrating the defect detection algorithm based on a line-scan spectral confocal camera provided by the present invention. Detailed Implementation

[0046] To make the technical means, creative features, objectives and effects of this invention easier to understand, the following description, in conjunction with the accompanying drawings and specific embodiments, further explains how this invention is implemented.

[0047] In one specific embodiment, refer to Figure 1 As shown, this invention provides a defect detection algorithm based on a line-scan spectral confocal camera, comprising the following steps:

[0048] S1. Point cloud data of the surface of the object under test is acquired by a line scan spectral confocal camera. This camera can capture the uneven features and depth information of the surface of the object under test.

[0049] S1': Reconstruct the point cloud data collected in step S1; and in subsequent steps, the point cloud data used will be the reconstructed point cloud data from step S1'.

[0050] In step S1', the specific steps for reconstructing the point cloud data include:

[0051] Since the point cloud data is acquired by a line-scan spectral confocal camera, the point cloud data F is represented as a line set:

[0052] F = {L1, L2, L3, ..., L...} n-2 L n-1 L n}

[0053] L1, L2, L3, ..., L n Each line in the line set refers to a line L. i It consists of several points, so it can be represented as a point set:

[0054] Li ={x i1 x i2 x i3 ,..,x im-2 x im-1 x im}

[0055] x i1 x i2 x i3 ,..,x im Each point in the point set is pointed to individually;

[0056] For any two adjacent lines L i and L i+1 The compensation value Δ is calculated using the following formula:

[0057] Δ=MEDIAN{x i1 -x (i+1)1 x i2 -x (i+1)2 x im -x (i+1)m}

[0058] Where MEDIAN represents the mean value;

[0059] Then, the compensated line L′ is obtained according to the following formula. i :

[0060] L′ i ={x i1 +Δ, x i2 +Δ, x i3 +Δ,..,x im-1 +Δ, x im +Δ}

[0061] The final reconstructed point cloud data F′ is obtained:

[0062] F′={L′1, L′2, L′3, .., L′ n-1 , L′ n}

[0063] S2. Fit a standard planar template based on the point cloud data, specifically including:

[0064] S21. Randomly select three non-collinear points on the point cloud data, take the plane containing these three points as the plane to be determined, and calculate its plane equation.

[0065] S22. Calculate the distance from each point in the point cloud data to the undetermined template plane in step S21. If the distance is less than a preset threshold, the point is considered to be on the undetermined plane. The total number of points in the point cloud data that are on the undetermined plane is obtained.

[0066] S23. Repeat steps S21 and S22 multiple times until the number of repetitions reaches a preset value, thereby obtaining multiple undetermined planes. Select the undetermined plane with the largest total number of points on the plane in the point cloud data as the standard plane template.

[0067] S3. Compare the point cloud data with the standard planar template obtained in step S2, and calculate the absolute difference of each point.

[0068] S4. Based on the absolute difference calculated in step S3, a threshold judgment is made. If the absolute difference of all points is not greater than the preset threshold, it is determined that there is no defect on the surface of the object being tested. If there are points with an absolute interpolation greater than the preset threshold, it is determined that there is a defect on the surface of the object being tested.

[0069] In step S4, if there are no defects on the surface of the object being tested, the process can be terminated; if there are defects on the surface of the object being tested, then proceed to the subsequent step S5.

[0070] S5. Map the corresponding positions of all points with defects to a binary map. Find the connected component contour of each defect region based on the binary map, and calculate the bounding rectangle of each connected component contour. Determine the specific type of each defect based on the bounding rectangle and the connected component.

[0071] Furthermore, in step S5, mapping the locations of all defective points to the binary image specifically includes the following steps:

[0072] First, start traversing from the top left edge of the point cloud data from left to right and from top to bottom;

[0073] Points with defects in point cloud data are called defect points. When the first defect point is encountered, it is saved as the starting point and the data is traversed and grown in the surrounding directions. If an adjacent defect point is found in any direction, it is saved as a point in the same connected component as the first defect point, and the traversal and growth continues until there are no adjacent defect points, thus obtaining a connected component.

[0074] Then, continue traversing, but no longer traversing points that are already in the connected components, until all points in the point cloud data have been traversed, all connected components have been found, and the corresponding positions of all connected components have been mapped to the binary graph.

[0075] In addition, step S5, which involves finding the bounding rectangle of each connected component contour and determining the specific type of each defect based on the bounding rectangle and the connected component, specifically includes:

[0076] For any connected component, find the points corresponding to the maximum x-coordinate Xmax, minimum xmin, maximum y-coordinate Ymax, and minimum ymin in the connected component. Then the circumscribed rectangle is the rectangle that passes through these four points and has side lengths of Xmax-Xmin and Ymax-Ymin.

[0077] Let L and W represent the length and width of the circumscribed rectangle, respectively, and let N represent the number of points in the connected region.

[0078] If W / L is less than a preset threshold, or N / (W*L) is less than a preset threshold, then the defect type of the connected component is determined to be a scratch; otherwise, the defect type of the connected component is determined to be a dent.

[0079] Generally, defects are categorized into scratches and dents. It's understood that scratches are characterized by their length being significantly greater than their width, or their connected regions occupying a relatively small proportion of the circumscribed rectangle. Therefore, this invention, utilizing the above-described scheme, can automatically determine the defect type. Furthermore, based on the sign of the difference between each defect point and the standard planar template, it can also be determined whether the defect is a convex or concave area relative to the surface.

[0080] In addition, if the object being tested has multiple surfaces, then in the above steps, defect detection is performed on each surface separately, and each surface is processed individually.

[0081] When the object under test has multiple surfaces, points located at the boundaries of adjacent surfaces in the point cloud data may be difficult to classify. Therefore, in step S3, for any point located at the boundary of adjacent surfaces, the absolute difference between the point and the standard planar template corresponding to each adjacent surface is calculated. The minimum value among the multiple calculation results is taken as the final determined absolute difference, and the point is assigned to the surface corresponding to the minimum value.

[0082] In summary, the defect detection algorithm based on a line-scan spectral confocal camera provided by this invention uses line-scan spectral confocal imaging to acquire information about the surface of the object being tested. This allows for excellent acquisition of depth information, leading to more accurate determination of whether a defect exists and its type. It exhibits excellent detection performance and is applicable to various object surfaces. Furthermore, this invention does not involve deep learning or require high-end hardware configurations, eliminating the need for extensive manual data collection, labeling, and model training. Therefore, it offers excellent real-time performance, meeting the inspection needs of production lines. The algorithm provided by this invention can be used, but is not limited to, surface defect detection in industries such as parts processing, pharmaceuticals, and textiles.

[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A defect detection algorithm based on a line-scan spectral confocal camera, characterized in that, Includes the following steps: S1. Acquire point cloud data of the surface of the object under test using a line scan spectral confocal camera; S2. Fit a standard planar template based on point cloud data; S3. Compare the point cloud data with the standard planar template obtained in step S2, and calculate the absolute difference of each point. S4. Based on the absolute difference calculated in step S3, a threshold judgment is made. If the absolute difference of all points is not greater than the preset threshold, it is determined that there is no defect on the surface of the object being tested. If there are points with an absolute interpolation value greater than the preset threshold, it is determined that there is a defect on the surface of the object being tested. After step S1 and before step S2, the following steps are also included: S1' Reconstruct the point cloud data collected in step S1; Furthermore, in subsequent steps, the point cloud data used are all the reconstructed point cloud data from step S1'. In step S1', the specific steps for reconstructing the point cloud data include: Since the point cloud data was acquired using a line-scan spectral confocal camera, the point cloud data... Represented as a line set: ; Each line in the line set refers to a single line within the set. It consists of several points, so it can be represented as a point set: ; Each point in the point set is pointed to individually; For any two adjacent lines and The compensation value is obtained by the following formula. : ; in, This indicates finding the midpoint; Then, the compensated line is obtained according to the following formula. : Finally, the reconstructed point cloud data is obtained. ': 。 2. The defect detection algorithm based on a line-scan spectral confocal camera according to claim 1, characterized in that, Step S2, the step of fitting a standard planar template based on point cloud data, specifically includes: S21. Randomly select three non-collinear points on the point cloud data, take the plane containing these three points as the plane to be determined, and calculate its plane equation. S22. Calculate the distance from each point in the point cloud data to the undetermined template plane in step S21. If the distance is less than a preset threshold, the point is considered to be on the undetermined plane. The total number of points in the point cloud data that are on the undetermined plane is obtained. S23. Repeat steps S21 and S22 multiple times until the number of repetitions reaches a preset value, thereby obtaining multiple undetermined planes. Select the undetermined plane with the largest total number of points on the plane in the point cloud data as the standard plane template.

3. The defect detection algorithm based on a line-scan spectral confocal camera according to claim 1, characterized in that, In step S4, if there are defects on the surface of the object being tested, the following steps are also included: S5. Map the corresponding positions of all points with defects to a binary map. Find the connected component contour of each defect region based on the binary map, and calculate the bounding rectangle of each connected component contour. Determine the specific type of each defect based on the bounding rectangle and the connected component.

4. The defect detection algorithm based on a line-scan spectral confocal camera according to claim 3, characterized in that, In step S5, mapping the locations of all defective points to the binary image specifically includes the following steps: First, start traversing from the top left edge of the point cloud data from left to right and from top to bottom; Points with defects in point cloud data are called defect points. When the first defect point is encountered, it is saved as the starting point and the data is traversed and grown in the surrounding directions. If an adjacent defect point is found in any direction, it is saved as a point in the same connected component as the first defect point, and the traversal and growth continues until there are no adjacent defect points, thus obtaining a connected component. Then, continue traversing, but no longer traversing points that are already in the connected components, until all points in the point cloud data have been traversed, all connected components have been found, and the corresponding positions of all connected components have been mapped to the binary graph.

5. The defect detection algorithm based on a line-scan spectral confocal camera according to claim 3, characterized in that, In step S5, the steps of finding the bounding rectangle of each connected component contour and determining the specific type of each defect based on the bounding rectangle and the connected component specifically include: For any connected component, find the points corresponding to the maximum x-coordinate Xmax, minimum xmin, maximum y-coordinate Ymax, and minimum ymin in the connected component. Then the circumscribed rectangle is the rectangle that passes through these four points and has side lengths of Xmax-Xmin and Ymax-Ymin. Let L and W represent the length and width of the circumscribed rectangle, respectively, and let N represent the number of points in the connected region. If W / L is less than a preset threshold, or N / (W*L) is less than a preset threshold, then the defect type of the connected component is determined to be a scratch; otherwise, the defect type of the connected component is determined to be a dent.

6. The defect detection algorithm based on a line-scan spectral confocal camera according to claim 1, characterized in that, If the object being tested has multiple surfaces, then defect detection is performed on each surface separately.

7. The defect detection algorithm based on a line-scan spectral confocal camera according to claim 6, characterized in that, If the object being measured has multiple surfaces, in step S3, for any point located at the boundary between adjacent surfaces, the absolute difference between that point and the standard plane template corresponding to each adjacent surface is calculated. The minimum value among the multiple calculation results is taken as the final determined absolute difference, and the point is assigned to the surface corresponding to the minimum value.

Citation Information

Patent Citations

  • Method and device for detecting surface of weld joint of nuclear fuel rod

    CN109978865A

  • Part surface defect detection method based on line laser scanning and machine vision

    CN112304954A