Precise positioning method and device for components of circuit board and defect detection method

By threshold segmentation and image processing of circuit board CAD diagrams and real images, precise positioning of components is achieved, time-consuming and labor-intensive selection and positioning of manual frames is solved, and work efficiency is improved.

CN120431032APending Publication Date: 2025-08-05TRULY OPTO ELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510482901.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-17
Publication Date
2025-08-05

AI Technical Summary

Technical Problem

In the prior art, manually selecting and positioning components on PCB boards is time-consuming and labor-intensive, and the work efficiency is low.

Method used

By using the threshold segmentation algorithm to segment the circuit board CAD diagram and the real image, calculate the center coordinates and the connecting line segment angle of the component to achieve accurate positioning of the component, and use the grayscale diagram of the area of interest to translate, rotate and scale, so that the components and the real image are one by one.

Benefits of technology

It realizes precise positioning of components, improves the degree of automation, and solves the inefficiency problem of manual frame selection and positioning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120431032A_ABST
    Figure CN120431032A_ABST
Patent Text Reader

Abstract

The invention discloses an accurate positioning method and device for components of a circuit board and a defect detection method. The positioning method comprises the following steps: calculating and acquiring a first circle center coordinate and a second circle center coordinate of any two circular regions on a first region-of-interest grey-scale map, a first length of a first connecting line segment of the two circular regions, and a first angle of the first connecting line segment relative to the horizontal transverse direction; calculating and obtaining a third circle center coordinate and a fourth circle center coordinate corresponding to two circular areas on the gray-scale map of the second region of interest, a second length of a second connecting line segment of the two circular areas, and a second angle of the second connecting line segment relative to the horizontal transverse direction; and translating, rotating and zooming the first region-of-interest grey-scale map to enable the first region-of-interest grey-scale map to be in one-to-one correspondence with the components of the circuit board physical image. Precise positioning of components is achieved, and the automation degree and the working efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of circuit board defect detection, and in particular to a method and device for accurately positioning components of a circuit board, and a defect detection method. Background Art

[0002] When inspecting defects in various precision components on FPCs and PCBs, relatively high-definition resolution images are required because the components are precise and dense. Inspection equipment requires manual pre-selection of the position information of each component on the circuit board and then an algorithm is used to detect and determine whether the component is defective. This is very time-consuming, occupies a lot of manpower, and reduces work efficiency. Summary of the Invention

[0003] In existing defect detection technology, components on PCB boards are manually selected and positioned, which is time-consuming, labor-intensive, and inefficient.

[0004] In response to the above problems, a method, device and defect detection method for accurately positioning components of a circuit board are proposed. By using a threshold segmentation algorithm to segment the circuit board CAD drawing and the actual image of the circuit board, a first region of interest grayscale image and a second region of interest grayscale image are obtained. Based on the second region of interest grayscale image, the first region of interest grayscale image is translated, converted and scaled to make its components correspond one-to-one with the components on the actual image of the circuit board. In this way, the center coordinates of each component area and the component distance between component areas can be obtained, thereby achieving precise positioning of components, improving the degree of automation, and solving the problem of manual frame selection and positioning of components on the PCB board in the existing defect detection technology, which is time-consuming, labor-intensive and inefficient.

[0005] In a first aspect, a method for accurately positioning components on a circuit board comprises: Step 100: Obtain a CAD drawing of a circuit board, process the CAD drawing of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a first region of interest, and calculate and obtain the first and second center coordinates of any two circular areas on the grayscale image of the first region of interest, a first length of a first connecting line segment of the two circular areas, and a first angle of the first connecting line segment relative to the horizontal. Step 200: Acquire a physical image of a circuit board, process the physical image of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a second region of interest, and calculate and obtain third and fourth center coordinates of two circular areas corresponding to the grayscale image of the second region of interest, a second length of a second connecting line segment of the two circular areas, and a second angle of the second connecting line segment relative to the horizontal. Step 300: Based on the third circle center coordinates and the second connecting line segment, the grayscale image of the first region of interest is translated, rotated, and scaled to make the grayscale image of the first region of interest correspond one-to-one with the components of the physical image of the circuit board, and obtain a scale image of the region of interest. The center coordinates of each component area and the component distance between the component areas are obtained based on the scale image of the region of interest.

