A polar defect detection method and device based on a feature point matching algorithm
The polarity defect detection method based on feature point matching algorithm uses neural network to calculate the coordinates of matching points and determine the angle difference, which solves the problems of multiple template images and high false alarm rate in PCB board inspection and achieves more efficient and accurate polarity detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA GRIDCOM
- Filing Date
- 2022-11-22
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies for PCB polarity detection suffer from problems such as numerous template images, complex operation, and high false alarm rate.
A polarity defect detection method based on feature point matching algorithm is adopted. By acquiring the image to be detected and the detection template image of the PCB board, the coordinates of the matching point are calculated using a preset neural network, and the existence of polarity defects is determined based on the angle difference between the coordinates of the matching point and the coordinates of the polarity marker point.
It improves the accuracy and efficiency of PCB board polarity defect detection, simplifies the operation process, and reduces the false alarm rate.
Smart Images

Figure CN115713639B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, and more specifically to a method, apparatus, and electronic device for judging polarity defects in PCB boards. Background Technology
[0002] Currently, the polarity markings of components on PCBs (Printed Circuit Boards) are small and diverse. Polarity detection on PCBs typically employs traditional image recognition methods, such as creating a template of the polarity markings on a PCB template and comparing the component images on the PCB with the template image to determine defects. Therefore, existing technologies suffer from the problems of requiring numerous PCB templates, complex operation, and a high false alarm rate in PCB defect detection. Summary of the Invention
[0003] Based on this, the first aspect of the present invention provides a method for detecting extreme inversion defects based on a feature point matching algorithm, which improves the accuracy of detecting extreme inversion defects on PCB boards. The method includes:
[0004] Obtain the image of the PCB board to be inspected, the inspection template image, and the coordinates of the points to be matched in the inspection template image;
[0005] The image to be detected, the detection template image, and the coordinates of the points to be matched are input into a preset neural network to obtain the coordinates of the matching points of the points to be matched in the image to be detected.
[0006] The presence of polarity defects on the PCB board is determined based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected.
[0007] In this embodiment of the invention, the preset neural network includes a feature extraction module, a transformer module, and a fully connected module connected in sequence.
[0008] The image to be detected, the detection template image, and the coordinates of the points to be matched are input into a preset neural network to obtain the coordinates of the matching points in the image to be detected, including:
[0009] The image to be detected and the detection template image are input into the feature extraction module for feature extraction to obtain the corresponding feature image to be detected and the feature image of the detection template.
[0010] The feature image to be detected and the feature image of the detection template are processed to obtain feature mapping information;
[0011] The feature mapping information and the coordinates of the points to be matched on the detection template image are input into the transformer module for processing to obtain the output information.
[0012] The output information is input into the fully connected layer to obtain the coordinates of the matching point.
[0013] In this embodiment of the invention, the feature image to be detected and the feature image of the detection template are processed to obtain feature mapping information, including:
[0014] The feature image to be detected and the feature image of the detection template are stitched together in the horizontal direction to obtain the stitched feature image;
[0015] The positional encoding of the coordinates of the points to be matched is added to the stitched feature image to obtain feature mapping information. The positional encoding is obtained by encoding the coordinates of the points to be matched.
[0016] In this embodiment of the invention, output information is obtained by processing feature mapping information and the coordinates of the points to be matched on the detection template image based on the transformer module, including:
[0017] The feature mapping information and the coordinates of the point to be matched are input into the encoder of the transformer module for encoding, and the encoded information and the encoded value of the coordinates of the point to be matched are obtained.
[0018] The encoded information and the encoded values of the coordinates of the point to be matched are input into the decoder of the transformer module for decoding, and the decoded information is used as the output information.
[0019] In this embodiment of the invention, determining whether a PCB board has a polarity defect based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected includes:
[0020] Obtain the coordinates of the first polarity marker point on the image to be detected;
[0021] Calculate the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point;
[0022] Obtain the coordinates of the second polarity marker point on the detection template image;
[0023] Calculate the second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point;
[0024] Determine whether the angle difference between the first angle and the second angle is within a preset angle threshold range;
[0025] If so, then the PCB board does not have polarity defects;
[0026] If not, then the PCB board has a polarity defect.
[0027] In this embodiment of the invention, calculating the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point includes:
[0028] Calculate the coordinates of the first centroid of the matching point;
[0029] The coordinates of the first centroid and the first polarity marker are transformed into the same coordinate system based on affine transformation.
[0030] Connect the coordinates of the first centroid point and the coordinates of the first polarity marker point, and calculate the first angle between the line connecting the coordinates of the first centroid point and the coordinates of the first polarity marker point and the horizontal axis.
[0031] In this embodiment of the invention, calculating the second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point includes:
[0032] Calculate the coordinates of the second centroid of the point to be matched;
[0033] The coordinates of the second centroid and the second polarity marker are transformed into the same coordinate system based on affine transformation.
[0034] Connect the coordinates of the second centroid and the second polarity marker, and calculate the second angle between the line connecting the coordinates of the second centroid and the second polarity marker and the horizontal axis.
[0035] A second aspect of the present invention provides a polar reflection defect detection device based on a feature point matching algorithm, comprising:
[0036] The image acquisition module acquires the image to be detected on the PCB board, the detection template image, and the coordinates of the points to be matched in the detection template image;
[0037] The matching point coordinate determination module is used to input the image to be detected, the detection template image, and the coordinates of the point to be matched into a preset neural network to obtain the coordinates of the matching point in the image to be detected.
[0038] The polarity judgment module is used to determine whether there is a polarity defect on the PCB board based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected.
[0039] A third aspect of the present invention provides an electronic device, which includes a processor and a memory. The memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the above-described extreme anti-defect detection method based on feature point matching algorithm.
[0040] A fourth aspect of the present invention provides a machine-readable storage medium storing instructions which, when executed by a processor, implement the above-described extreme anti-defect detection method based on feature point matching algorithm.
[0041] The above technical solution first obtains the image to be detected, the detection template image, and the coordinates of the matching point in the image to be detected; then, the image to be detected, the detection template image, and the coordinates of the matching point are input into a preset neural network to obtain the coordinates of the matching point in the image to be detected; finally, the PCB board is judged to have polarity defects based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected. This process improves the accuracy of polarity detection of PCB board.
[0042] Other features and advantages of the embodiments of the present invention will be described in detail in the following detailed description section. Attached Figure Description
[0043] The accompanying drawings are provided to further illustrate embodiments of the present invention and form part of the specification. They are used together with the following detailed description to explain the embodiments of the present invention, but do not constitute a limitation thereof. In the drawings:
[0044] Figure 1 This is a flowchart illustrating a polar reflection defect detection method based on a feature point matching algorithm provided in an embodiment of the present invention.
[0045] Figure 2 This is a schematic diagram of the structure of a polar reflection defect detection device based on a feature point matching algorithm provided in an embodiment of the present invention;
[0046] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0047] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the scope of the present invention.
[0048] In the field of industrial visual inspection, traditional image recognition methods are currently widely used to inspect industrial PCB boards. However, the polarity markings of components on PCB boards are small and diverse. Traditional image inspection solutions typically involve creating a template of the polarity markings on a test image, and then comparing the component images on the PCB board with the template image to detect defects. This approach suffers from problems such as a large number of template images, complex operation, and a high false alarm rate.
[0049] Based on this, this application provides a method for detecting extreme inversion defects based on a feature point matching algorithm. Figure 1 This is a flowchart illustrating a polar reflection defect detection method based on a feature point matching algorithm, as shown below. Figure 1 As shown, the method includes:
[0050] Step S101: Obtain the image to be detected on the PCB board, the detection template image, and the coordinates of the points to be matched in the detection template image.
[0051] In practical applications, polarity defect detection of PCB boards requires obtaining the image to be detected and the detection template image of the PCB board. The detection template image includes multiple polarity marker points, and the coordinates of the multiple polarity marker points are used as the coordinates of the points to be matched.
[0052] Step S102: Input the image to be detected, the detection template image, and the coordinates of the points to be matched into a preset neural network to obtain the coordinates of the matching points in the image to be detected.
[0053] In practical applications, a pre-set neural network is used to take the image to be detected, the detection template image, and the coordinates of the points to be matched as input to obtain the coordinates of the matching points on the image to be detected. Specifically, the pre-set neural network can obtain the coordinates of a single matching point and output sparse matching results, or it can calculate the matching points of all points in the image to be detected to obtain dense matching mapping relationships, thus effectively improving the detection efficiency of polar reflection defects on PCB boards.
[0054] Step S103: Determine whether the PCB board has polarity defects based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected.
[0055] In practical applications, after obtaining the coordinates of the matching point in the image to be detected, an affine transformation is used to calculate the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected, and a second angle is calculated between the coordinates of the matching point and the coordinates of the second polarity marker point in the detection template image. The difference between the first angle and the second angle is used to determine whether the PCB board has polarity defects.
[0056] Through the above embodiments, the following steps are taken: first, the image to be detected, the detection template image, and the coordinates of the matching point in the image to be detected are obtained; then, the image to be detected, the detection template image, and the coordinates of the matching point are input into a preset neural network to obtain the coordinates of the matching point in the image to be detected; finally, the presence of polarity defects in the PCB board is determined based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected. This process improves the accuracy of polarity detection of the PCB board.
[0057] In one embodiment, the preset neural network includes a feature extraction module, a transformer module, and a fully connected module connected in sequence. Step S102 includes:
[0058] The image to be detected and the detection template image are input into the feature extraction module for feature extraction to obtain the corresponding feature image to be detected and the feature image of the detection template.
[0059] The feature image to be detected and the feature image of the detection template are processed to obtain feature mapping information;
[0060] The feature mapping information and the coordinates of the points to be matched on the detection template image are input into the transformer module for processing to obtain the output information.
[0061] The output information is input into the fully connected layer to obtain the coordinates of the matching point.
[0062] In practical applications, the pre-defined neural network includes a feature extraction module, a transformer module, and a fully connected module. The feature extraction module can be either a CNN module or an RNN module; this application does not impose any restrictions. Taking the CNN module as an example, the image to be detected and the detection template image of the PCB board are input into the CNN module for feature extraction, resulting in the corresponding feature image to be detected and the detection template feature image. Based on the coordinates of the points to be matched, the feature image to be detected and the detection template feature image are processed to obtain feature mapping information. This feature mapping information is then input into the transformer module for encoding and decoding. The decoded output information is then input into the fully connected module to obtain the coordinates of the matching points.
[0063] In practical applications, after passing through the fully connected module, the coordinates of the matching point have already undergone feature combination. Therefore, after inputting the coordinates of the point to be matched into the fully connected module, the coordinates of the matching point can be output.
[0064] Through the above embodiments, a preset neural network is used to extract features from the image to be detected and the detection template image, and further processing is performed to obtain the coordinates of the matching points in the image to be detected, thereby improving the accuracy of obtaining the coordinates of the matching points.
[0065] In one embodiment, the feature image to be detected and the feature image of the detection template are processed to obtain feature mapping information, including:
[0066] The feature image to be detected and the feature image of the detection template are stitched together in the horizontal direction to obtain the stitched feature image;
[0067] The positional encoding of the coordinates of the points to be matched is added to the stitched feature image to obtain feature mapping information. The positional encoding is obtained by encoding the coordinates of the points to be matched.
[0068] In practical applications, obtaining feature mapping information first requires horizontally concatenating the feature image to be detected and the template feature image, i.e., spatially concatenating them to obtain a concatenated feature image. For example, if the feature image to be detected and the template feature image are both 16*16*256, after spatial concatenation, a concatenated feature image of 16*32*256 is obtained.
[0069] In practical applications, positional codes for the coordinates of the points to be matched are added to the stitched feature image to obtain feature mapping information. Specifically, the coordinates of the points to be matched are encoded to obtain positional codes, which are then used as spatial information encodings.
[0070] In practical applications, the expression for feature mapping information is: Where c represents the feature mapping information, To stitch together feature images, The positional encoding of the coordinates of the point to be matched.
[0071] Through the above embodiments, feature mapping information of the feature image to be detected and the feature image of the detection template is obtained using the coordinates of the point to be matched, which facilitates the subsequent calculation of the coordinates of the matching point based on the coordinates of the point to be matched.
[0072] In one embodiment, feature mapping information and the coordinates of the points to be matched on the detection template image are input to the transformer module for processing to obtain output information, including:
[0073] The feature mapping information and the coordinates of the point to be matched are input into the encoder of the transformer module for encoding, and the encoded information and the encoded value of the coordinates of the point to be matched are obtained.
[0074] The encoded information and the encoded values of the coordinates of the point to be matched are input into the decoder of the transformer module for decoding, and the decoded information is used as the output information.
[0075] In practical applications, the feature mapping information is input into the transformer module, which encodes the feature mapping information to obtain encoded information. The encoded information and the coordinates of the points to be matched on the detection template image are input into the decoder for decoding, establishing the correspondence between the image to be detected and the detection template image. The coordinates of the matching points in the image to be detected are then determined by the coordinates of the points to be matched in the detection template image.
[0076] Through the above embodiments, the feature mapping information c is input to the encoder of the transformer module. In (c), the encoding result is... (c) The encoded value P(x) corresponding to the point x to be matched is input together into the decoder of the transformer module. Finally, the decoding result is input into the fully connected layer D to obtain the coordinates of the matching point.
[0077] In one embodiment, determining whether a PCB board has a polarity defect based on the angle between the coordinates of the matching point and the coordinates of a first polarity marker point in the image to be detected includes:
[0078] Obtain the coordinates of the first polarity marker point on the image to be detected;
[0079] Calculate the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point;
[0080] Obtain the coordinates of the second polarity marker point on the detection template image;
[0081] Calculate the second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point;
[0082] Determine whether the angle difference between the first angle and the second angle is within a preset angle threshold range;
[0083] If so, then the PCB board does not have polarity defects;
[0084] If not, then the PCB board has a polarity defect.
[0085] In practical applications, determining whether a PCB board has polarity defects based on the coordinates of matching points in the image to be inspected involves several steps. First, the coordinates of the first polarity marker point in the image to be inspected are obtained. Then, the coordinates of the matching point and the first polarity marker point are transformed into the same coordinate system, and the first angle between them is calculated. Next, the coordinates of the second polarity marker point in the inspection template image are obtained. The coordinates of the point to be matched and the second polarity marker point are transformed into the same coordinate system, and the second angle between them is calculated.
[0086] In practical applications, the angle difference between the first angle and the second angle is calculated, and it is determined whether the angle difference is within a preset angle threshold range. If the angle difference is within the preset angle threshold range, the PCB board components do not exhibit polar inversion; if the angle difference is not within the preset angle threshold range, the PCB board components exhibit polar inversion. It is understandable that different components can be set with different angle threshold ranges.
[0087] Through the above embodiments, the first angle between the coordinates of the matching point in the image to be detected and the coordinates of the first polarity marker point is compared with the second angle between the coordinates of the matching point in the detection template image and the coordinates of the second polarity marker point. By comparing the first angle and the second angle, it is determined whether the image to be detected is the same as that in the detection template image and whether there is a phenomenon of polarity reversal of components.
[0088] In one embodiment, calculating the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point includes:
[0089] Calculate the coordinates of the first centroid of the matching point;
[0090] The coordinates of the first centroid and the first polarity marker are transformed into the same coordinate system based on affine transformation.
[0091] Connect the coordinates of the first centroid point and the coordinates of the first polarity marker point, and calculate the first angle between the line connecting the coordinates of the first centroid point and the coordinates of the first polarity marker point and the horizontal axis.
[0092] In practical applications, the first centroid coordinates of all matching points in the image to be detected are calculated. The first centroid coordinates and the first polarity marker coordinates are transformed into the same coordinate system through affine transformation. The first centroid coordinates and the first polarity marker coordinates are connected, and the first angle between the line connecting the first centroid coordinates and the first polarity marker coordinates and the horizontal axis is calculated.
[0093] In one embodiment, calculating the second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point includes:
[0094] Calculate the coordinates of the second centroid of the point to be matched;
[0095] The coordinates of the second centroid and the second polarity marker are transformed into the same coordinate system based on affine transformation.
[0096] Connect the coordinates of the second centroid and the second polarity marker, and calculate the second angle between the line connecting the coordinates of the second centroid and the second polarity marker and the horizontal axis.
[0097] Through the above embodiments, the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected are transformed into the same coordinate system according to the affine transformation, and the first angle of the line connecting the coordinates of the matching point and the coordinates of the first polarity marker point is calculated. The coordinates of the matching point and the coordinates of the second polarity marker point in the detection template image are transformed into the same coordinate system, and the second angle of the line connecting the coordinates of the matching point and the coordinates of the second polarity marker point is calculated.
[0098] Based on the above-described extreme inversion defect detection method based on feature point matching algorithm, this embodiment of the invention also provides an extreme inversion defect detection device 200 based on feature point matching algorithm. Figure 2 This is a schematic diagram of a polar reflection defect detection device based on a feature point matching algorithm. The detection device 200 includes:
[0099] Image acquisition module 201 acquires the image to be detected on the PCB board, the detection template image, and the coordinates of the points to be matched in the detection template image;
[0100] The matching point coordinate determination module 202 is used to input the image to be detected, the detection template image and the coordinates of the point to be matched into a preset neural network to obtain the coordinates of the matching point in the image to be detected.
[0101] The polarity judgment module 203 is used to determine whether there is a polarity defect on the PCB board based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected.
[0102] The extreme inverse defect detection device based on feature point matching algorithm provided in this application embodiment can realize each process of the extreme inverse defect detection method based on feature point matching algorithm in the method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0103] This invention also provides an electronic device, see [link to relevant documentation]. Figure 3 As shown, the electronic device includes a processor 130 and a memory 131. The memory 131 stores machine-executable instructions that can be executed by the processor 130. The processor 130 executes the machine-executable instructions to implement the above-described extreme anti-defect detection method based on feature point matching algorithm.
[0104] Furthermore, Figure 3 The electronic device shown also includes a bus 132 and a communication interface 133, with the processor 130, the communication interface 133 and the memory 131 connected via the bus 132.
[0105] The memory 131 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 133 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 132 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0106] Processor 130 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 130 or by instructions in software form. Processor 130 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 131. The processor 130 reads the information from memory 131 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0107] This invention also provides a machine-readable storage medium storing machine-executable instructions. When these machine-executable instructions are called and executed by a processor, they cause the processor to implement the above-described extreme anti-defect detection method based on feature point matching algorithm. For specific implementation details, please refer to the method embodiments, which will not be repeated here.
[0108] The present invention provides a method and apparatus for detecting extreme inversion defects based on a feature point matching algorithm, which includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.
[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0110] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0111] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0112] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0113] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for detecting extreme inversion defects based on a feature point matching algorithm, characterized in that, include: Obtain the image of the PCB board to be inspected, the inspection template image, and the coordinates of the points to be matched in the inspection template image; The image to be detected, the detection template image, and the coordinates of the point to be matched are input into a preset neural network to obtain the coordinates of the matching point of the point to be matched in the image to be detected. The preset neural network includes a feature extraction module, a transformer module, and a fully connected module connected in sequence. The presence of polarity defects in the PCB board is determined based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected. The step of determining whether the PCB board has a polarity defect based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected includes: Obtain the coordinates of the first polarity marker point on the image to be detected; Calculate the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point; Obtain the coordinates of the second polarity marker point on the detection template image; Calculate the second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point; Determine whether the angle difference between the first angle and the second angle is within a preset angle threshold range; If so, then the PCB board does not have polarity defects; If not, then the PCB board has an extreme polarity defect.
2. The method according to claim 1, characterized in that, The step of inputting the image to be detected, the detection template image, and the coordinates of the point to be matched into a preset neural network to obtain the coordinates of the matching point of the point to be matched in the image to be detected includes: The image to be detected and the detection template image are input into the feature extraction module for feature extraction to obtain the corresponding feature image to be detected and the detection template feature image. The feature image to be detected and the feature image of the detection template are processed to obtain feature mapping information; The feature mapping information and the coordinates of the points to be matched on the detection template image are input into the transformer module for processing to obtain output information; The output information is input into the fully connected layer to obtain the coordinates of the matching point.
3. The method according to claim 2, characterized in that, The process of processing the feature image to be detected and the detection template feature image to obtain feature mapping information includes: The feature image to be detected and the feature image of the detection template are stitched together in the horizontal direction to obtain the stitched feature image; The positional encoding of the coordinates of the point to be matched is added to the stitched feature image to obtain the feature mapping information, wherein the positional encoding is obtained by encoding based on the coordinates of the point to be matched.
4. The method according to claim 2, characterized in that, The step of inputting the feature mapping information and the coordinates of the points to be matched on the detection template image into the transformer module for processing to obtain output information includes: The feature mapping information and the coordinates of the point to be matched are input into the encoder of the transformer module for encoding to obtain the encoded information and the encoded value of the coordinates of the point to be matched. The encoded information and the encoded values of the coordinates of the point to be matched are input into the decoder of the transformer module for decoding to obtain decoded information, and the decoded information is used as the output information.
5. The method according to claim 1, characterized in that, The calculation of the first angle between the coordinates of the matching point and the coordinates of the first polarity marker point includes: Calculate the coordinates of the first centroid of the matching point; The coordinates of the first centroid point and the first polarity marker point are transformed to the same coordinate system based on affine transformation; Connect the coordinates of the first centroid point and the coordinates of the first polarity marker point, and calculate the first angle between the line connecting the coordinates of the first centroid point and the coordinates of the first polarity marker point and the horizontal axis.
6. The method according to claim 1, characterized in that, The calculation of the second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point includes: Calculate the coordinates of the second centroid of the point to be matched; The coordinates of the second centroid and the second polarity marker are transformed to the same coordinate system based on affine transformation. Connect the coordinates of the second centroid point and the coordinates of the second polarity marker point, and calculate the second angle between the line connecting the coordinates of the second centroid point and the coordinates of the second polarity marker point and the horizontal axis.
7. A polar reflection defect detection device based on a feature point matching algorithm, characterized in that, include: The image acquisition module acquires the image to be detected on the PCB board, the detection template image, and the coordinates of the points to be matched in the detection template image; The matching point coordinate determination module is used to input the image to be detected, the detection template image, and the coordinates of the point to be matched into a preset neural network to obtain the coordinates of the matching point of the point to be matched in the image to be detected. The preset neural network includes a feature extraction module, a transformer module, and a fully connected module connected in sequence. The polarity reversal judgment module is used to determine whether the PCB board has a polarity reversal defect based on the angle between the coordinates of the matching point and the coordinates of the first polarity marker point in the image to be detected. The module includes: obtaining the coordinates of the first polarity marker point in the image to be detected; calculating a first angle between the coordinates of the matching point and the coordinates of the first polarity marker point; obtaining the coordinates of a second polarity marker point in the detection template image; calculating a second angle between the coordinates of the point to be matched and the coordinates of the second polarity marker point; determining whether the angle difference between the first angle and the second angle is within a preset angle threshold range; if yes, the PCB board does not have a polarity reversal defect; if no, the PCB board has a polarity reversal defect.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the extreme anti-defect detection method based on feature point matching algorithm according to any one of claims 1 to 6.
9. A machine-readable storage medium storing instructions thereon, characterized in that, When the instructions are executed by the processor, they implement the extreme anti-defect detection method based on the feature point matching algorithm as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Depth measurement method based on binocular three-dimensional vision
CN101907448A
PCB plate defect detection method and system
CN112233100A