Part appearance defect detection method, device and equipment and storage medium
Through multi-camera arrangement and photometric stereo imaging technology, combined with template matching and image classification modules, the accuracy problem of surface defect detection of metal parts with complex geometric structures is solved, achieving all-round photometric stereo imaging without blind spots, and improving the recall of the inspection system. rate and accuracy.
Patent Information
- Application Number
- CN202410967378.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-07-18
AI Technical Summary
Existing technology is difficult to effectively detect surface defects of metal parts with complex geometric structures, especially the lack of depth, normal direction, curvature and other micro-feature information under 2D imaging, resulting in a high missed detection rate, many false detection signals, and a lack of targeted detection. Accurate detection solution for raised or recessed structures.
Using multi-camera arrangement and photometric stereo imaging technology, the camera is set up at a preset position to obtain images of parts under different lighting conditions, and image mixing and preprocessing are performed. Combined with template matching and image classification modules, it achieves all-round photometric stereo without blind spots. Imaging, obtaining more depth and normal direction information, improving the recall rate and accuracy of the detection algorithm.
It achieves high-accuracy detection of surface defects of metal parts with complex geometric structures, reduces the missed detection and false detection rates, and improves the practicability and stability of the detection system.
Smart Images

Figure CN118777310A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of parts detection, and in particular to a method, device, equipment and storage medium for detecting appearance defects of parts. Background Art
[0002] Appearance inspection refers to the testing or measurement activities carried out to determine whether the product meets the quality standards and technical requirements specified in the design. Traditional appearance inspection mainly relies on manpower, which has problems such as high workload, high repetitiveness, easy fatigue due to long-term work, and increased subjective errors.
[0003] At present, most of the existing technical solutions are aimed at detecting two-dimensional planar materials, and the lighting solutions mostly use coaxial light sources. Most of the research in the field of surface defect detection is aimed at plane or continuous curved surface backgrounds. Defects are often only clearly visible under specific lighting angles. At the same time, due to the convex or concave shape of the part, the camera at a single position inevitably cannot capture the entire structure of the part. Therefore, it is usually necessary to use multiple cameras or rotate and move the part for multiple shots. This type of 2D imaging method lacks microscopic feature information such as depth, normal direction, and curvature when detecting metal surfaces with concave and convex structures. It is difficult to detect small defects such as pores and slag inclusions, and the missed detection rate is high. For pseudo defects such as oxide scale and water stains and defects with depth information such as cracks and roller marks, the features on the 2D grayscale image are very similar and easy to confuse. In the production process, the proportion of non-defects is often much higher than that of real defects, which brings a large number of false detection signals and significantly reduces the practicality of the surface defect detection system. At present, there is no mature surface defect detection solution for metal parts with complex geometric structures. Therefore, the inventors of the present invention provide a method, device, equipment and storage medium for detecting appearance defects of parts to solve the above problems. Summary of the invention
[0004] In order to solve the above problems, the purpose of the present invention is to provide a method, device, equipment and storage medium for part appearance defect detection, which realizes all-round photometric stereo imaging without blind spots, and improves the recall rate and stability of the detection algorithm by collecting more information such as the surface depth and normal direction of metal parts.
[0005] Based on this, the present invention provides a method for detecting appearance defects of parts, the method comprising:
[0006] A plurality of images of the part to be inspected under different lighting conditions are obtained by setting cameras at preset positions. The number of cameras is set so that there is no blind spot for the part to be inspected, and each camera is set at a different position;
[0007] Preprocessing the image of the part to be detected, and mixing the image of the part to be detected captured by each camera to obtain a pseudo-color image of the part to be detected at a preset angle;
[0008] The pseudo-color images are input into a preset defect detector, the defect detector outputs a recognition result, and the parts to be detected are graded according to the recognition result.
[0009] Wherein, preprocessing the image of the part to be detected includes:
[0010] Cropping the image of the part to be detected specifically includes:
[0011] The image of the part to be inspected is divided into slices of fixed size, and adjacent slices after division retain a preset percentage of overlapping areas, where the preset percentage is 15 percent.
[0012] Wherein, the images of the part to be detected captured by each camera are mixed to obtain a pseudo-color image of the part to be detected at a preset angle, including:
[0013] Mixing n images of the same size captured by each camera into a three-channel image according to a mixing algorithm;
[0014] The hybrid algorithm includes:
[0015]
[0016] The mixed image is denoted as G, and the images of the three channels are denoted as G1, G2, and G3 respectively. ij is the mixing coefficient, which can be represented by a 3×n matrix. The mixed image G can be displayed in RGB mode.
[0017] Wherein, the defect detector comprises:
[0018] A template matching module and an image classification module connected in sequence;
[0019] The template matching module is used to extract the part contour in the pseudo-color image, and match the part contour with a preset defect-free part contour template to determine whether the part to be inspected has a missing contour;
[0020] The image classification module is used to classify the pseudo-color images without the missing contour, classify the pseudo-color images belonging to the same defect into one category, and mark the defect position, size, and category of the pseudo-color images through labels.
[0021] The method further includes: randomly extracting the pseudo-color image input into the defect detector, performing contrast enhancement on the pseudo-color image, and receiving manual defect annotations on the pseudo-color image.
[0022] Wherein, the method further comprises:
[0023] Comparing the manual defect annotation of the pseudo-color image with the annotation of the pseudo-color image by the defect detector to determine the accuracy of the defect detector;
[0024] If the accuracy is lower than a preset accuracy threshold, the use of the defect detector is suspended and the defect detector is retrained to improve the defect detection accuracy.
[0025] Wherein, the method further comprises: controlling the light emitting state of the light source by a PWM controller so that the part to be inspected is placed under different lighting conditions.
[0026] The embodiment of the present invention further provides a device for detecting appearance defects of parts, the device comprising:
[0027] An acquisition module, used to acquire a plurality of images of the part to be inspected under different lighting conditions by using cameras arranged at preset positions, wherein the number of cameras is set so that there is no blind spot for photographing the part to be inspected, and each camera is arranged at a different position;
[0028] A processing and mixing module, used for preprocessing the image of the part to be detected, and mixing the image of the part to be detected captured by each camera to obtain a pseudo-color image of the part to be detected at a preset angle;
[0029] The detection and grading module is used to input the pseudo-color images into a preset defect detector, the defect detector outputs a recognition result, and the parts to be detected are graded according to the recognition result.
[0030] An embodiment of the present invention also provides a part appearance defect detection device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the above-mentioned part appearance defect detection method when executing the computer program.
[0031] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned part appearance defect detection method.
[0032] In the present invention, multiple light sources and multiple cameras cooperate with each other and work together in a high-speed continuous shooting mode, thereby realizing photometric stereo imaging without blind spots for multi-angle lighting and multi-angle shooting. The advantage of this multi-camera arrangement is that it can capture multiple perspectives at the same time, eliminating factors that may usually cause occlusion and shadow problems. By adopting photometric stereo lighting technology, different lighting methods are used in each frame of shooting, and the same scene is shot under different lighting conditions, thereby increasing the information collection of the target object, i.e., the part to be detected. Preprocessing the image of the part to be detected, i.e., cropping and image enhancement of the image of the part to be detected, can help the model capture more pixels to identify the characteristics of small defects and reduce the amount of calculation. The main function of the defect detector is to identify defects from the feature map, classify or grade the defects, and mark the position, size, edge, and category of the defects in the image of the part to be detected by labels. The method of the present invention can effectively improve the accuracy of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 is a flow chart of a method for detecting appearance defects of parts provided by an embodiment of the present invention;
[0035] Figure 2 is a schematic diagram of cutting the image of the part to be detected provided by an embodiment of the present invention;
[0036] Figure 3 Schematic diagram of a device for detecting appearance defects of parts provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Figure 1 : is a flow chart of a method for detecting appearance defects of parts provided by an embodiment of the present invention, the method comprising:
[0039] S101. Acquire several images of the part to be inspected under different lighting conditions by setting cameras at preset positions, wherein the number of cameras is set so that there is no blind spot for the part to be inspected, and each camera is set at a different position;
[0040] Wherein, the method further comprises: controlling the light emitting state of the light source by a PWM controller so that the part to be inspected is placed under different lighting conditions.
[0041] Optionally, the transistor synchronization signal generator controls the light source and industrial camera through a set of synchronization signals to continuously illuminate and take pictures. The number of industrial cameras can be m and the number of light sources can be k. These cameras and light sources are arranged in a staggered manner up and down around the detection target, i.e., the part to be detected, to ensure that every angle of the part to be detected can be photographed and illuminated to prevent blind spots.
[0042] Here’s how it works:
[0043] N continuous frame sequences are sent out through the transistor synchronous signal generator, recorded as 1 to n. In each frame, several light sources illuminate the part to be inspected, and a specific industrial camera takes a picture at the same time. When all frame sequences are completed, a total of m×n images taken from m angles can be obtained. By mixing the images of each perspective according to different channels, a photometric stereo image of m perspectives can be obtained.
[0044] When all frame sequences are completed, a total of m×n images taken from m angles can be obtained. By mixing the images of each perspective according to different channels, a photometric stereo image of m perspectives can be obtained.
[0045] S102. Preprocessing the image of the part to be detected, mixing the images of the part to be detected captured by each camera to obtain a pseudo-color image of the part to be detected at a preset angle;
[0046] Wherein, preprocessing the image of the part to be detected includes:
[0047] Cropping the image of the part to be detected specifically includes:
[0048] The image of the part to be inspected is divided into slices of fixed size, and adjacent slices after division retain a preset percentage of overlapping areas, where the preset percentage is 15 percent. Figure 2 is a schematic diagram of cutting the image of the part to be detected provided by an embodiment of the present invention, please refer to Figure 2 .
[0049] Industrial surface defect detection tasks are shot with high-resolution cameras, and the image resolution is as high as 2560×1920 pixels. The defect size in the metal parts surface defect detection task is very small, and some defects are only 0.5mm. Therefore, the use of high-resolution images helps to capture more pixels to identify the characteristics of tiny defects. In order to process high-resolution images, the present invention uses sliding cutting to divide the original image into slices of fixed size. Adjacent slices after cutting retain 15% overlapping area to ensure that defects in any area can be fully detected. Note: These preprocessing are only for the convenience of software and hardware to process the image, and are not the key steps of the present invention. Failure to slice the image will increase the hardware overhead, but will not affect the practicality of the present invention.
[0050] Wherein, the images of the part to be detected captured by each camera are mixed to obtain a pseudo-color image of the part to be detected at a preset angle, including:
[0051] Mixing n images of the same size captured by each camera into a three-channel image according to a mixing algorithm;
[0052] The hybrid algorithm includes:
[0053]
[0054] The mixed image is denoted as G, and the images of the three channels are denoted as G1, G2, and G3 respectively. ij is the mixing coefficient, which can be represented by a 3×n matrix θ, and the mixed image G can be displayed in RGB mode. The value of the parameter matrix θ is initialized as:
[0055]
[0056] Make the images of different light source illumination angles orthogonal to each other in the three RGB channels. The matrix form of θ here is only a mathematical expression of the light source brightness parameter, and is not the only implementation method of the invention. For example:
[0057] A deep convolutional network with n input channels, 3 output channels, and a convolution kernel size of 1x1 is used to achieve image mixing, and θ is the weight matrix of the convolution kernel. The mixing operation is performed on the tensor to maintain the gradient flow, so θ can be optimized through backpropagation to improve the overall performance of defect detection.
[0058] S103. Input the pseudo-color images into a preset defect detector, which outputs a recognition result, and classifies the parts to be detected according to the recognition result.
[0059] Wherein, the defect detector comprises:
[0060] A template matching module and an image classification module connected in sequence;
[0061] The template matching module is used to extract the part contour in the pseudo-color image, and match the part contour with a preset defect-free part contour template to determine whether the part to be inspected has a missing contour;
[0062] The image classification module is used to classify the pseudo-color images without the missing contour, classify the pseudo-color images belonging to the same defect into one category, and mark the defect position, size, and category of the pseudo-color images through labels.
[0063] The template matching module is used to screen out some major defects of the parts to be inspected, i.e., defects of missing contours. At this time, the parts to be inspected with contour defects are first-class defective products. The parts to be inspected without missing contours need to be further inspected by the image classification module for some minor defects such as pitting, burrs, etc.
[0064] Parts with minor defects in a preset first number range can be classified as second-level defective products, and parts with minor defects in a preset second number range can be classified as third-level defective products, wherein the lowest value of the second number range is greater than the highest value of the first number range.
[0065] The image classification module may have a built-in defect library, which includes pseudo-color images of different types of minor defects. The size of the pseudo-color image of the minor defect is pre-set and smaller than the pseudo-color image of the part to be detected. Multiple pseudo-color images of minor defects may be moved from top to bottom and from left to right by a preset unit distance to traverse the pseudo-color image of the part to be detected in turn for comparison. When the comparison is consistent, the part to be detected has the defect. A part to be detected may also have multiple defects.
[0066] Defect results can be slag inclusions, pits, burrs, etc.
[0067] The method further includes: randomly extracting the pseudo-color image input into the defect detector, performing contrast enhancement on the pseudo-color image, and receiving manual defect annotations on the pseudo-color image.
[0068] The purpose of further manually marking defects on the pseudo-color image is to verify the accuracy of the defect detector.
[0069] Wherein, the method further comprises:
[0070] Comparing the manual defect annotation of the pseudo-color image with the annotation of the pseudo-color image by the defect detector to determine the accuracy of the defect detector;
[0071] If the accuracy is lower than a preset accuracy threshold, the use of the defect detector is suspended and the defect detector is retrained to improve the defect detection accuracy.
[0072] The defect detector may include models for target detection such as YOLO, FCOS, RT-DETR, CASCADE-RCNN, and their improved versions.
[0073] In the present invention, multiple light sources and multiple cameras cooperate with each other and work together in a high-speed continuous shooting mode, thereby realizing photometric stereo imaging without blind spots for multi-angle lighting and multi-angle shooting. The advantage of this multi-camera arrangement is that it can capture multiple perspectives at the same time, eliminating factors that may usually cause occlusion and shadow problems. By adopting photometric stereo lighting technology, different lighting methods are used in each frame of shooting, and the same scene is shot under different lighting conditions, thereby increasing the information collection of the target object, i.e., the part to be detected. Preprocessing the image of the part to be detected, i.e., cropping and image enhancement of the image of the part to be detected, can help the model capture more pixels to identify the characteristics of small defects and reduce the amount of calculation. The main function of the defect detector is to identify defects from the feature map, classify or grade the defects, and mark the position, size, edge, and category of the defects in the image of the part to be detected by labels. The method of the present invention can effectively improve the accuracy of defect detection.
[0074] Figure 3 is a schematic diagram of a device for detecting appearance defects of parts provided by an embodiment of the present invention, the device comprising:
[0075] An acquisition module 301 is used to acquire a plurality of images of the part to be inspected under different lighting conditions by using cameras arranged at preset positions. The number of cameras is set so that there is no blind spot for the part to be inspected, and each camera is arranged at a different position;
[0076] A processing and mixing module 302 is used to pre-process the image of the part to be detected, and mix the image of the part to be detected captured by each camera to obtain a pseudo-color image of the part to be detected at a preset angle;
[0077] The detection and grading module 303 is used to input the pseudo-color images into a preset defect detector, the defect detector outputs a recognition result, and grades the parts to be detected according to the recognition result.
[0078] The technical features and technical effects of a part appearance defect detection device proposed in an embodiment of the present invention are the same as those of the method proposed in an embodiment of the present invention, and will not be elaborated here.
[0079] An embodiment of the present invention also provides a part appearance defect detection device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the above-mentioned part appearance defect detection method when executing the computer program.
[0080] An embodiment of the present invention further provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned part appearance defect detection method.
[0081] In the present invention, multiple light sources and multiple cameras cooperate with each other and work together in a high-speed continuous shooting mode, thereby realizing photometric stereo imaging without blind spots for multi-angle lighting and multi-angle shooting. The advantage of this multi-camera arrangement is that it can capture multiple perspectives at the same time, eliminating factors that may usually cause occlusion and shadow problems. By adopting photometric stereo lighting technology, different lighting methods are used in each frame of shooting, and the same scene is shot under different lighting conditions, thereby increasing the information collection of the target object, i.e., the part to be detected. Preprocessing the image of the part to be detected, i.e., cropping and image enhancement of the image of the part to be detected, can help the model capture more pixels to identify the characteristics of small defects and reduce the amount of calculation. The main function of the defect detector is to identify defects from the feature map, classify or grade the defects, and mark the position, size, edge, and category of the defects in the image of the part to be detected by labels. The method of the present invention can effectively improve the accuracy of defect detection.
[0082] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and substitutions can be made without departing from the technical principles of the present invention. These improvements and substitutions should also be regarded as the scope of protection of the present invention.
Claims
1. A method for detecting appearance defects of parts, characterized in that: include: A plurality of images of the part to be inspected under different lighting conditions are obtained by setting cameras at preset positions. The number of cameras is set so that there is no blind spot for the part to be inspected, and each camera is set at a different position; Preprocessing the image of the part to be detected, and mixing the image of the part to be detected captured by each camera to obtain a pseudo-color image of the part to be detected at a preset angle; The pseudo-color images are input into a preset defect detector, the defect detector outputs a recognition result, and the parts to be detected are graded according to the recognition result.
2. The method for detecting appearance defects of parts according to claim 1, characterized in that: Preprocessing the image of the part to be detected includes: Cropping the image of the part to be detected specifically includes: The image of the part to be inspected is divided into slices of fixed size, and adjacent slices after division retain a preset percentage of overlapping areas, where the preset percentage is 15 percent.
3. The method for detecting appearance defects of parts according to claim 1, characterized in that: The images of the part to be detected captured by each camera are mixed to obtain a pseudo-color image of the part to be detected at a preset angle, including: Mixing n images of the same size captured by each camera into a three-channel image according to a mixing algorithm; The hybrid algorithm includes: The mixed image is denoted as G, and the images of the three channels are denoted as G1, G2, and G3 respectively. ij is the mixing coefficient, which can be represented by a 3×n matrix. The mixed image G can be displayed in RGB mode.
4. The method for detecting appearance defects of parts according to claim 1, characterized in that: The defect detector comprises: A template matching module and an image classification module connected in sequence; The template matching module is used to extract the part contour in the pseudo-color image, and match the part contour with a preset defect-free part contour template to determine whether the part to be inspected has a missing contour; The image classification module is used to classify the pseudo-color images without the missing contour, classify the pseudo-color images belonging to the same defect into one category, and mark the defect position, size, and category of the pseudo-color images through labels.
5. The method for detecting appearance defects of parts according to claim 1, characterized in that: The method further includes: randomly extracting the pseudo-color image input into the defect detector, performing contrast enhancement on the pseudo-color image, and receiving manual defect annotations on the pseudo-color image.
6. The method for detecting appearance defects of parts according to claims 4 and 5, characterized in that: The method further comprises: Comparing the manual defect annotation of the pseudo-color image with the annotation of the pseudo-color image by the defect detector to determine the accuracy of the defect detector; If the accuracy is lower than a preset accuracy threshold, the use of the defect detector is suspended and the defect detector is retrained to improve the defect detection accuracy.
7. The method for detecting appearance defects of parts according to claim 1, characterized in that: The method further comprises: controlling the lighting condition of the light source by a PWM controller so that the part to be inspected is placed under different lighting conditions.
8. A device for detecting defects in the appearance of parts, characterized in that: include: An acquisition module, used to acquire a plurality of images of the part to be inspected under different lighting conditions by using cameras arranged at preset positions, wherein the number of cameras is set so that there is no blind spot for photographing the part to be inspected, and each camera is arranged at a different position; A processing and mixing module, used for preprocessing the image of the part to be detected, and mixing the image of the part to be detected captured by each camera to obtain a pseudo-color image of the part to be detected at a preset angle; The detection and grading module is used to input the pseudo-color images into a preset defect detector, the defect detector outputs a recognition result, and the parts to be detected are graded according to the recognition result.
9. A part appearance defect detection device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the part appearance defect detection method as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the method for detecting appearance defects of parts as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Omnidirectional and visual on-line detection system of surface defects of strip-shaped workpiece
CN104634791A
Method for detecting surface defects
CN108827971A
Cylinder two-dimensional image generation method based on plurality of RGB-D cameras
CN111932599A
Segment code liquid crystal screen defect detection method based on machine vision
CN113344872A
Appearance defect detection method and device, visual detection system and electronic equipment
CN117392079A
Cited By
Image-based apparent defect detection method, apparatus, medium, and program
CN122023425A
Image-based appearance defect detection method, device, medium, and program
CN122023425B