[0006] In conjunction with the method for accurately positioning components on a circuit board according to the first aspect of the present invention, in a first possible implementation, step 100 includes: Step 110: Using a threshold segmentation algorithm, segment the region with high brightness grayscale value of the circuit board CAD image to obtain the grayscale image of the first region of interest; Step 120: Filter out two circular areas from the first region of interest grayscale image, calculate the coordinates of the two circular areas, and obtain the first circle center coordinates and the second circle center coordinates.

[0007] In conjunction with the first possible implementation of the first aspect of the present invention, in a second possible implementation, step 100 further includes: Step 130: Connect the first circle center coordinates and the second circle center coordinates to obtain the first connecting line segment; Step 140: Calculate the length of the first connecting line segment in pixels to obtain the first length; Step 150: Calculate the angle of the first connecting line segment relative to the horizontal to obtain the first angle.

[0008] In conjunction with the method for accurately positioning components on a circuit board according to the first aspect of the present invention, in a third possible implementation, step 200 includes: Step 210: Using a threshold segmentation algorithm, segment the region with high brightness grayscale value on the physical image of the circuit board to obtain a grayscale image of the second region of interest; Step 220: Filter out two corresponding circular areas from the second region of interest grayscale image, calculate the coordinates of the two circular areas, and obtain the third circle center coordinates and the fourth circle center coordinates.

[0009] In combination with the third possible implementation manner of the first aspect of the present invention, in a fourth possible implementation manner, step 200 further includes: Step 230: Connect the third circle center coordinate and the fourth circle center coordinate to obtain the second connecting line segment; Step 240: Calculate the length of the second connecting line segment in pixels to obtain the second length; Step 250: Calculate the angle of the second connecting line segment relative to the horizontal to obtain the second angle.

[0010] In conjunction with the method for accurately positioning components on a circuit board according to the first aspect of the present invention, in a fifth possible implementation, step 300 includes: Step 310: Calculate the vertical coordinate deviation and horizontal coordinate deviation between the first circle center coordinate and the third circle center coordinate based on the third circle center coordinate. Step 320: translating the first circle center coordinates according to the ordinate deviation and the abscissa deviation so that the first circle center coordinates coincide with the third circle center coordinates, thereby obtaining a translated grayscale image of interest.

[0011] In combination with the fifth possible implementation manner of the first aspect of the present invention, in a sixth possible implementation manner, step 300 further includes: Step 330: Calculate and obtain an angular deviation between the first connecting line segment and the second connecting line segment; Step 340: According to the angle deviation, the translated grayscale image of interest is rotated with the third circle center coordinate as the rotation center, so that the first connecting line segment and the second connecting line segment are located at the same level, thereby obtaining a rotated grayscale image of interest.

[0012] In combination with the sixth possible implementation manner of the first aspect of the present invention, in a seventh possible implementation manner, step 300 further includes: Step 350: Calculate and obtain the scaling ratio between the circuit board CAD drawing and the physical image of the circuit board; Step 360: scaling the rotated grayscale image of interest based on the scaling ratio and taking the third circle center coordinate as the scaling endpoint, so that the first grayscale image of the region of interest corresponds one-to-one with the components of the physical image of the circuit board, and obtaining the scale image of the region of interest.

[0013] In a second aspect, a device for accurately positioning components on a circuit board is provided, which adopts the method for accurately positioning components on a circuit board described in the first aspect, comprising: a first image processing module, configured to obtain a CAD drawing of a circuit board, process the CAD drawing of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a first region of interest, and calculate and obtain first and second center coordinates of any two circular areas on the grayscale image of the first region of interest, a first length of a first connecting line segment of the two circular areas, and a first angle of the first connecting line segment relative to a horizontal direction; a second image processing module, configured to acquire a physical image of a circuit board, process the physical image of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a second region of interest, and calculate and obtain third and fourth center coordinates of two circular areas corresponding to the grayscale image of the second region of interest, a second length of a second connecting line segment of the two circular areas, and a second angle of the second connecting line segment relative to the horizontal; A positioning module is used to translate, rotate, and scale the first region of interest grayscale image based on the third circle center coordinates and the second connecting line segment, so that the first region of interest grayscale image corresponds one-to-one with the components of the physical image of the circuit board, obtain a region of interest scale image, and obtain the center coordinates of each component area and the distance between component areas based on the region of interest scale image.

