A defect detection system and a defect detection method
Patent Information
- Application Number
- CN202310230176.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-10
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2043-03-10
AI Technical Summary
[0002]关于一种汽车配件中的法兰,其通过毛胚烧结、压制成型、车削等加工工艺制成的,在加工过程中可能存在凹坑、缺料、阴阳面、震刀、划痕等情况,这几种情况均会导致法兰达不到密封效果,安装后出现漏油后果,甚至可能存在后续用车安全隐患,因此需要进行外观缺陷检测
[0023] 1) This invention replaces human labor with machines, that is, it uses an automated non-contact optical inspection system to perform full inspection of the appearance and dimensions of the flange, eliminating unqualified products. Optical image detection replaces human eyes, has no vision requirements, and ensures clarity. It also avoids the problems of personal injury and reduced efficiency caused by long-term manual labor. Furthermore, the machine judgment has strong consistency, avoids randomness, and ensures the overall quality of the flange.
Smart Images

Figure CN116140225B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of optical inspection systems and relates to a defect detection system and a defect detection method. Background Technology
[0002] Regarding a flange in an automotive part, which is made through processes such as blank sintering, pressing, and turning, there may be issues such as pits, missing material, uneven surfaces, vibration, and scratches during the processing. These issues can all lead to the flange failing to achieve a sealing effect, resulting in oil leaks after installation, and may even pose safety hazards for subsequent vehicle use. Therefore, it is necessary to conduct appearance defect inspection.
[0003] Currently, most automotive flange manufacturers use manual visual inspection during final inspection to detect defects in the appearance of such flanges. This manual inspection method has the following shortcomings: (1) It requires high visual acuity; (2) It is labor-intensive and causes great damage to the eyes; (3) It is a manual judgment, which is highly random and the quality of the flange cannot be guaranteed; (4) It is inefficient and the continuous working time cannot be too long, which affects production efficiency; (5) The increasingly high labor costs also bring great pressure to enterprises.
[0004] Meanwhile, due to the characteristics of its processing technology, flange products often have distinctions between the front and back sides, as well as distinctions in the features inside the through holes. These distinctions will first bring more workload and affect efficiency in manual inspection work, and will also bring greater inspection errors and randomness. Summary of the Invention
[0005] In order to overcome the shortcomings of the prior art, the present invention provides a defect detection system and a defect detection method.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: a defect detection system, comprising a detection device and an analysis and processing unit, wherein,
[0007] The detection device includes a stage, a telecentric light source, a horizontal light source, a coaxial light source, and a camera. The stage is used to load workpieces, including workpieces with through holes and workpieces without through holes. When the telecentric light source is turned on, the camera obtains a projected image of the workpiece. When the coaxial light source is turned on, the camera obtains a first surface image of the workpiece. When the horizontal light source is turned on, the camera obtains a second surface image of the workpiece.
[0008] The analysis and processing unit is used to detect whether the workpiece is a through-hole workpiece or a non-through-hole workpiece based on the projected image, to detect the front or back of the workpiece and a first type of defect based on the first surface image, and to detect a second type of defect of the workpiece based on the second surface image.
[0009] Furthermore, the coaxial light source and the telecentric light source are located above and below the stage, respectively, and both illuminate the stage to provide vertical illumination to the workpiece; the horizontal light source is located above the stage and below the coaxial light source, and includes four strip light sources forming a U-shape to provide oblique illumination to the side of the workpiece; the camera is located above the coaxial light source and shoots downwards.
[0010] Furthermore, it also includes a vibrating screen, a conveyor belt, a photoelectric sensor, and a gantry robot. The vibrating screen is located at one side of the conveyor belt, and the detection device is located at the other side of the conveyor belt. The conveyor belt travels from the vibrating screen to the detection device. The photoelectric sensor is located on the conveyor belt and is communicatively connected to the conveyor belt and the gantry robot. The gantry robot is located at the other side of the conveyor belt.
[0011] Furthermore, the detection device also includes a housing, in which the camera, the coaxial light source, the horizontal light source, the stage, and the telecentric light source are arranged from top to bottom; the housing has an opening and also includes a telescopic mechanism for driving the stage through the opening and extending out of the housing, the stage being connected to the telescopic end of the telescopic mechanism.
[0012] A defect detection method, applied to the aforementioned defect detection system, includes the following steps:
[0013] S1. The telecentric light source is used to illuminate the back of the workpiece from below the stage, and the camera is used to acquire the projected image of the workpiece from above the stage. The analysis and processing unit calls the corresponding template to match the workpiece, and determines whether the workpiece is a through-hole workpiece or a non-through-hole workpiece based on the matched template.
[0014] S2. The coaxial light source is used to illuminate the top surface of the workpiece above the stage, and the camera is used to acquire a grayscale image of the workpiece above the coaxial light source. The analysis and processing unit determines whether the current surface is the front or the back.
[0015] S3. The coaxial light source or the horizontal light source is used to illuminate the top surface of the workpiece above the stage. The camera is used above the coaxial light source to acquire surface images of the front and back of the workpiece. The analysis and processing unit performs defect detection on the surface images of the front and back respectively.
[0016] S3.1 When the workpiece is a through-hole workpiece, perform defect detection procedures on the front and back of the workpiece respectively;
[0017] S3.2 When the workpiece is a non-through hole workpiece, the defect detection process shall be carried out on the front and back of the workpiece respectively. During the detection process, when the front side of the workpiece is the back side of the workpiece, the outer diameter of the non-through hole of the workpiece shall be measured.
[0018] S4. The telecentric light source is used to illuminate the back of the workpiece from below the stage, and the camera is used to acquire a projected image of the workpiece from above the stage. The analysis and processing unit performs a size measurement process based on the projected image.
[0019] Furthermore, in step S3, the surface image includes a first surface image and a second surface image. The acquisition of the first surface image includes using a camera above the coaxial light source to capture the image when the workpiece is vertically illuminated by a coaxial light source. The acquisition of the second surface image includes using a camera above the workpiece when the workpiece is obliquely illuminated by a horizontal light source. The first surface image is used for detecting defects such as pits, missing material, vibration, and uneven surfaces. The second surface image is used for detecting scratch defects.
[0020] Furthermore, dents and material shortages are identified using grayscale. Figure 2 After value-based processing, the area of connected regions with a gray value of 0 is extracted for judgment; for defects such as vibration and uneven surfaces, the optimal threshold is obtained by mean filtering the surface image and comparing it with the set value for judgment; for scratch defects, a deep learning method is used for judgment.
[0021] Furthermore, in step S3.2, the outer diameter of the non-through hole of the workpiece is measured based on the first surface image.
[0022] In summary, the advantages of this invention are:
[0023] 1) This invention replaces human labor with machines, that is, it uses an automated non-contact optical inspection system to perform full inspection of the appearance and dimensions of the flange, eliminating unqualified products. Optical image detection replaces human eyes, has no vision requirements, and ensures clarity. It also avoids the problems of personal injury and reduced efficiency caused by long-term manual labor. Furthermore, the machine judgment has strong consistency, avoids randomness, and ensures the overall quality of the flange.
[0024] 2) This invention achieves the differentiation of the front and back sides of the flange and the differentiation of through hole features by replacing human labor with machines. The differentiation work is based on the normal process of the detection system, without adding an additional detection item as in manual detection, which would increase the detection time and effectively ensure detection efficiency.
[0025] 3) The reasonable layout of the camera, coaxial light source, telecentric light source, and horizontal light source relative to the stage eliminates the need for positional changes. Simply controlling the on / off state of each light source allows the camera to acquire images under various light sources, which is sufficient to cover the required inspections, including size and appearance. The structure is simple and reasonable, and the inspection effect is good.
[0026] 4) The vibrating screen disc enables the individual shaking of multiple workpieces, the conveyor belt enables the automatic transport of workpieces, and the photoelectric sensor, together with the gantry robot, enables the identification, gripping and transport of workpieces. The entire process is automated, significantly reducing labor costs.
[0027] 5) The camera and various light sources are housed in a shell, which can prevent external light interference to a certain extent. In addition, the telescopic structure is used in conjunction with the gantry robot, so that the workpiece can be picked up and placed outside the shell without the robot reaching into the shell, which simplifies the mechanical structure and makes the operation more reasonable.
[0028] 6) In the inspection process, workpieces are classified by template matching, and the front and back sides are used to distinguish the current state of the workpieces. The optimal inspection sequence is set according to the category and state of the workpieces, which ensures full inspection of the project and optimizes the inspection process. Compared with manual inspection, the inspection efficiency is greatly improved.
[0029] 7) The three types of defects—dimples, uneven surfaces caused by vibration, and scratches—are distinguished and detected using different light source illumination methods and different surface treatment identification methods. This approach is highly targeted, accurate, and results in high-quality finished products. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the defect detection system of the present invention.
[0031] Figure 2 This is a schematic diagram of the detection device in a defect detection system.
[0032] Figure 3 This is a schematic flowchart of the defect detection method of the present invention.
[0033] Figure 4 This is a schematic diagram of the template matching process of the present invention.
[0034] Figure 5 This is a schematic diagram of the dimension measurement process of the present invention.
[0035] Figure 6 This is a schematic diagram showing the dimensional composition of the flange of the present invention.
[0036] The following are labeled in the diagram: 1. Detection device; 11. Telecentric light source; 12. Coaxial light source; 13. Horizontal light source; 14. Camera; 15. Stage; 16. Housing; 17. Telecentric lens; 2. Frame robot; 3. Conveyor belt; 4. Vibrating screen; 5. Photoelectric sensor. Detailed Implementation
[0037] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.
[0038] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0039] In this embodiment of the invention, all directional indicators (such as up, down, left, right, front, back, lateral, longitudinal, etc.) are only used to explain the relative positional relationship and movement of each component in a specific posture. If the specific posture changes, the directional indicator will also change accordingly.
[0040] like Figure 1 As shown, a detection system includes a vibrating screen 4, a conveyor belt 3, a gantry robot 2, a photoelectric sensor 5, and a detection device 1, etc., and is used to detect surface defects, analyze, count and sort qualified and unqualified products on the workpiece (specifically a flange).
[0041] In this embodiment, the detection system employs a machine-based approach. The vibrating screen 4 is positioned at one end of the conveyor belt 3, and the detection device 1 is positioned at the other end. The detection device 1 contains an analysis and processing unit, which is communicatively connected to the conveyor belt 3, the overhead robot 2, and the photoelectric sensor 5. When screening multiple flanges, the flanges are laid flat on the vibrating screen 4, and the vibration of the screen 4 causes the flanges to fall sequentially onto the conveyor belt 3. The conveyor belt 3 then transports the flanges towards the detection device 1. The photoelectric sensor 5 is positioned at... The position on the conveyor belt 3 near the detection device 1 is also within the working range of the gantry robot 2. Its photoelectric detection range covers the area above the conveyor belt 3 at this position. When the flange moves into the detection range, the photoelectric sensor 5 triggers the conveyor belt 3 to stop, and at the same time triggers the gantry robot 2 to grab the flange and place it in the detection device 1. After the detection device 1 completes the detection, the analysis and processing unit sends a detection result classification signal and a grab signal to the gantry robot 2. The gantry robot 2 grabs qualified and unqualified products into the conveyor belt 3 and the waste box respectively according to the classification signal.
[0042] The gantry robot 2 is equipped with a controller, which is used to control the movement of the gantry robot 2 and to communicate with the analysis and processing unit, photoelectric sensor 5, etc.
[0043] The detection device 1 includes a housing 16, within which a camera 14, a coaxial light source 12, a horizontal light source 13, and a telecentric light source 11 are fixedly arranged from top to bottom. The camera 14 faces directly downwards to take pictures. Specifically, the camera 14 is coaxially arranged with the coaxial light source 12 and the telecentric light source 11. A platform 15 is arranged between the coaxial light source 12 and the telecentric light source 11 in the vertical direction. The coaxial light source 12 illuminates the platform 15 from top to bottom, the telecentric light source 11 illuminates the platform 15 from bottom to top, and the horizontal light source 13 illuminates the platform 15 from the side at an angle. The platform 15 is used to place the flange. The coaxial light source 12, the telecentric light source 11, and the horizontal light source 13 provide front, back, and side illumination to the flange, respectively.
[0044] Furthermore, the stage 15 should be made of a light-transmitting material or be made transparent so that at least the light from the telecentric light source 11 can illuminate the camera 14.
[0045] The horizontal light source 13 is composed of four strip light sources forming a square shape. When the flange is placed on the platform 15, the flange should be located inside the square shape, so that the horizontal light source 13 can provide lateral tilted illumination to the flange.
[0046] In the entire detection system of this embodiment, the camera 14, the telecentric light source 11, the coaxial light source 12, and the horizontal light source 13 are all communicatively connected to the analysis and processing unit and controlled by the analysis and processing unit. To ensure the clarity of the workpiece image under various light sources, the telecentric light source 11, the coaxial light source 12, and the horizontal light source 13 are selectively activated, as follows:
[0047] When the telecentric light source 11 is turned on (first illumination case), the camera 14 captures an image (projected image) of the workpiece under the illumination of the telecentric light source 11 above the workpiece. In the projected image, only the flange area is black and the other areas are white, thus clearly highlighting the edge of the flange.
[0048] When the coaxial light source 12 is turned on (second illumination situation), the camera 14 captures an image of the upper surface of the flange from above the coaxial light source 12. That is, the image captured by the camera 14 after the vertical light generated by the coaxial light source 12 above the workpiece hits the upper surface of the flange (first surface image) can highlight defects such as pits, missing material, vibration, and uneven surfaces.
[0049] When the horizontal light source 13 is turned on (third illumination case), the camera 14 captures another image of the upper surface of the flange from above the horizontal light source 13. That is, the image that the camera 14 can capture after the side light generated by the horizontal light source 13 located on the side of the workpiece is obliquely hit on the upper surface of the flange (second surface image) can highlight defects such as scratches.
[0050] Among these three types of images that can be acquired, defect detection of the flange can be achieved. The analysis and processing unit in the detection device 1 performs detection and analysis based on the images acquired by the camera 14. The detection specifically includes through hole detection, front and back side detection, size measurement, pit detection, material shortage detection, vibrating knife detection, yin and yang side detection, scratch detection, etc.
[0051] The flange described in this embodiment is specifically a flange used for fastening oil caps. It is manufactured through processes such as blank sintering, pressing, and turning. During the processing, the following situations may occur: pits or material shortages during blank production; scratches on the surface caused by the transfer of processes; uneven surfaces due to insufficient machining allowance after rework of unqualified machined surfaces; tool damage causing tool vibration during processing; and dimensional deviations during processing. Therefore, it is necessary to distinguish between qualified and unqualified products through the aforementioned defect detection.
[0052] In addition, the flanges in this embodiment have a front and a back due to their manufacturing process, so they need to be distinguished; and the flanges also include two types: through-hole flanges and non-through-hole flanges. That is, through-hole flanges have a smooth inner wall circular hole, and non-through-hole flanges have a circular hole with features such as threads or flanges on the inner wall (that is, the size of the circular hole includes the inner circle and the outer circle), so they also need to be distinguished.
[0053] The distinction between through holes and non-through holes is achieved by performing a template matching process in the projected image under the first irradiation condition, and then determining whether the flange is a through hole flange or a non-through hole flange based on the matched template; furthermore, after template matching of the flange, the analysis and processing unit will generate a classification signal based on the flange type, so as to control the gantry robot 2 to sort and count them after the subsequent detection process.
[0054] A defect detection method using the aforementioned defect detection system includes the following steps:
[0055] S1. Turn on the telecentric light source 11, and the camera 14 acquires the projected image of the workpiece. Based on the projected image, perform a template matching process to determine whether the workpiece is a through hole or a non-through hole.
[0056] S2. Turn on the coaxial light source 12 and the camera 14 acquires the first surface image of the workpiece. Perform grayscale value statistical analysis based on the first surface image to determine whether the workpiece is the front or back.
[0057] S3. Turn on the coaxial light source 12 and the camera 14 to acquire the first surface image of the workpiece. Perform a defect detection process based on the first surface image to determine whether the workpiece has four types of defects: pits, missing material, vibration, and uneven surfaces. Turn on the horizontal light source 13 and the camera 14 to acquire the second surface image of the workpiece. Perform a defect detection process based on the second surface image to determine whether the workpiece has scratches.
[0058] S4. Turn the workpiece over;
[0059] S5. Turn on the coaxial light source 12 and the camera 14 to acquire the first surface image of the workpiece. Perform a defect detection process based on the first surface image to determine whether the workpiece has four types of defects: pits, missing material, vibration, and uneven surfaces. Turn on the horizontal light source 13 and the camera 14 to acquire the second surface image of the workpiece. Perform a defect detection process based on the second surface image to determine whether the workpiece has scratches.
[0060] S6. Turn on the telecentric light source 11, and the camera 14 acquires the projected image of the workpiece. Based on the projected image, perform the size inspection process to determine whether the size of the workpiece is compliant.
[0061] S7. Turn on the coaxial light source 12, and the camera 14 acquires the first surface image of the workpiece. Measure the outer diameter of the non-through hole based on the first surface image.
[0062] Step S6 can be performed before or after any of steps S2, S3, S4, and S5.
[0063] If, after the workpiece has been processed through steps S1 and S2, it is determined to be a non-through-hole workpiece and the current face is the front, then step S7 is performed after step S4; if the workpiece is determined to be a non-through-hole workpiece and the current face is the back, then step S7 is performed between steps S2 and S4.
[0064] The template matching process in step S1 includes the following steps:
[0065] S1.1 Perform grayscale binarization on each pixel in the grayscale image to be inspected, that is, reduce the grayscale value of pixels with a grayscale value greater than 100 to 1, and vice versa;
[0066] S1.2. The Sobe edge detection algorithm is used to obtain the grayscale gradient image;
[0067] S1.3 Perform contour finding processing on the grayscale gradient image to obtain the outer contour point set and inner contour point set information of the workpiece;
[0068] S1.4 Find the minimum bounding rectangle of the workpiece's outer contour, including the center point, rotation angle, length, and width of the minimum bounding rectangle, and find the area of the minimum bounding circle of the maximum inner contour.
[0069] S1.5. Traverse each of the created template models and compare the area of the minimum bounding rectangle of the template with the aspect ratio of the workpiece. If either the area ratio or the aspect ratio is not within the range of 98% to 102%, the matching is deemed to have failed, and the process continues to traverse the next template. If both of their ratios are within the range of 98% to 102%, the process further compares the area of the minimum bounding circle of the maximum inner contour of this template with the workpiece. If the ratio is within the range of 98% to 102%, the matching is deemed to have succeeded; otherwise, the matching is deemed to have failed, and the process continues to traverse the next template.
[0070] S1.6 If a template is successfully matched during iteration, the iteration ends and the template matching information is output; if no template is successfully matched during iteration, the interface will display a template matching failure message.
[0071] Firstly, the contour finding algorithm is implemented by calling the contour finding function in the open-source algorithm library OpenCV. The principle of contour finding is as follows: for a binary image with a black background and a white target, if a white point is found in the image and its 8-neighborhood (or 4-neighborhood) is also white, it means that the point is an internal point of the target, and it is set to black, which visually makes it look like the inside is hollowed out; otherwise, it is kept white, and the point is the boundary point (or contour point) of the target. By traversing the entire image in the above way, each contour (or contour point set) will be obtained and stored as a point vector. In addition, the topological information of the image is also obtained, that is, the index number of the next contour, the previous contour, the parent contour, and the embedded contour of a contour.
[0072] Secondly, step S1.1 specifically refers to converting the grayscale binarized detection area image into a black and white image, where a grayscale value of 0 represents black and a grayscale value of 255 represents white; and then performing Sober edge detection processing on the binarized detection area image.
[0073] The Sober edge detection process is as follows:
[0074] S1.2.1 Assume that matrix A represents the pixel value matrix of the detection region image;
[0075] S1.2.2 Find the derivatives in the horizontal direction (x) and the vertical direction (y) respectively;
[0076] Horizontal direction: Convolve A with a kernel of size 3, as shown in equation (1):
[0077]
[0078] In equation (1), G x This represents the grayscale gradient value in the horizontal direction.
[0079] Vertical direction: Convolve A with a kernel of size 3, as shown in equation (2):
[0080]
[0081] In equation (2), G y This represents the grayscale gradient value in the vertical direction.
[0082] The gray-level gradient values of each pixel in the image in the horizontal and vertical directions are combined using the following formula (3) to calculate the gray-level gradient value of that point.
[0083]
[0084] In equation (3), G represents the grayscale gradient value of the current pixel.
[0085] In step S2, the front and back detection is necessary because, in the case of a non-through hole workpiece, the measurement of the outer diameter of the non-through hole needs to be performed from the back side. Therefore, it is necessary to distinguish the front and back of the flange. Specifically, under the second irradiation, the grayscale value of the flange surface is statistically analyzed in the first surface image, and the average grayscale value is compared to determine whether the current surface is the front or the back.
[0086] In step S6, refer to Figure 5 and Figure 6 The size detection process includes the following steps:
[0087] S6.1 Obtain the ROI region information of the workpiece;
[0088] S6.1.1 The workpiece RO I region information is the minimum bounding rectangle information of the workpiece's outer contour point set;
[0089] S6.2. Correct the position of the current workpiece image based on the position information of the template;
[0090] S6.2.1 Position correction is a tool for assisting in positioning, correcting target motion offset, and assisting in precise positioning. It can establish a reference for position offset based on the center point and angle of the matching template in the template matching result, and then realize the coordinate rotation offset of the ROI region, that is, to enable the ROI region to keep up with the changes in image angle and pixels.
[0091] S6.3 After the position is corrected, the detection frame areas of the left, middle and right circles are also corrected accordingly. Based on the position corrected detection frame areas, the edge contour point sets of the left, middle and right circles are selected from all the inner contour points of the workpiece.
[0092] S6.4 Using the obtained left circle contour point set, perform circle fitting on the left circle to obtain circle 1; using the obtained middle circle contour point set, perform circle fitting on the middle circle to obtain circle 2; using the obtained right circle contour point set, perform circle fitting on the right circle to obtain circle 3.
[0093] S6.5. Obtain the center distance from circle 1 to circle 2 based on the center information; obtain the center distance from circle 2 to circle 3 based on the center information;
[0094] S6.6 After the position is corrected, the detection frame areas of the four long sides of the workpiece are also corrected accordingly. Based on the position corrected detection frame areas, the contour point sets of the four long sides of the workpiece are extracted from the outer contour point set of the workpiece.
[0095] S6.7 Using the obtained contour point sets of the four long sides of the workpiece, fit the four long sides of the workpiece to obtain straight lines 1, 2, 3, 4.
[0096] S6.8 Fit a quadrilateral using lines 1, 2, 3, and 4;
[0097] S6.9 Obtain the long diagonal 1 and the short diagonal 2 of the quadrilateral;
[0098] S6.10. Perform edge search on the workpiece based on the angle and position information of diagonal 1;
[0099] S6.10.1 Edge finding is to find the points that intersect with the set of points on the outer contour of the workpiece based on the equation of the straight line of diagonal 1. The intersection point on the left is the left edge, and the intersection point on the right is the right edge.
[0100] S6.11. Obtain the workpiece length based on the distance between the left edge point and the right edge point;
[0101] S6.12. Perform edge search on the workpiece based on the angle and position information of diagonal 2;
[0102] S6.12.1 Edge finding is to find the points that intersect with the workpiece edge point set based on the equation of the straight line of diagonal 2. The intersection point above is the upper edge, and the intersection point below is the lower edge.
[0103] S6.13. Obtain the workpiece width based on the distance between the upper and lower edges;
[0104] S6.14 Output all measured dimensional information.
[0105] The circle fitting method used in step S6.4 and the line fitting method used in step S6.7 are implemented by combining the principles of the Ransac algorithm with the least squares method.
[0106] Specifically, in step S6.4, the circle fitting method is as follows:
[0107] S6.4.1, Let the set of contour points extracted from the corresponding detection region be... There are n pixels, where point (x) j ,y j Let (x) represent the j-th pixel in the contour point set. Assume the equation of the circle to be found is: (xA) 2 +(yB) 2 =R 2 Where A represents the x-coordinate of the center of the circle, B represents the y-coordinate of the center of the circle, and R represents the radius of the circle;
[0108] S6.4.2. Randomly select three points from n pixels and substitute them into the circle equation (xA). 2 +(yB) 2 =R 2 Find A, B, and R;
[0109] S6.4.3 Calculate the distance from other points to the circle. If the distance is less than a certain threshold (the threshold is set to 2 pixels in this embodiment), treat it as an inner point and count the number of inner points.
[0110] S6.4.4 Repeat steps S6.4.2 to S6.4.3 M times to obtain the set of interior points with the most points;
[0111] S6.4.5, Set the set of interior points with the most points. By running the least squares method, we can obtain
[0112]
[0113]
[0114]
[0115]
[0116]
[0117]
[0118]
[0119]
[0120]
[0121]
[0122] Among them, C, D, E, G, H, a, b, and c are all intermediate calculation parameters in the derivation process of A, B, and R. That is, the calculation formulas of A, B, and R are reasonably decomposed and used to refer to the parameters of each decomposed formula.
[0123] The equation of the desired circle (xA) is thus obtained. 2 +(yB) 2 =R 2 ,
[0124] Among them, point (x) i ,y i ) represents the i-th pixel in the interior point set, and N represents the number of pixels in the interior point set;
[0125] The value of M can be estimated by the following formula. Where p represents the probability of an interior point, p 2 1-p represents the probability that all three points are interior points. 3 Let z represent the probability that at least one of the three points is an outlier (sampling failure), and z = 1 - (1 - p) 3 ) M This represents the probability that at least one of the M sampling attempts will be successful.
[0126] In this embodiment, it is assumed that p = 0.8 and z = 0.99, then M can be 7.
[0127] Specifically, in step S6.7, the straight line fitting method is as follows:
[0128] S6.7.1, Let the set of contour points extracted from the corresponding detection region be... There are n pixels, where point (x) j ,y j ) represents the j-th pixel in the contour point set. Assume the equation of the line to be found is: y = a*x + b, where a represents the slope of the line to be found and b represents a constant.
[0129] S6.7.2. Randomly select two points from n pixels, substitute them into the equation of the line y=a*x+b, and find a and b;
[0130] S6.7.3 Calculate the distance from other points to the line. If the distance is less than a certain threshold (the threshold is set to 2 pixels in this embodiment), treat it as an interior point and count the number of interior points.
[0131] S6.7.4 Repeat steps S6.7.2 to S6.7.3M times to obtain the set of interior points with the most points;
[0132] S6.7.5, Set the set of interior points with the most points. By running the least squares method, we can obtain
[0133] The equation of the desired line is then obtained as y = ax + b;
[0134] Among them, point (x) i ,y i ) represents the i-th pixel in the interior point set, and N represents the number of pixels in the interior point set;
[0135] The value of M can be estimated by the following formula. Where p represents the probability of an interior point, p 2 1-p represents the probability that both points are interior points. 2 This represents the probability that at least one of the two points is an outlier (sampling failure).
[0136] z = 1 - (1 - p) 2 ) M This represents the probability that at least one of the M sampling attempts will be successful.
[0137] In this embodiment, we assume p = 0.8 and z = 0.99, then M can be 5.
[0138] In summary, for the above-mentioned circle-to-line fitting process, if only the least squares method is used to fit the circle or line, when there are small burrs, small protrusions, or small concave points on the edge of the workpiece, the extracted contour will have outliers when used for fitting, which will lead to inaccurate fitting. The method in this paper first uses the idea of the Ransac algorithm, based on the probability p that a contour point randomly extracted from the detection object (contour point set) is an interior point (non-outlier point) and the probability z that at least one of the M samplings is successful, to obtain the number of samplings M, and then counts the interior point set with the largest number of points, and then performs least squares fitting. This can effectively remove outliers, improve fitting accuracy, and thus improve measurement accuracy.
[0139] In steps S3 / S5, for pit detection and material shortage detection, under the second illumination condition, less light is reflected back to the photosensitive surface of the camera 14 from the pits and material shortage areas. Therefore, the areas they occupy are much darker than other normal areas, meaning that the grayscale values of the pixels they contain are significantly smaller than those of other normal areas. Therefore, grayscale values are calculated according to a set value (preferably 80 in this embodiment). Figure 2 Value-based grading involves setting the grayscale value of pixels with a value greater than a set value to 1, and the grayscale value of pixels with a value less than or equal to the set value to 0. Then, connected components with a grayscale value of 0 are extracted. If the area of the extracted connected component is greater than a set value (preferably 1.5 mm in this embodiment), then the value is considered positively evaluated. 2 This indicates a dent or missing material.
[0140] In steps S3 / S5, for the vibration detection and the detection of the shaded and uneven surfaces, under the second irradiation condition, the vibration and shaded / uneven surfaces, due to over-processing, lose their inherent halo-like shallow textures, making them relatively brighter than other normal areas. That is, the grayscale values of the pixels they contain are larger than those of other normal areas. Therefore, the grayscale image is first subjected to mean filtering, and then the optimal threshold k for grayscale thresholding is obtained by using the maximum inter-class variance method. * Next, determine k. * Whether it is within the set range (preferably 100 to 180 in this embodiment), if not, it is determined that there is no vibrating blade or yin-yang surface area; if so, the aforementioned defect exists. The obtained k is then used to determine the defect. * The size of the area occupied by the vibrating blade and the yin-yang side is statistically analyzed. If it is larger than the set value (preferably 4mm in this embodiment), then... 2 If the area occupied is too small, it is determined to be a defective area of the vibrating knife or the yin-yang side; otherwise, it is determined that the defect does not exist.
[0141] The mean filtering process involves iterating through each pixel in the grayscale image and performing the following steps on each pixel: the pixel is referred to as the target pixel, and a filtering template is formed by combining the target pixel with the eight pixels surrounding it. The grayscale value of the target pixel is then replaced by the average grayscale value of all pixels in the template.
[0142] The maximum inter-class variance method is used to determine the optimal threshold k for grayscale thresholding. * The implementation idea is as follows:
[0143] The grayscale image has 256 gray levels [1, 2, ..., 256]. The number of pixels with gray level i is n. i Therefore, the total number of pixels is...
[0144] Use a normalized grayscale histogram and consider it as the probability distribution of this image:
[0145]
[0146] In equation (4), p i This represents the probability of gray level i in this image.
[0147] Now, suppose these pixels are divided into two classes, C0 and C1, using a grayscale threshold of k; C0 represents pixels with grayscale levels [1, 2, ..., k], and C1 represents pixels with grayscale levels [k+1, ..., 256]. The probability of each class and the average grayscale level of each class are given by the following formulas:
[0148]
[0149] In equation (5), ω0 represents the probability of C0 appearing, and ω(k) represents the cumulative probability of gray levels from 1 to k.
[0150]
[0151] In equation (6), ω1 represents the probability of C1 occurring.
[0152]
[0153] In equation (7), μ0 represents the average gray level of C0, and μ(k) represents the average gray level from 1 to k.
[0154]
[0155] In equation (8), μ1 represents the average gray level of C1, μ T This represents the average gray level of the entire image.
[0156]
[0157]
[0158] These represent the cumulative occurrence probability of gray levels from 1 to k and the average gray level (first-order cumulative moment), respectively.
[0159]
[0160] It is the average gray level of the entire image.
[0161] For any chosen k, we have:
[0162] ω0μ0+ω1μ1=μ T , ω0+ω1=1. (12)
[0163] The following equation (13) is used as the measurement standard for evaluating the "goodness" (separability) of selecting k as the threshold.
[0164]
[0165] in, Represents the variance between classes. Represents the total variance of gray levels:
[0166]
[0167] According to equation (12), we can conclude that:
[0168]
[0169] These two formulas represent the inter-class variance and the total variance of the gray levels, respectively.
[0170] Using the following formula, different k values are selected sequentially for searching, and the optimal threshold k is found according to equations (9) and (10). * To maximize η, or equivalently to maximize η, is to maximize η. Reach the maximum.
[0171]
[0172]
[0173] Furthermore, the optimal threshold k * that is
[0174]
[0175] Vibration knife and yin-yang surface defects will occur during workpiece processing. Since the front side of the workpiece is the processing surface, in this embodiment, vibration knife and yin-yang surface defect detection is only performed on the front side of the workpiece. Furthermore, in the defect detection process, pit and missing material defects are detected first. After workpieces with pits and missing material are removed, vibration knife and yin-yang surface defect detection is performed to ensure the accuracy of vibration knife and yin-yang surface defect detection.
[0176] In steps S3 / S5, for scratch detection, under the third illumination condition, more light is reflected back to the photosensitive surface of camera 14 at the scratch location, while less light is reflected back to the photosensitive surface of camera 14 from other normal areas. However, considering that scratches of different shapes and depths may exist simultaneously, their distinction from normal areas is not significant. Therefore, a deep learning method is used for detection. In the process of annotating the defect targets in the grayscale image, morphological closing operations are first performed on the grayscale image so that some discontinuous scratches can be connected to present a complete image. After the model is trained, when performing detection, morphological closing operations are also performed on the grayscale image to be detected before calling the model for detection. Specifically, based on the size of the trained model (e.g., the model size is a matrix of 5 pixels multiplied by 5 pixels), the grayscale image after morphological closing operations is traversed. If the confidence of a certain area in the grayscale image with the model reaches 90%, it is determined to be a scratch; otherwise, it is not.
[0177] The training process for the aforementioned deep learning model includes the following steps:
[0178] S3 / 5.1 acquired a large number of scratch sample images;
[0179] S3 / 5.2 Mark the areas where scratches are located in all sample images;
[0180] The data and images labeled S3 / 5.3 are input into the backbone network;
[0181] S3 / 5.4 normalizes and scales the sample images in the training set to integer multiples of 32 in the network;
[0182] S3 / 5.5 sets the width and height of the initial candidate boxes in the boundary regression module;
[0183] Iterative training of the prediction model begins in S3 / 5.6;
[0184] After training is completed, S3 / 5.7 generates and exports the prediction model;
[0185] S3 / 5.8 uses a predictive model to infer from the actual detected images;
[0186] S3 / 5.9 Determine whether the detection accuracy exceeds 95%;
[0187] S3 / 5.10 If the accuracy is below 95%, proceed to step S3 / 5.11; if it is above 95%, proceed to step S3 / 5.14.
[0188] S3 / 5.11 requires re-marking of missed scratches;
[0189] S3 / 5.12 Normal areas are misidentified as scratches; removal markings are included.
[0190] S3 / 5.13 The re-annotated image is then moved to step S3 / 5.3;
[0191] S3 / 5.14 training completed.
[0192] In addition, in the detection device 1 of this embodiment, the three light sources and camera 14 are placed inside the housing 16 to obtain a good illumination effect and avoid interference from external ambient light, so as to avoid affecting the accuracy of detection. However, after the housing 16 is set, the movement of the gantry robot 2 to move the flange onto the platform 15 inside the housing 16 is somewhat limited due to the flexibility of the gantry robot 2. Therefore, this embodiment also includes a telescopic mechanism, which is installed on the platform 15 and communicates with the analysis and processing unit to drive the platform 15 to extend out of the housing 16, so as to facilitate the gantry robot arm to move and flip the flange onto the platform 15. In this embodiment, the telescopic mechanism can preferably be an electric linear slide rail.
[0193] It should be added that, in order for the camera 14 to obtain better image information, the shooting end of the camera 14 is also equipped with a telecentric lens 17. When the workpiece is placed on the stage 15, due to the influence of machine precision and other factors, its placement position cannot achieve a uniform coaxial effect with the shooting direction of the camera 14, that is, it is placed crookedly. In this case, it will have a certain impact on the various detection results mentioned above, especially in dimensional measurement. When the workpiece is placed crookedly, the side of the workpiece will also be photographed and easily merged into the upper surface area of the workpiece, thus causing dimensional measurement errors. Therefore, in this embodiment, a telecentric lens 17 is installed on the shooting end of the camera 14. By utilizing the high resolution, ultra-wide depth of field, ultra-low distortion and unique parallel light design of the telecentric lens 17, the impact of the workpiece being placed crookedly on the image acquired by the camera 14 is reduced.
[0194] Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort should fall within the scope of protection of the present invention.
Claims
1. A flange defect detection system, characterized by, Includes a detection device and an analysis and processing unit, wherein, The detection device includes a stage, a telecentric light source, a horizontal light source, a coaxial light source, and a camera. The stage is used to load workpieces, including workpieces with through holes and workpieces without through holes. When the telecentric light source is turned on, the camera obtains a projected image of the workpiece. When the coaxial light source is turned on, the camera obtains a first surface image of the workpiece. When the horizontal light source is turned on, the camera obtains a second surface image of the workpiece. The coaxial light source and the telecentric light source are located above and below the stage, respectively, and both illuminate the stage to provide vertical illumination to the workpiece; the horizontal light source is located above the stage and below the coaxial light source, and includes four strip light sources arranged in a U-shape to provide oblique side illumination to the workpiece; the camera is located above the coaxial light source and shoots downwards. The analysis and processing unit is used to detect whether the workpiece is a through-hole workpiece or a non-through-hole workpiece based on the projected image, to detect the front or back of the workpiece and a first type of defect based on the first surface image, and to detect a second type of defect of the workpiece based on the second surface image.
2. The flange defect detection system of claim 1, wherein It also includes a vibrating screen, a conveyor belt, a photoelectric sensor, and a gantry robot. The vibrating screen is located at one side of the conveyor belt, and the detection device is located at the other side of the conveyor belt. The conveyor belt travels from the vibrating screen to the detection device. The photoelectric sensor is located on the conveyor belt and is communicatively connected to the conveyor belt and the gantry robot. The gantry robot is located at the other side of the conveyor belt.
3. A flange defect detection system according to claim 2, wherein, The detection device further includes a housing, in which the camera, the coaxial light source, the horizontal light source, the stage, and the telecentric light source are arranged from top to bottom; the housing has an opening and also includes a telescopic mechanism for driving the stage through the opening and extending out of the housing, the stage being connected to the telescopic end of the telescopic mechanism.
4. A method for detecting defects of a flange, applied to the flange defect detection system according to any one of claims 1 to 3, characterized by, Includes the following steps: S1. The telecentric light source is used to illuminate the back of the workpiece from below the stage, and the camera is used to acquire the projected image of the workpiece from above the stage. The analysis and processing unit calls the corresponding template to match the workpiece, and determines whether the workpiece is a through-hole workpiece or a non-through-hole workpiece based on the matched template. S2. The coaxial light source is used to illuminate the top surface of the workpiece above the stage, and the camera is used to acquire a grayscale image of the workpiece above the coaxial light source. The analysis and processing unit determines whether the current surface is the front or the back. S3. The coaxial light source or the horizontal light source is used to illuminate the top surface of the workpiece above the stage. The camera is used above the coaxial light source to acquire surface images of the front and back of the workpiece. The analysis and processing unit performs defect detection on the surface images of the front and back respectively. S3.1 When the workpiece is a through-hole workpiece, perform defect detection procedures on the front and back of the workpiece respectively; S3.2 When the workpiece is a non-through hole workpiece, the defect detection process shall be carried out on the front and back of the workpiece respectively. During the detection process, when the front side of the workpiece is the back side of the workpiece, the outer diameter of the non-through hole of the workpiece shall be measured. S4. The telecentric light source is used to illuminate the back of the workpiece from below the stage, and the camera is used to acquire a projected image of the workpiece from above the stage. The analysis and processing unit performs a size measurement process based on the projected image.
5. The method of claim 4, wherein the step of detecting the defect of the flange is characterized by, In step S3, the surface image includes a first surface image and a second surface image. The acquisition of the first surface image includes using a camera above the coaxial light source to capture the image when the workpiece is vertically illuminated by a coaxial light source. The acquisition of the second surface image includes using a camera above the workpiece when the side of the workpiece is obliquely illuminated by a horizontal light source. The first surface image is used for detecting defects such as pits, missing material, vibration, and uneven surfaces. The second surface image is used for detecting scratch defects.
6. The method of detecting defects in a flange according to claim 5, wherein Defects such as dents and missing materials are determined by extracting the area of connected regions with a grayscale value of 0 after binarizing the grayscale image; defects such as vibrating blades and uneven surfaces are determined by calculating the optimal threshold after mean filtering the surface image and comparing it with a set value. Scratch defects are determined using deep learning methods.
7. The method of claim 5, wherein the step of detecting the defect of the flange is characterized by, In step S3.2, the outer diameter of the non-through hole of the workpiece is measured based on the first surface image.
Citation Information
Patent Citations
Flange appearance quality detection system
CN110687120A
Cylindrical battery shell size detection method and device applying visual device
CN115655107A