[0014] In a third aspect, a method for detecting component defects of a circuit board includes: Step 400: Use the circuit board component precise positioning method described in the first aspect to obtain the center coordinates of each component area and the component distances between component areas; Step 500: Move the defect detection platform according to the center coordinates of each component area and the component distance between the component areas, so that each component to be inspected is moved to the camera center of the defect detection platform for defect inspection.

[0015] The present invention provides a method, device, and defect detection method for accurately positioning components of a circuit board. By using a threshold segmentation algorithm to segment a circuit board CAD drawing and a physical image of the circuit board, a first region of interest grayscale image and a second region of interest grayscale image are obtained. The first region of interest grayscale image is translated, converted, and scaled based on the second region of interest grayscale image, so that its components correspond one-to-one with the components on the physical image of the circuit board. This allows the center coordinates of each component area and the component distances between component areas to be obtained, thereby achieving accurate positioning of components and improving the degree of automation. This solves the problem in existing defect detection technology of manually framing and positioning components on the PCB board, which is time-consuming, labor-intensive, and inefficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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 creative work.

[0017] Figure 1This is a flow chart of a specific embodiment of a method for accurately positioning components on a circuit board in the present application; Figure 2 yes Figure 1 A flowchart of a specific embodiment of step 100; Figure 3 yes Figure 2 A flow chart of a specific embodiment after step 120; Figure 4 yes Figure 1 A flowchart of a specific embodiment of step 200; Figure 5 yes Figure 2 A flow chart of a specific embodiment after step 220; Figure 6 yes Figure 1 A flowchart of a specific embodiment of step 300; Figure 7 yes Figure 6 A flow chart of a specific embodiment after step 320 in FIG. Figure 8 yes Figure 7 A flowchart of a specific embodiment of step 340 in FIG. Figure 9 This is a screenshot of the CAD drawing of the circuit board in this application; Figure 10 Yes Figure 9 Grayscale image of the circuit board CAD drawing screenshot after threshold segmentation; Figure 11 Yes Figure 10 A grayscale image of a first region of interest obtained by screening the medium grayscale image; Figure 12 is a first schematic diagram of a grayscale image of a first region of interest in this application; Figure 13 is a second schematic diagram of the grayscale image of the first region of interest in this application; Figure 14 This is a photo of the actual circuit board in this application; Figure 15 Yes Figure 14 The physical picture of the circuit board is enhanced to obtain the physical picture of the circuit board; Figure 16 Yes Figure 15 A grayscale image of a second region of interest obtained by performing threshold segmentation on the physical image of the circuit board; Figure 17 It will Figure 11 The grayscale image of the first region of interest in Figure 16 The center coordinate coincidence diagram of the grayscale image of the second region of interest in ; Figure 18 Yes Figure 17 Rotate the grayscale image of the first region of interest in to obtain a rotation coincidence image of the two; Figure 19 Yes Figure 18 Scaling the grayscale image of the first region of interest in the image to obtain a size-coincidence image of the two; Figure 20 is a first schematic diagram of a grayscale image of a second region of interest in this application; Figure 21 is a second schematic diagram of a grayscale image of a second region of interest in this application; Figure 22 The second schematic diagram of the grayscale image of the first region of interest in this application and the second schematic diagram of the grayscale image of the second region of interest are located at the same center. Figure 23 It is a schematic diagram of horizontal overlap of the second schematic diagram of the grayscale image of the first region of interest and the second schematic diagram of the grayscale image of the second region of interest in this application; Figure 24 It is a schematic diagram showing the sizes of the second schematic diagram of the grayscale image of the first region of interest and the second schematic diagram of the grayscale image of the second region of interest in this application being overlapped; Figure 25 This is a schematic diagram of a specific embodiment of a device for accurately positioning components on a circuit board in the present application; Figure 26 This is a flow chart of a specific embodiment of a method for detecting component defects in a circuit board in the present application. DETAILED DESCRIPTION

[0018] The following will clearly and completely describe the technical solutions of the present invention in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, other embodiments obtained by ordinary technicians in this field without creative work are all within the scope of protection of the present invention.

[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one skilled in the art to which this invention pertains. The terms used in this specification of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0020] It should be noted that when an element is referred to as being “fixed on” or “disposed on” another element, it may be directly on the other element or indirectly on the other element. When an element is referred to as being “connected to” another element, it may be directly connected to the other element or indirectly connected to the other element.

[0021] It should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on this application.

[0022] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. Throughout the description of this application, "plurality" means two or more, unless otherwise specifically defined.

[0023] In existing defect detection technology, components on PCB boards are manually selected and positioned, which is time-consuming, labor-intensive, and inefficient.

[0024] In order to solve the above problems, a method and device for accurately positioning components of a circuit board and a defect detection method are proposed.

[0025] First embodiment In the first aspect, a method for accurately positioning components of a circuit board is provided. Figure 1 , Figure 1 This is a flow chart of a specific embodiment of a method for accurately positioning components on a circuit board in this application, including: Step 100: Obtain a CAD drawing of a circuit board, process the CAD drawing of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a first region of interest, calculate and obtain the first center coordinates and second center coordinates of any two circular areas on the grayscale image of the first region of interest, the first length of the first connecting line segment of the two circular areas, and the first angle of the first connecting line segment relative to the horizontal.

[0026] In a preferred embodiment, Figure 2 , Figure 2 yes Figure 1A flowchart of a specific embodiment of step 100 in FIG. 1 is provided; step 100 includes: step 110, using a threshold segmentation algorithm to segment areas with high brightness grayscale values of the circuit board CAD drawing to obtain a grayscale image of a first region of interest; step 120, screening out two circular areas from the grayscale image of the first region of interest, calculating the coordinates of the two circular areas, and obtaining the coordinates of the first center of the circle and the second center of the circle.

[0027] In this embodiment, the CAD design drawing of the circuit board is opened. The CAD design drawing contains the position arrangement information of the components. The design is scaled to any size and the component part to be tested is screenshoted. Figure 9 , Figure 9 This is a screenshot of the CAD drawing of the circuit board in this application. It is a screenshot of the CAD drawing of the component arrangement of the circuit board. The brightest area is the component location, such as Figure 10 , Figure 10 Yes Figure 9 Grayscale image of the circuit board CAD drawing screenshot after threshold segmentation.

[0028] The screenshot Cad_Image is processed by the threshold segmentation algorithm to obtain the grayscale image of the first region of interest, such as Figure 11 and Figure 12 , Figure 11 Yes Figure 10 The grayscale image of the first region of interest is obtained by screening the grayscale image. Figure 12 is a first schematic diagram of a grayscale image of a first region of interest in this application; Figure 12 The dotted area in the circuit board is the area segmented by the algorithm, which segments the area with high brightness grayscale value. threshold(Cad_Image, Cad_ROIRegion,MinGray, MaxGray). The segmented area Cad_ROIRegion corresponds to the distribution area of components and the circle.

[0029] In a preferred embodiment, Figure 3 , Figure 3 yes Figure 2 A flowchart of a specific embodiment after step 120 in FIG. 1 ; step 100 further includes: step 130, connecting the first circle center coordinates and the second circle center coordinates to obtain a first connecting line segment; step 140, calculating the length of the first connecting line segment in pixels to obtain a first length; step 150, calculating the angle of the first connecting line segment relative to the horizontal to obtain a first angle.

[0030] In this embodiment, the shape of the region is filtered to select the two circular regions Cad_CircleRegions with the highest circular similarity, select_shape(Cad_ROIRegion, Cad_CircleRegions,'circularity','and',Min, Max), where the two circular regions are the upper left corner and lower right corner of the circle, respectively, and the circular similarity range is 0.9<Min<Max≤1. The two circular regions (such as Figure 11 The red circle in the figure is the exposed copper area on the circuit board. The position of this area has a high relative positional invariance accuracy relative to the position of the components. The algorithm then calculates the coordinates of the first center of the two circular areas, Cad_C1 (Cad_Row1, Cad_Column1), the coordinates of the second center of the two circular areas, Cad_C2 (Cad_Row2, Cad_Column2), the distance Cad_Distance (unit: number of pixels) between the first line segment Cad_Line_C1C2 connecting points Cad_C1 and Cad_C2, and the first angle Cad_Rad of this line segment relative to the horizontal. Figure 13 , Figure 13 This is a second schematic diagram of the grayscale image of the first region of interest in this application.

[0031] Step 200: Acquire a physical image of the circuit board, process the physical image of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of the second region of interest, and calculate the third and fourth center coordinates of the two circular areas corresponding to the grayscale image of the second region of interest, the second length of the second connecting line segment of the two circular areas, and the second angle of the second connecting line segment relative to the horizontal.

[0032] In a preferred embodiment, Figure 4 , Figure 4 yes Figure 1 A flowchart of a specific embodiment of step 200 in FIG. 2 is provided; step 200 includes: step 210, using a threshold segmentation algorithm to segment the area with high brightness grayscale value on the physical image of the circuit board to obtain a grayscale image of the second region of interest; step 220, screening out two corresponding circular areas from the grayscale image of the second region of interest, calculating the coordinates of the two circular areas, and obtaining the third center coordinates and the fourth center coordinates.

[0033] In a preferred embodiment, Figure 5 , Figure 5 yes Figure 2A flowchart of a specific embodiment after step 220 in the embodiment; step 200 also includes: step 230, connecting the third circle center coordinates and the fourth circle center coordinates to obtain a second connecting line segment; step 240, calculating the length of the second connecting line segment in pixels to obtain a second length; step 250, calculating the angle of the second connecting line segment relative to the horizontal to obtain a second angle.

[0034] In this embodiment, if Figure 14 , Figure 14 It is a photograph of the actual circuit board in this application; the camera takes a picture of the circuit board components to obtain an image Image, and performs grayscale contrast enhancement on the image Scale_Image, such as Figure 15 , Figure 15 Yes Figure 14 The physical photo of the circuit board in the image is enhanced to obtain the physical image of the circuit board; the contrast between the circular exposed copper position and the background is enhanced.

[0035] The enhanced image is processed by the threshold segmentation algorithm to segment the area with high brightness grayscale value to obtain the second grayscale image of the region of interest, such as Figure 16 , Figure 20 and Figure 21 , Figure 16 Yes Figure 15 The grayscale image of the second region of interest is obtained by threshold segmentation of the physical image of the circuit board in the figure. Figure 20 is a first schematic diagram of the grayscale image of the second region of interest in this application, Figure 21 This is a second schematic diagram of a grayscale image of a second region of interest in this application.

[0036] The shapes of the regions are then filtered to select the two circular regions with the highest circular similarity, Image_CircleRegions, using select_shape(Image_ROIRegion, Image_CircleRegions,'circularity','and',Min, Max). The circular similarity range is 0.9 < Min < Max ≤ 1. These two circular regions are exposed copper areas on the circuit board, and their positions relative to the components have a high degree of relative positional invariance. The algorithm then calculates the third center coordinates of the two circular regions, Image_C1 (Image_Row1, Image_Column1), the fourth center coordinates, Image_C2 (Image_Row2, Image_Column2), the length, Image_Distance, of the second line segment connecting Image_C1 and Image_C2, and the second angle, Image_Rad, of this line segment relative to the horizontal.

[0037] Step 300: Based on the third circle center coordinates and the second connecting line segment, the grayscale image of the first region of interest is translated, rotated, and scaled to make the grayscale image of the first region of interest correspond one-to-one with the components of the physical image of the circuit board, and obtain a scale image of the region of interest. The center coordinates of each component area and the component distance between the component areas are obtained based on the scale image of the region of interest.

[0038] In a preferred embodiment, Figure 6 , Figure 6 yes Figure 1 A flowchart of a specific embodiment of step 300 in FIG. 3 is provided; step 300 includes: step 310, calculating the ordinate deviation and the abscissa deviation of the first circle center coordinate and the third circle center coordinate based on the third circle center coordinate; step 320, translating the first circle center coordinate according to the ordinate deviation and the abscissa deviation so that the first circle center coordinate coincides with the third circle center coordinate, and obtaining a translated grayscale image of interest.

[0039] In this embodiment, if Figure 17 , Figure 17 It will Figure 11 The grayscale image of the first region of interest in Figure 16 The center coordinates of the second region of interest grayscale image coincide with the map; the third center coordinate Image_C1 is the positioning position, and Cad_C1 is calculated ( Figure 17 middle red area) relative to Image_C1 ( Figure 17 The pixel position deviation of the first region of interest (the green area in the image) is calculated using the vertical coordinate deviation V_Offset = Image_Row1 - Cad_Row1 and the horizontal coordinate deviation H_Offset = Image_Column1 - Cad_Column1. The first region of interest grayscale image Cad_ROIRegion is translated vertically by V_Offset pixels and then horizontally by H_Offset pixels to obtain the translated grayscale image Cad_ROIRegion_Translate. After the translation, the coordinates of the first and third circle centers coincide.

[0040] In a preferred embodiment, Figure 7 , Figure 7 yes Figure 6 A flowchart of a specific embodiment after step 320 in the figure; step 300 also includes: step 330, calculating and obtaining the angular deviation between the first connecting line segment and the second connecting line segment; step 340, rotating the translated grayscale image of interest based on the angular deviation with the third circle center coordinate as the rotation center, so that the first connecting line segment and the second connecting line segment are at the same level, thereby obtaining a rotated grayscale image of interest.

[0041] In this embodiment, if Figure 18 , Figure 18 Yes Figure 17 Rotate the first grayscale image of the region of interest in the image to obtain the rotation coincidence image of the two; calculate the angular deviation of the first connecting line segment Cad_Line_C1C2 relative to the second connecting line segment Image_Line_C1C2, that is, Rad_Offset = Image_Rad - Cad_Rad, and use the third circle center coordinate Image_C1 as the rotation center to rotate the translated grayscale image of interest Cad_ROIRegion_Translate to obtain the rotated grayscale image of interest Cad_ROIRegion_Rotate ( Figure 18 middle blue area), such as Figure 22 and 23 , Figure 22 The second schematic diagram of the grayscale image of the first region of interest in this application and the second schematic diagram of the grayscale image of the second region of interest are located at the same center. Figure 23 It is a schematic diagram of horizontal overlap of the second schematic diagram of the grayscale image of the first region of interest and the second schematic diagram of the grayscale image of the second region of interest in this application.

[0042] In a preferred embodiment, Figure 8 Step 300 also includes: step 350, calculating and obtaining the scaling ratio between the circuit board CAD drawing and the physical image of the circuit board; step 360, scaling the rotated grayscale image of interest based on the scaling ratio and taking the third circle center coordinate as the scaling endpoint, so that the grayscale image of the first region of interest corresponds one-to-one with the components of the physical image of the circuit board, and obtaining a scale image of the region of interest.

[0043] In this embodiment, Figure 19 Yes Figure 18 The first grayscale image of the region of interest in the image is scaled to obtain a size coincidence image of the two; finally, the proportional relationship between the first length Cad_Distance and the second length Image_Distance is obtained, and the scaling ratio relationship of the region Cad_ROIRegion_Rotate relative to Image is obtained, that is, the scaling ratio Scale_Distance = Image_Distance / Cad_Distance, and the third circle center coordinate Image_C1 is used as the scaling endpoint to rotate the grayscale image of interest Cad_ROIRegion_Rotate ( Figure 19 The orange area in the middle is scaled to obtain the region of interest scale map Cad_ROIRegion_Scale, as shown in the following example: Figure 24 , Figure 24 This is a schematic diagram showing the sizes of the second schematic diagram of the grayscale image of the first region of interest and the second schematic diagram of the grayscale image of the second region of interest in this application overlapping.

[0044] It is worth noting that the translation grayscale image of interest, the rotation grayscale image of interest, and the scale image of the region of interest are state images of the translation, rotation, and scaling of the first region of interest grayscale image, respectively. By using the threshold segmentation algorithm to segment the circuit board CAD drawing and the physical image of the circuit board, the first region of interest grayscale image and the second region of interest grayscale image are obtained. Based on the second region of interest grayscale image, the first region of interest grayscale image is translated, converted, and scaled so that its components correspond one-to-one with the components on the physical image of the circuit board. In this way, the center coordinates of each component area and the component distance between component areas can be obtained, thereby achieving precise positioning of components, improving the degree of automation, and solving the problem of manual selection and positioning of components on the PCB board in existing defect detection technology, which is time-consuming, labor-intensive, and inefficient.

[0045] Second embodiment In a second aspect, a device for accurately positioning components of a circuit board adopts the method for accurately positioning components of a circuit board of the first aspect, comprising: a first image processing module 401 for acquiring a CAD drawing of a circuit board, processing the CAD drawing of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a first region of interest, and calculating the first center coordinates and the second center coordinates of any two circular areas on the grayscale image of the first region of interest, the first length of a first connecting line segment of the two circular areas, and the first angle of the first connecting line segment relative to the horizontal; a second image processing module 402 for acquiring a physical image of the circuit board, processing the physical image of the circuit board using a threshold segmentation algorithm, and calculating the first center coordinates and the second center coordinates of any two circular areas on the grayscale image of the first region of interest. The first region of interest grayscale image is processed to obtain the second region of interest grayscale image, and the third center coordinates and the fourth center coordinates of the two circular areas corresponding to the second region of interest grayscale image, the second length of the second connecting line segment of the two circular areas, and the second angle of the second connecting line segment relative to the horizontal are calculated; the positioning module 403 is used to translate, rotate and scale the first region of interest grayscale image based on the third center coordinates and the second connecting line segment, so that the first region of interest grayscale image corresponds to the components of the physical image of the circuit board one by one, and obtain the region of interest scale image, and obtain the center coordinates of each component area and the distance between the component areas according to the region of interest scale image.

[0046] Third embodiment In a third aspect, a method for detecting component defects of a circuit board includes: step 400, using the component precise positioning method of the circuit board of the first aspect to obtain the center coordinates of each component area and the component distance between the component areas; step 500, moving the defect detection platform according to the center coordinates of each component area and the component distance between the component areas, so that each component to be inspected is moved to the camera center of the defect detection platform for defect detection.

[0047] The present invention implements a method, device and defect detection method for accurately positioning components of a circuit board. By using a threshold segmentation algorithm to segment a circuit board CAD drawing and a physical image of the circuit board, a grayscale image of a first region of interest and a grayscale image of a second region of interest are obtained. The grayscale image of the first region of interest is translated, converted and scaled based on the grayscale image of the second region of interest, so that its components correspond one-to-one with the components on the physical image of the circuit board. The center coordinates of each component area and the component distance between component areas can be obtained, thereby achieving accurate positioning of components, improving the degree of automation, and solving the problem of manual frame selection and positioning of components on the PCB board in existing defect detection technology, which is time-consuming, labor-intensive and inefficient.

[0048] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for accurately positioning components on a circuit board, characterized in that: include: Step 100: Obtain a CAD drawing of a circuit board, process the CAD drawing of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a first region of interest, and calculate and obtain first and second center coordinates of any two circular areas on the grayscale image of the first region of interest, a first length of a first connecting line segment of the two circular areas, and a first angle of the first connecting line segment relative to the horizontal. Step 200: Acquire a physical image of a circuit board, process the physical image of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a second region of interest, and calculate and obtain third and fourth center coordinates of two circular areas corresponding to the grayscale image of the second region of interest, a second length of a second connecting line segment of the two circular areas, and a second angle of the second connecting line segment relative to the horizontal. Step 300: Based on the third circle center coordinates and the second connecting line segment, the grayscale image of the first region of interest is translated, rotated, and scaled to make the grayscale image of the first region of interest correspond one-to-one with the components of the physical image of the circuit board, and obtain a scale image of the region of interest. The center coordinates of each component area and the component distance between the component areas are obtained based on the scale image of the region of interest.

2. The method for accurately positioning components of a circuit board according to claim 1, wherein: The step 100 includes: Step 110: Using a threshold segmentation algorithm, segment the region with high brightness grayscale value of the circuit board CAD image to obtain the grayscale image of the first region of interest; Step 120: Filter out two circular areas from the first region of interest grayscale image, calculate the coordinates of the two circular areas, and obtain the first circle center coordinates and the second circle center coordinates.

3. The method for accurately positioning components of a circuit board according to claim 2, wherein: The step 100 further includes: Step 130: Connect the first circle center coordinates and the second circle center coordinates to obtain the first connecting line segment; Step 140: Calculate the length of the first connecting line segment in pixels to obtain the first length; Step 150: Calculate the angle of the first connecting line segment relative to the horizontal to obtain the first angle.

4. The method for accurately positioning components of a circuit board according to claim 1, wherein: The step 200 includes: Step 210: Using a threshold segmentation algorithm, segment the region with high brightness grayscale value on the physical image of the circuit board to obtain a grayscale image of the second region of interest; Step 220: Filter out two corresponding circular areas from the second region of interest grayscale image, calculate the coordinates of the two circular areas, and obtain the third circle center coordinates and the fourth circle center coordinates.

5. The method for accurately positioning components of a circuit board according to claim 4, characterized in that: The step 200 further includes: Step 230: Connect the third circle center coordinate and the fourth circle center coordinate to obtain the second connecting line segment; Step 240: Calculate the length of the second connecting line segment in pixels to obtain the second length; Step 250: Calculate the angle of the second connecting line segment relative to the horizontal to obtain the second angle.

6. The method for accurately positioning components of a circuit board according to claim 1, wherein: The step 300 includes: Step 310: Calculate the vertical coordinate deviation and horizontal coordinate deviation between the first circle center coordinate and the third circle center coordinate based on the third circle center coordinate. Step 320: translating the first circle center coordinates according to the ordinate deviation and the abscissa deviation so that the first circle center coordinates coincide with the third circle center coordinates, thereby obtaining a translated grayscale image of interest.

7. The method for accurately positioning components of a circuit board according to claim 6, wherein: The step 300 further includes: Step 330: Calculate and obtain an angular deviation between the first connecting line segment and the second connecting line segment; Step 340: According to the angle deviation, the translated grayscale image of interest is rotated with the third circle center coordinate as the rotation center, so that the first connecting line segment and the second connecting line segment are located at the same level, thereby obtaining a rotated grayscale image of interest.

8. The method for accurately positioning components of a circuit board according to claim 7, characterized in that: The step 300 further includes: Step 350: Calculate and obtain the scaling ratio between the circuit board CAD drawing and the physical image of the circuit board; Step 360: scaling the rotated grayscale image of interest based on the scaling ratio and taking the third circle center coordinates as scaling endpoints, so that the first grayscale image of the region of interest corresponds one-to-one with the components of the physical image of the circuit board, and obtaining the scale image of the region of interest.

9. A device for accurately positioning components of a circuit board, using the method for accurately positioning components of a circuit board according to any one of claims 1 to 8, characterized in that: include: A first image processing module is configured to obtain a CAD drawing of a circuit board, process the CAD drawing of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a first region of interest, and calculate and obtain first and second center coordinates of any two circular areas on the grayscale image of the first region of interest, a first length of a first connecting line segment of the two circular areas, and a first angle of the first connecting line segment relative to a horizontal direction; a second image processing module, configured to acquire a physical image of a circuit board, process the physical image of the circuit board using a threshold segmentation algorithm to obtain a grayscale image of a second region of interest, and calculate and obtain third and fourth center coordinates of two circular areas corresponding to the grayscale image of the second region of interest, a second length of a second connecting line segment of the two circular areas, and a second angle of the second connecting line segment relative to the horizontal; A positioning module is used to translate, rotate, and scale the first region of interest grayscale image based on the third circle center coordinates and the second connecting line segment, so that the first region of interest grayscale image corresponds one-to-one with the components of the physical image of the circuit board, obtain a region of interest scale image, and obtain the center coordinates of each component area and the distance between component areas based on the region of interest scale image.

10. A method for detecting component defects of a circuit board, characterized in that: include: Step 400: Use the circuit board component precise positioning method according to any one of claims 1 to 8 to obtain the center coordinates of each component area and the component distances between component areas; Step 500: Move the defect detection platform according to the center coordinates of each component area and the component distance between the component areas, so that each component to be inspected is moved to the camera center of the defect detection platform for defect inspection.