Circuit board defect detection method, device and equipment and storage medium

By comparing the similarity between the image of the circuit board to be tested and the images of the standard and defective circuit boards, the problem of misjudgment in the circuit board defect detection in the prior art is solved, and more accurate component defect detection is achieved.

CN119515756APending Publication Date: 2025-02-25GUANGZHOU LEICHEN INTELLIGENT EQUIP TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311017127.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-11
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

Existing circuit board defect detection methods are prone to misjudgment, especially when the pads or devices are blocked, it is difficult to accurately detect component defects.

Method used

By acquiring the target image of the circuit board to be tested, the first reference image of the standard circuit board without component defects, and the second reference image of the defective circuit board having component defects, the similarity between the two is calculated, and the component defect detection result of the circuit board to be tested is determined based on the similarity.

Benefits of technology

This method improves the accuracy of circuit board component defect detection through forward and reverse references, and can accurately detect component defects of circuit boards, especially when pads or devices are blocked.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119515756A_ABST
    Figure CN119515756A_ABST
Patent Text Reader

Abstract

The invention provides a circuit board defect detection method and device, equipment and a storage medium, and the method comprises the steps: obtaining a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, the first reference image is an image of a standard circuit board without element defects, and the second reference image is an image of a defective circuit board with element defects; determining a first similarity between the target image and the first reference image, and determining a second similarity between the target image and the second reference image; and determining an element defect detection result of the to-be-detected circuit board according to the first similarity and the second similarity. According to the technical scheme, when the bonding pad or the device is shielded, the element defect condition of the circuit board can be accurately detected, and the detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of defect detection, and in particular to a circuit board defect detection method, device, equipment and storage medium. Background Art

[0002] With the continuous development of industrial production and technology, the requirements for production efficiency and quality are getting higher and higher. In the production process of printed circuit boards (PCBs), PCB defects are detected based on the principle of optical detection to determine whether there are component defects such as wrong soldering, soldering leakage or multiple soldering of components on the PCB, and then determine whether the PCB meets the production requirements.

[0003] At present, the PCB to be inspected is photographed by optical inspection equipment, and the image of the PCB to be inspected is compared with the image of the standard PCB to determine whether there are any missing components on the PCB to be inspected. Since the image of the PCB to be inspected is similar to the image background of the standard PCB, misjudgment is prone to occur when the pads or components are blocked. Summary of the invention

[0004] The present application provides a circuit board defect detection method, device, equipment and storage medium to solve the technical problem that circuit board defect detection is prone to misjudgment.

[0005] In a first aspect, a circuit board defect detection method is provided, comprising:

[0006] Acquire a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, wherein the target image is an image of a circuit board to be tested, the first reference image is an image of a standard circuit board without component defects, and the second reference image is an image of a defective circuit board with component defects;

[0007] Determining a first similarity between the target image and the first reference image, and determining a second similarity between the target image and the second reference image;

[0008] A component defect detection result of the circuit board to be tested is determined according to the first similarity and the second similarity.

[0009] In this technical solution, by obtaining a target image of the circuit board to be tested, a first reference image of a standard circuit board without component defects, and a second reference image of a defective circuit board with component defects, and then determining a first similarity between the target image and the first reference image, and a second similarity between the target image and the second reference image, the component defect detection result of the circuit board to be tested is determined according to the first similarity and the second similarity. Since the component defect detection result of the circuit board to be tested is determined by comparing the image of the circuit board to be tested with the image with component defects and the image without component defects by similarity, there is not only a positive reference but also a reverse reference. When the pad or device is blocked, the component defect of the circuit board can be detected more accurately, thereby improving the accuracy of detection.

[0010] In combination with the first aspect, in a possible implementation, determining the component defect detection result of the target image according to the first similarity and the second similarity includes: if the first similarity is greater than the second similarity, determining that the circuit board to be tested does not have component defects; if the first similarity is less than the second similarity, determining that the circuit board to be tested has component defects. The component defect situation of the circuit board to be tested is determined by comparing the size of the similarity, and the implementation method is simple.

[0011] In combination with the first aspect, in a possible implementation, the determining of the first similarity between the target image and the first reference image, and the determining of the second similarity between the target image and the second reference image, include: extracting features from the target image, the first reference image, and the second reference image, respectively, to obtain image features corresponding to the target image, the first reference image, and the second reference image; calculating the similarity between the image features corresponding to the target image and the image features corresponding to the first reference image, to obtain the first similarity, and calculating the similarity between the image features corresponding to the target image and the image features corresponding to the second reference image, to obtain the second similarity. By first extracting features from the images, and determining the similarity between the images based on the similarity between the image features, it is possible to avoid partial noise interference in the images, more accurately judge the similarity between the images, and help improve the accuracy of subsequent component defect detection results.

[0012] In combination with the first aspect, in a possible implementation, the target image, the first reference image, and the second reference image are respectively subjected to feature extraction to obtain image features corresponding to the target image, the first reference image, and the second reference image, including: inputting the target image, the first reference image, and the second reference image into a three-input twin neural network for feature extraction to obtain image features corresponding to the target image, the first reference image, and the second reference image, wherein the three-input twin neural network includes three feature extraction modules, and each of the three feature extraction modules has the same structure and weight parameters. By extracting image features of the target image, the first reference image, and the second reference image including three three-input twin neural networks with the same structure and weight parameters, accurate extraction of image features can be achieved, which is beneficial to judging the similarity between images.

[0013] In combination with the first aspect, in a possible implementation, the method further includes: obtaining a target sample image, a positive sample image corresponding to the target sample image, and a negative sample image corresponding to the target sample image, wherein the component defect condition of the positive sample image is the same as the component defect condition of the target sample image, and the component defect condition of the negative sample image is different from the component defect condition of the target sample image, and one of the positive sample image and the negative sample image is an image of a standard circuit board without component defects, and the other of the positive sample image and the negative sample image is an image of a defective circuit board with component defects; and the three-input twin neural network is obtained by training according to the target sample image, the positive sample image, and the negative sample image. By pre-adopting sample images, positive sample images, and negative sample images to train the three-input twin neural network, the three-input twin neural network can be made capable of accurately extracting image features.

[0014] In combination with the first aspect, in a possible implementation, the training of the three-input twin neural network according to the target sample image, the positive sample image and the negative sample image includes: inputting the target sample image, the positive sample image and the negative sample image into the three feature extraction modules for feature extraction respectively, and obtaining the image features corresponding to the target sample image, the positive sample image and the negative sample image; calculating the feature difference between the image features corresponding to the target sample image and the image features corresponding to the positive sample image, and obtaining the first difference; calculating the feature difference between the image features corresponding to the target sample image and the image features corresponding to the negative sample image, and obtaining the second difference; adjusting the weight parameters of the three feature extraction modules according to the first difference and the second difference, so that the first difference is reduced and the second difference is increased. By adjusting the weight parameters of the three feature extraction modules in the three-input twin neural network, so that the difference between the target sample image and the positive sample image is reduced, and the difference between the target sample image and the negative sample image is increased, the three-input neural network can be equipped with the ability to extract features that can distinguish images of different defect conditions.

[0015] In combination with the first aspect, in a possible implementation, the weight parameters of the three feature extraction modules are adjusted according to the first difference and the second difference so that the first difference decreases and the second difference increases, including: calculating the model loss according to a preset loss function, the first difference and the second difference, the preset loss function is: loss = max (S1-S2+m, 0), loss represents the model loss, S1 is the first difference, S2 is the second difference, and m represents a hyperparameter; according to the model loss, the weight parameters of the three feature extraction modules are adjusted so that the model loss decreases. Calculating the model loss according to the preset loss function and adjusting the weight parameters of the feature extraction modules so that the model loss decreases can reduce the intra-class difference and increase the inter-class difference, so that the three-input neural network has the ability to extract image features more accurately.

[0016] In combination with the first aspect, in a possible implementation, the calculating the feature difference between the image feature corresponding to the target sample image and the image feature corresponding to the positive sample image to obtain a first difference, and calculating the feature difference between the image feature corresponding to the target sample image and the image feature corresponding to the negative sample image to obtain a second difference, includes: calculating the Euclidean distance between the image feature corresponding to the target sample image and the image feature corresponding to the positive sample image to obtain the first difference; calculating the Euclidean distance between the image feature corresponding to the target sample image and the image feature corresponding to the negative sample image to obtain the second difference. By calculating the Euclidean distance of the image features to determine the difference between the image features, the difference between the image features can be accurately evaluated.

[0017] In combination with the first aspect, in a possible implementation, before determining the first similarity between the target image and the first reference image, and determining the second similarity between the target image and the second reference image, it also includes: performing image enhancement processing on the target image, the first reference image, and the second reference image, respectively, to obtain the target image, the first reference image, and the second reference image after image enhancement; determining the first similarity between the target image and the first reference image, and determining the second similarity between the target image and the second reference image, includes: determining the first similarity between the target image after image enhancement and the first reference image after image enhancement, and determining the second similarity between the target image after image enhancement and the second reference image after image enhancement. By performing enhancement processing on the images and then determining the similarity between the images, it is helpful to more accurately determine the similarity between the images.

[0018] In combination with the first aspect, in a possible implementation, the image enhancement processing is performed on the target image, the first reference image, and the second reference image to obtain the target image, the first reference image, and the second reference image after image enhancement, including: performing image sharpening on the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image; performing color compression on the sharpened images corresponding to the target image, the first reference image, and the second reference image to obtain the color compressed images corresponding to the target image, the first reference image, and the second reference image; performing contrast enhancement on the color compressed images corresponding to the target image, the first reference image, and the second reference image to obtain the target image, the first reference image, and the second reference image after image enhancement. By performing sharpening, color compression, and contrast enhancement on the images in sequence, an image with clearer details can be obtained, which helps to more accurately determine the similarity between images.

[0019] In combination with the first aspect, in a possible implementation, before performing image sharpening on the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image, the method further includes: performing color space transformation on the target image, the first reference image, and the second reference image to obtain the target image, the first reference image, and the second reference image in the HSV color space; performing image sharpening on the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image, includes: performing image sharpening on the target image, the first reference image, and the second reference image in the HSV color space to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image. Before sharpening the image, transforming the image to the HSV space can suppress the interference of environmental variables and help to more accurately determine the similarity between images.

[0020] In combination with the first aspect, in a possible implementation, before performing image sharpening on the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image, the method further includes: performing center cropping and size scaling on the target image, the first reference image, and the second reference image to obtain the local images corresponding to the target image, the first reference image, and the second reference image; performing image sharpening on the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image, the method further includes: performing image sharpening on the local images corresponding to the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image. Performing center cropping and scaling on the image before sharpening can reduce interference from the image background and help to more accurately determine the similarity between images.

[0021] In combination with the first aspect, in a possible implementation, before the target image, the first reference image, and the second reference image are subjected to center cropping and size scaling respectively to obtain the local images corresponding to the target image, the first reference image, and the second reference image, the method further includes: performing affine transformation on the target image, the first reference image, and the second reference image along a coordinate axis respectively. Performing affine transformation on an image can achieve distortion correction of the image, which helps to more accurately determine the similarity between images.

[0022] In a second aspect, a circuit board defect detection device is provided, comprising:

[0023] An image acquisition module, used to acquire a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, wherein the target image is an image of a circuit board to be tested, the first reference image is an image of a standard circuit board without component defects, and the second reference image is an image of a defective circuit board with component defects;

[0024] a similarity determination module, configured to determine a first similarity between the target image and the first reference image, and to determine a second similarity between the target image and the second reference image;

[0025] The result determination module is used to determine the component defect detection result of the circuit board to be tested according to the first similarity and the second similarity.

[0026] In a third aspect, a computer device is provided, comprising a memory and one or more processors, wherein the memory is connected to the one or more processors, and the one or more processors are used to execute one or more computer programs stored in the memory, and when the one or more processors execute the one or more computer programs, the computer device implements the circuit board defect detection method of the first aspect mentioned above.

[0027] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the circuit board defect detection method of the first aspect.

[0028] The present application can achieve the following technical effects: since the component defect detection result of the circuit board to be tested is determined by comparing the similarity between the image of the circuit board to be tested and the image with component defects and the image without component defects, there is not only a positive reference but also a reverse reference. When the pad or device is blocked, the component defects of the circuit board can be detected more accurately, thereby improving the accuracy of detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of a flow chart of a circuit board defect detection method provided in an embodiment of the present application;

[0030] Figure 2 A schematic diagram of a flow chart of another circuit board defect detection method provided in an embodiment of the present application;

[0031] Figure 3 A schematic diagram of center cropping and size scaling of an image provided in an embodiment of the present application;

[0032] Figure 4 A schematic diagram of a flow chart of another circuit board defect detection method provided in an embodiment of the present application;

[0033] Figure 5 A schematic diagram of the structure of a three-input twin neural network provided in an embodiment of the present application;

[0034] Figure 6 It is a structural schematic diagram of a circuit board defect detection device provided in an embodiment of the present application;

[0035] Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0036] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0037] The technical solution of the present application is applicable to the circuit board component defect detection scenario. In the circuit board component defect detection scenario, the circuit board to be detected is generally photographed by an optical detection device to obtain an image of the circuit board to be detected (hereinafter referred to as the image to be detected), and then the image to be detected is calculated for similarity with the image of the standard circuit board (hereinafter referred to as the standard image). If the similarity between the image to be detected and the standard image is greater than the similarity threshold, it is determined that there are no component defects in the circuit board to be detected, that is, there are no component omissions; if the similarity between the image to be detected and the standard image is less than the similarity threshold, it is determined that there are component defects in the circuit board to be detected, that is, there are component omissions. Since the difference between the circuit board to be detected and the standard circuit board is only in the pad area, and other areas are the same, only the standard circuit board is used for comparison, and the circuit board to be detected with component defects may be judged as a standard circuit, that is, a false detection occurs.

[0038] In view of this, the present application proposes a circuit board defect detection method. In addition to using the image of a standard circuit board without component defects as a reference, the image of a defective circuit board with component defects is also used as a reference. The component defect result of the circuit board to be tested is comprehensively determined by comparing the similarity between the image of the circuit board to be tested and the two reference images. Because the image of the defective circuit board is used as a negative reference, the component defect situation of the circuit board to be tested can be detected more accurately, thereby improving the accuracy of detection.

[0039] The technical solution of the present application is described in detail below. The technical solution of the present application can be applied to computer devices with image processing functions. The computer devices include but are not limited to optical detection equipment, desktop computers, servers, and the like.

[0040] See also Figure 1 , Figure 1A schematic diagram of a circuit board defect detection method provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method comprises the following steps:

[0041] S101, acquiring a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image.

[0042] The target image is an image of a circuit board to be tested. The circuit board to be tested refers to a circuit board that needs to be tested for component defects. Component defects refer to various component defects that exist in the process of producing circuit boards. Component defects include but are not limited to component missoldering, component leaking, component oversoldering, etc. A circuit board with at least one component defect is a circuit board with component defects, and a circuit board with component defects can be called a defective circuit board; a circuit board without any component defects is a circuit board without component defects, and a circuit board without component defects can be called a standard circuit board.

[0043] The first reference image is an image of a standard circuit board, and the second reference image is an image of a defective circuit board.

[0044] Specifically, the circuit board to be tested may be photographed to obtain a target image, and a first reference image corresponding to the target image and a second reference image corresponding to the target image may be obtained locally from a computer device. Optionally, the target image may also be obtained locally from a computer device.

[0045] S102: Determine a first similarity between the target image and the first reference image, and determine a second similarity between the target image and the second reference image.

[0046] Specifically, one or more image similarity algorithms selected from cosine similarity, mean hash algorithm, difference hash algorithm, perceptual hash algorithm, and histogram distance can be used to calculate the similarity between the target image and the first reference image, and the similarity between the target image and the second reference image, thereby determining the first similarity and the second similarity. The image similarity algorithm used to calculate the similarity between the target image and the first reference image is the same as the image similarity algorithm used to calculate the similarity between the target image and the second reference image.

[0047] If an image similarity algorithm is used to calculate the similarity between the target image and the first reference image, and the similarity between the target image and the second reference image, the two similarities calculated are the first similarity and the second similarity, respectively.

[0048] If multiple image similarity algorithms are used to calculate the similarity between the target image and the first reference image, and the similarity between the target image and the second reference image, the first similarity and the second similarity can be obtained by weighted summing or weighted averaging the similarities calculated by different image similarity algorithms. The first similarity can be obtained by weighted summing or weighted averaging the similarities between the target image and the first reference image calculated by different image similarity algorithms; the second similarity can be obtained by weighted summing or weighted averaging the similarities between the target image and the second reference image calculated by different image similarity algorithms.

[0049] S103: Determine a component defect detection result of the circuit board to be tested according to the first similarity and the second similarity.

[0050] Specifically, if the first similarity is greater than the second similarity, it means that the target image is more similar to the first reference image, that is, the circuit board to be tested is closer to the standard circuit board, and it is determined that there is no component defect in the circuit board to be tested; if the first similarity is less than the second similarity, it means that the target image is more similar to the second reference image, that is, the circuit board to be tested is closer to the defective circuit board, and it is determined that there is a component defect in the circuit board to be tested. The component defect of the circuit board to be tested is determined by comparing the size of the similarity, and the implementation method is simple.

[0051] In the above Figure 1 In the corresponding technical solution, by obtaining a target image of the circuit board to be tested, a first reference image of a standard circuit board without component defects, and a second reference image of a defective circuit board with component defects, and then determining a first similarity between the target image and the first reference image, and a second similarity between the target image and the second reference image, the component defect detection result of the circuit board to be tested is determined according to the first similarity and the second similarity. Since the component defect detection result of the circuit board to be tested is determined by comparing the image of the circuit board to be tested with the image with component defects and the image without component defects for similarity, there is not only a positive reference but also a reverse reference. When the pad or device is blocked, the component defect of the circuit board can also be detected more accurately, thereby improving the accuracy of detection.

[0052] In some possible cases, before comparing the similarity between images, image enhancement can also be performed on the images to improve the image details. Figure 2 , Figure 2 A schematic diagram of a flow chart of another circuit board defect detection method provided in an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:

[0053] S201, acquiring a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image.

[0054] Here, the specific implementation of step S201 can refer to the relevant description of the aforementioned step S101, which will not be repeated here.

[0055] S202, performing image enhancement processing on the target image, the first reference image and the second reference image respectively to obtain the target image, the first reference image and the second reference image after image enhancement.

[0056] Here, the purpose of performing image enhancement processing on the target image, the first reference image and the second reference image is to improve the image quality of the target image, the first reference image and the second reference image and increase the amount of information contained in the target image, the first reference image and the second reference image.

[0057] In a feasible implementation manner, image enhancement processing of the target image, the first reference image, and the second reference image may be implemented through the following steps A1-A3:

[0058] A1. Perform image sharpening on the target image, the first reference image, and the second reference image respectively to obtain sharpened images corresponding to the target image, the first reference image, and the second reference image.

[0059] Specifically, the target image, the first reference image and the second reference image can be sharpened respectively based on any one of the differential algorithms such as the gradient algorithm, the Roberts gradient algorithm, the Sobel algorithm, the Prewitt algorithm, the Laplace algorithm, etc., to obtain sharpened images corresponding to the target image, the first reference image and the second reference image.

[0060] By performing image sharpening on the target image, the first reference image and the second reference image respectively, noise information in the target image, the first reference image and the second reference image can be removed, and edge details in the target image, the first reference image and the second reference image can be highlighted.

[0061] A2. Perform color compression on the target image, the sharpened images corresponding to the first reference image and the second reference image respectively to obtain color compressed images corresponding to the target image, the first reference image and the second reference image.

[0062] Specifically, for each of the sharpened images corresponding to the target image, the first reference image, and the second reference image, the bit of each pixel in the image (here, the sharpened image corresponding to the target image, the sharpened image corresponding to the first reference image, or the sharpened image corresponding to the second reference image) can be compressed to reduce the number of bits of each pixel in the image, thereby achieving color compression of the image, thereby obtaining the color compressed image corresponding to the target image, the first reference image, and the second reference image. For each of the sharpened images corresponding to the target image, the first reference image, and the second reference image, the bit of each pixel in the image can be compressed based on the K-means clustering algorithm to reduce the number of bits of each pixel in the image.

[0063] A3. Contrast enhancement is performed on the target image, the first reference image, and the color compressed images corresponding to the second reference image to obtain the target image, the first reference image, and the second reference image after image enhancement.

[0064] Specifically, for each of the target image, the first reference image, and the color compressed image corresponding to the second reference image, histogram equalization can be performed on the image (here, the color compressed image corresponding to the target image, the color compressed image corresponding to the first reference image, or the color compressed image corresponding to the second reference image) to achieve contrast enhancement of the image, thereby obtaining the target image, the first reference image, and the second reference image after image enhancement. By performing contrast enhancement on the color compressed images corresponding to the target image, the first reference image, and the second reference image through histogram equalization, the information structure of the image can be avoided from being changed.

[0065] By sequentially sharpening, color compressing, and contrast enhancing the image, an image with clearer details can be obtained, which helps to more accurately determine the similarity between images.

[0066] In some possible cases, before performing image sharpening on the target image, the first reference image, and the second reference image to obtain the sharpened images corresponding to the target image, the first reference image, and the second reference image, color space transformation may be performed on the target image, the first reference image, and the second reference image to obtain the target image, the first reference image, and the second reference image in the HSV (hue, saturation, value) color space.

[0067] Specifically, for each of the target image, the first reference image, and the second reference image, each pixel in the image (here, the target image, the first reference image, or the second reference image) can be processed according to the following formula, and each pixel in the image is converted to the HSV color space, thereby obtaining the target image, the first reference image, and the second reference image in the HSV color space:

[0068]

[0069]

[0070]

[0071]

[0072]

[0073]

[0074] When the target image, the first reference image and the second reference image are converted into the HSV color space, the sharpened images corresponding to the target image, the first reference image and the second reference image can be obtained by respectively sharpening the target image, the first reference image and the second reference image in the HSV color space. The specific implementation method of image sharpening can refer to the description of the aforementioned step A1 and will not be repeated here.

[0075] Before sharpening the image, the image is transformed into the HSV color space, which can suppress the interference of environmental variables and help to more accurately determine the similarity between images.

[0076] In some possible situations, before performing image sharpening on the target image, the first reference image, and the second reference image to obtain sharpened images corresponding to the target image, the first reference image, and the second reference image, center cropping and resizing processing may be performed on the target image, the first reference image, and the second reference image to obtain local images corresponding to the target image, the first reference image, and the second reference image.

[0077] Specifically, for each of the target image, the first reference image and the second reference image, the center of the image (here referring to the target image, the first reference image or the second reference image) can be used as the cropping center, and an image area with a random size centered on the cropping center can be cropped, and the cropped image area can be scaled to a preset size to achieve center cropping and size scaling of the image, thereby obtaining local images corresponding to the target image, the first reference image and the second reference image.

[0078] For example, the image to be processed (which may be a target image, a first reference image or a second reference image) is as follows: Figure 3 As shown in P1, Figure 3 Point a in the image is the center of the image. For image P1, we can use a as the cropping center to crop an area of ​​any size, and get Figure 3 The image area Q in the image is then scaled to a fixed size to obtain the local image P2 corresponding to the image P1.

[0079] When the target image, the first reference image, and the second reference image are respectively subjected to center cropping and size scaling processing, the sharpened images corresponding to the target image, the first reference image, and the second reference image can be obtained by respectively sharpening the local images corresponding to the target image, the first reference image, and the second reference image. The specific method of image sharpening can be referred to the description of the aforementioned step A1, which will not be repeated here.

[0080] Optionally, before color space transformation is performed on the target image, the first reference image, and the second reference image to obtain the target image, the first reference image, and the second reference image in the HSV color space, the target image, the first reference image, and the second reference image may be respectively subjected to center cropping and size scaling to obtain local images corresponding to the target image, the first reference image, and the second reference image. In this case, the target image, the first reference image, and the second reference image in the HSV color space may be obtained by color space transformation of local images corresponding to the target image, the first reference image, and the second reference image. The specific implementation of the color space transformation can refer to the above description and will not be repeated here.

[0081] In some possible situations, before performing center cropping and resizing processing on the target image, the first reference image, and the second reference image to obtain local images corresponding to the target image, the first reference image, and the second reference image, affine transformation may be performed on the target image, the first reference image, and the second reference image along a coordinate axis.

[0082] Specifically, for each of the target image, the first reference image and the second reference image, the image can be affine transformed with the X-axis or Y-axis of the image (here referring to the target image, the first reference image or the second reference image) as the axis transformation center, so as to obtain the affine transformed images corresponding to the target image, the first reference image and the second reference image.

[0083] For example, if the Y axis is fixed and the transformation is along the X axis, the position coordinate transformation formula of a pixel in the image is as follows:

[0084]

[0085]

[0086] in, is the position coordinate of the pixel in the image after transformation, (x, y) is the position coordinate of the pixel in the image before transformation, (x c ,y c ) is the position coordinate of the center point of the image.

[0087] In this case, the local images corresponding to the target image, the first reference image and the second reference image are obtained by performing center cropping and size scaling on the affine transformation images corresponding to the target image, the first reference image and the second reference image respectively. The specific implementation method of center cropping and size scaling can be referred to the above description and will not be repeated here.

[0088] Performing an affine transformation on an image can correct the distortion of the image and help determine the similarity between images more accurately.

[0089] It should be noted that the above-described image processing all belongs to the category of image enhancement. In an optional implementation, the image enhancement of the target image, the first reference image and the second reference image can also be achieved by other methods, which are not limited in this application.

[0090] S203, determining a first similarity between the target image after image enhancement and the first reference image after image enhancement, and determining a second similarity between the target image after image enhancement and the second reference image after image enhancement.

[0091] Here, the specific implementation method of determining the first similarity between the target image after image enhancement and the first reference image after image enhancement, and determining the second similarity between the target image after image enhancement and the second reference image after image enhancement is similar to the specific implementation method of determining the first similarity between the target image and the first reference image, and determining the second similarity between the target image and the second reference image in the aforementioned step S102. Please refer to the description of the aforementioned step S102, or refer to the description of the subsequent steps S302 to S303, and no further details will be given here.

[0092] S204: Determine a component defect detection result of the circuit board to be tested according to the first similarity and the second similarity.

[0093] Here, the specific implementation of step S204 can refer to the description of the aforementioned step S103, which will not be repeated here.

[0094] In the above Figure 2 In the corresponding technical solution, after obtaining the target image of the circuit board to be tested, the first reference image of the standard circuit board without component defects, and the second reference image of the defective circuit board with component defects, the similarity between the images can be more accurately determined by enhancing the images respectively and then determining the similarity between the target image and the first reference image, and between the target image and the second reference image, thereby helping to improve the accuracy of the component defect detection results.

[0095] In some possible cases, the similarity between two images can be compared by comparing the similarity between the image features of the two images. Figure 4 , Figure 4 A schematic diagram of a flow chart of another circuit board defect detection method provided in an embodiment of the present application, such as Figure 4 As shown, the method comprises the following steps:

[0096] S301, acquiring a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image.

[0097] Here, the specific implementation of step S301 can refer to the relevant description of the aforementioned step S101, which will not be repeated here.

[0098] S302, performing feature extraction on the target image, the first reference image and the second reference image respectively to obtain image features corresponding to the target image, the first reference image and the second reference image.

[0099] Specifically, the target image, the first reference image, and the second reference image can be respectively subjected to feature extraction by an image feature extraction algorithm to obtain image features corresponding to the target image, the first reference image, and the second reference image. The image feature extraction algorithm includes but is not limited to at least one of Fourier transform method, window Fourier transform method, wavelet transform method, directional gradient histogram method, local binary patterns (LBP) algorithm, and the like.

[0100] Optionally, feature extraction can be performed on the target image, the first reference image, and the second reference image based on a deep learning algorithm to obtain image features corresponding to the target image, the first reference image, and the second reference image. The target image, the first reference image, and the second reference image can be input into a pre-trained three-input twin network for feature extraction to obtain image features corresponding to the target image, the first reference image, and the second reference image. The three-input twin neural network includes three feature extraction modules, and each of the three feature extraction modules has the same structure and weight parameters.

[0101] For example, Figure 5As shown, each feature extraction module may include a ResNet18 network, which includes 18 layers of convolutional neural networks, which are pre-trained by ImageNet, and the ResNet18 network can output 1000-dimensional features. That is, the three-input twin neural network includes three ResNet18 networks, and the weight parameters of each ResNet18 are the same. After the target image, the first reference image, and the second reference image are input into the three-input twin neural network, the 1000-dimensional features corresponding to the target image, the first reference image, and the second reference image can be obtained. In addition to the ResNet18 network, the feature extraction module may also include a fully connected layer, which is connected to the ResNet18 network. The fully connected layer is used to convert the 1000-dimensional features output by the ResNet18 network into n-dimensional image features, where n is a positive integer. After the target image, the first reference image, and the second reference image are input into the three-input twin neural network, the features output by the fully connected layer are the image features corresponding to the target image, the first reference image, and the second reference image.

[0102] Optionally, the feature extraction module may also be other feature extraction structures, for example, the feature extraction module may also include any one of ResNet20 network, ResNet34 network, ResNet50 network, AlexNet, and VGGNet network. This application does not limit the specific structure of the feature extraction module.

[0103] By extracting image features of a target image, a first reference image, and a second reference image using a three-input twin neural network with the same three structures and weight parameters, accurate extraction of image features can be achieved, which is facilitating the judgment of the similarity between images.

[0104] Before using the three-input twin neural network to extract features of the target image, the first reference image, and the second reference image respectively, the three-input twin neural network can also be trained based on training samples.

[0105] Specifically, the three-input twin neural network can be trained through the following steps B1-B3:

[0106] B1. Obtain a target sample image, a positive sample image corresponding to the target sample image, and a negative sample image corresponding to the target sample image.

[0107] Among them, the target sample image, the positive sample image and the negative sample image are images of circuit boards used as training samples, one of the positive sample image and the negative sample image is an image of a standard circuit board without component defects, and the other of the positive sample image and the negative sample image is an image of a defective circuit board with component defects. The component defect situation in the positive sample image is the same as the component defect situation in the target sample image, and the component defect situation in the negative sample image is different from the component defect situation in the target sample image. If the target sample image is an image of a standard circuit board, the positive sample image is an image of a standard circuit board, and the negative sample image is an image of a defective circuit board; if the target sample image is an image of a defective circuit board, the positive sample image is an image of a defective circuit board, and the negative sample image is an image of a standard circuit board.

[0108] There can be one or more target sample images; similarly, there can be one or more positive sample images and negative sample images. In a specific implementation, multiple images of circuit boards with known component defects can be collected in advance to form a sample image set, and each image in the sample image set is pre-labeled with an image label, and the image label is used to indicate whether the circuit board in the image is a standard circuit board or a defective circuit board. An arbitrary image is obtained from the sample image set as the target sample image, and then a sample image with the same image label as the target sample image is obtained from the sample image set as a positive sample image, and a sample image with a different image label from the target sample image is obtained from the sample image set as a negative sample image, and this is used as a group of sample images. By obtaining the target sample image, positive sample image, and negative sample image multiple times in the same way, multiple groups of sample images can be obtained.

[0109] B2. Based on the target sample image, positive sample image and negative sample image, a three-input twin neural network is trained.

[0110] Here, the three-input twin neural network is trained according to the target sample image, the positive sample image and the negative sample image, which means that the weight parameters of the feature extraction module in the three-input twin network are continuously adjusted according to the target sample image, the positive sample image and the negative sample image, so that the three-input twin network has the ability to extract features that can distinguish images with different defect conditions.

[0111] Among them, the three-input twin neural network can be trained through the following steps B21-B23:

[0112] B21. Input the target sample image, positive sample image and negative sample image into the three feature extraction modules of the three-input twin neural network respectively for feature extraction to obtain the image features corresponding to the target sample image, positive sample image and negative sample image.

[0113] B22. Calculate the feature difference between the image features corresponding to the target sample image and the image features corresponding to the positive sample image to obtain a first difference, and calculate the feature difference between the image features corresponding to the target sample image and the image features corresponding to the negative sample image to obtain a second difference.

[0114] In a feasible implementation manner, the difference between two image features may be evaluated based on the Euclidean distance.

[0115] Specifically, the Euclidean distance between the image features corresponding to the target sample image and the image features corresponding to the positive sample image can be calculated to obtain the first difference degree; then the Euclidean distance between the image features corresponding to the target sample image and the image features corresponding to the negative sample image can be calculated to obtain the second difference degree.

[0116] The calculation formulas for the first difference and the second difference can be specifically as follows:

[0117]

[0118] Among them, d1 is the first difference, d2 is the second difference, t 1i is the i-th dimension image feature of the positive sample image, t 2i is the i-th dimension image feature of the target sample image, t 3i is the i-th dimension image feature of the negative sample image, and n is the dimension of the image feature extracted.

[0119] The difference between images can be determined by calculating the Euclidean distance of image features, so that the difference between images can be accurately evaluated.

[0120] Optionally, the feature difference between the image features corresponding to the target sample image and the image features corresponding to the positive sample image, and the feature difference between the image features corresponding to the target sample image and the image features corresponding to the negative sample image may also be calculated by other measurement indicators for evaluating the difference between the two image features. The measurement indicator used to calculate the feature difference between the image features corresponding to the target sample image and the image features corresponding to the positive sample image is the same as the measurement indicator used to calculate the difference between the image features corresponding to the target sample image and the image features corresponding to the negative sample image. For example, the Manhattan distance, Hamming distance, KL divergence, etc. between the two image features may also be calculated to calculate the difference between the two image features. This application is not limited thereto.

[0121] B23. According to the first difference and the second difference, adjust the weight parameters of the three feature extraction modules in the three-input twin neural network so that the first difference decreases and the second difference increases.

[0122] Specifically, the model loss can be calculated according to the preset loss function, the first difference and the second difference, wherein the preset loss function is loss=max(S1-S2+m, 0), loss represents the model loss, S1 represents the first difference, S2 represents the second difference, and m represents the hyperparameter; according to the model loss, the weight parameters of the three feature extraction modules in the three-input twin neural network are adjusted to reduce the model loss. Among them, the weight parameters of the three feature extraction modules can be adjusted based on the stochastic gradient method and combined with the model loss.

[0123] The model loss is calculated according to the preset loss function and the weight parameters of the feature extraction module are adjusted to reduce the model loss, narrow the intra-class difference and increase the inter-class difference, so that the three-input neural network has the ability to extract image features more accurately.

[0124] In the process of training the three-input neural network, the above steps B21 to B23 can be iterated multiple times until the model loss is close to 0, or the number of iterative executions reaches a preset number, so that a three-input twin neural network can be obtained.

[0125] In some possible cases, in the process of training the three-input twin neural network according to the target sample image, the positive sample image and the negative sample image, after obtaining the target sample image, the positive sample image and the negative sample image, the target sample image, the positive sample image and the negative sample image can be image enhanced, and the three-input twin neural network can be trained using the enhanced target sample image, the positive sample image and the negative sample image. The specific implementation method of image enhancement for the target sample image, the positive sample image and the negative sample image can refer to the specific implementation method of image enhancement for the target image, the first reference image and the second reference image in the aforementioned step S202, which will not be repeated here.

[0126] S303, calculating the similarity between the image features corresponding to the target image and the image features corresponding to the first reference image to obtain a first similarity, and calculating the similarity between the image features corresponding to the target image and the image features corresponding to the second reference image to obtain a second similarity.

[0127] Here, the similarity between the two image features can be calculated by using the method of calculating the feature difference between the two image features in the aforementioned step B22. The similarity and the difference are negatively correlated, that is, the greater the difference between the two image features, the smaller the similarity between the two image features, and the smaller the difference between the two image features, the greater the similarity between the two image features.

[0128] After calculating the difference between the image feature corresponding to the target image and the image feature corresponding to the first reference image, and the difference between the image feature corresponding to the target image and the image feature corresponding to the second reference image in the same manner as that in the aforementioned step B22, if the difference between the image feature corresponding to the target image and the image feature corresponding to the first reference image is greater than the difference between the image feature corresponding to the target image and the image feature corresponding to the second reference image, it means that the first similarity is less than the second similarity; if the difference between the image feature corresponding to the target image and the image feature corresponding to the first reference image is less than the difference between the image feature corresponding to the target image and the image feature corresponding to the second reference image, it means that the first similarity is greater than the second similarity.

[0129] Optionally, the first similarity and the second similarity may also be calculated by other metrics for evaluating the similarity of two image features. For example, the cosine similarity, Pearson correlation coefficient, Jaccard distance, etc. of the two image features may be calculated to determine the similarity between the two image features. This application does not impose any limitation.

[0130] S304: Determine a component defect detection result of the circuit board to be tested according to the first similarity and the second similarity.

[0131] Here, the specific implementation of step S304 can refer to the description of the aforementioned step S102, which will not be repeated here.

[0132] In the above Figure 3 In the corresponding technical solution, after obtaining the target image of the circuit board to be tested, the first reference image of the standard circuit board without component defects, and the second reference image of the defective circuit board with component defects, the image features of the target image, the first reference image, and the second reference image are extracted, and the similarity between the images is determined based on the similarity between the image features. This can avoid partial noise interference in the image, more accurately judge the similarity between images, and help improve the accuracy of subsequent component defect detection results.

[0133] The method of the present application is introduced above, and the device of the present application is introduced below.

[0134] See also Figure 6 , Figure 6 Schematic diagram of the structure of a circuit board defect detection device provided in an embodiment of the present application. Figure 6 As shown, the circuit board defect detection device 40 includes:

[0135] An image acquisition module 401 is used to acquire a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, wherein the target image is an image of a circuit board to be tested, the first reference image is an image of a standard circuit board without component defects, and the second reference image is an image of a defective circuit board with component defects;

[0136] A similarity determination module 402, configured to determine a first similarity between the target image and the first reference image, and to determine a second similarity between the target image and the second reference image;

[0137] The result determination module 403 is used to determine the component defect detection result of the circuit board to be tested according to the first similarity and the second similarity.

[0138] In a possible design, the similarity determination module 402 is specifically used to: if the first similarity is greater than the second similarity, determine that there is no component defect in the circuit board to be tested; if the first similarity is less than the second similarity, determine that there is a component defect in the circuit board to be tested.

[0139] In a possible design, the similarity determination module 402 is specifically used to: perform feature extraction on the target image, the first reference image and the second reference image respectively to obtain image features corresponding to the target image, the first reference image and the second reference image; calculate the similarity between the image features corresponding to the target image and the image features corresponding to the first reference image to obtain the first similarity, and calculate the similarity between the image features corresponding to the target image and the image features corresponding to the second reference image to obtain the second similarity.

[0140] In one possible design, the similarity determination module 402 is specifically used to: input the target image, the first reference image and the second reference image into a three-input twin neural network for feature extraction to obtain image features corresponding to the target image, the first reference image and the second reference image, wherein the three-input twin neural network includes three feature extraction modules, and the structure and weight parameters of each of the three feature extraction modules are the same.

[0141] In a possible design, the circuit board defect detection device 40 further includes a model training module 404, which is used to obtain a target sample image, a positive sample image corresponding to the target sample image, and a negative sample image corresponding to the target sample image, wherein the component defect condition of the positive sample image is the same as the component defect condition of the target sample image, and the component defect condition of the negative sample image is different from the component defect condition of the target sample image, and one of the positive sample image and the negative sample image is an image of a standard circuit board without component defects, and the other of the positive sample image and the negative sample image is an image of a defective circuit board with component defects; the three-input twin neural network is trained based on the target sample image, the positive sample image, and the negative sample image.

[0142] In a possible design, the above-mentioned model training module 404 is specifically used to: input the target sample image, the positive sample image and the negative sample image into the three feature extraction modules for feature extraction respectively, and obtain the image features corresponding to the target sample image, the positive sample image and the negative sample image; calculate the feature difference between the image features corresponding to the target sample image and the image features corresponding to the positive sample image to obtain the first difference, calculate the feature difference between the image features corresponding to the target sample image and the image features corresponding to the negative sample image to obtain the second difference; according to the first difference and the second difference, adjust the weight parameters of the three feature extraction modules so that the first difference is reduced and the second difference is increased.

[0143] In a possible design, the above-mentioned model training module 404 is specifically used to: calculate the model loss according to a preset loss function, the first difference and the second difference, the preset loss function is: loss = max(S1-S2+m, 0), loss represents the model loss, S1 is the first difference, S2 is the second difference, and m represents the hyperparameter; according to the model loss, adjust the weight parameters of the three feature extraction modules to reduce the model loss.

[0144] In a possible design, the above-mentioned model training module 404 is specifically used to: calculate the Euclidean distance between the image features corresponding to the target sample image and the image features corresponding to the positive sample image to obtain a first difference; calculate the Euclidean distance between the image features corresponding to the target sample image and the image features corresponding to the negative sample image to obtain a second difference.

[0145] In a possible design, the circuit board defect detection device 40 further includes an image enhancement module 405, which is used to perform image enhancement processing on the target image, the first reference image and the second reference image respectively to obtain the target image, the first reference image and the second reference image after image enhancement; the similarity determination module 402 is specifically used to: determine the first similarity between the target image after image enhancement and the first reference image after image enhancement, and determine the second similarity between the target image after image enhancement and the second reference image after image enhancement.

[0146] In a possible design, the above-mentioned image enhancement module 405 is specifically used to: perform image sharpening on the target image, the first reference image and the second reference image respectively to obtain the sharpened images corresponding to the target image, the first reference image and the second reference image; perform color compression on the sharpened images corresponding to the target image, the first reference image and the second reference image respectively to obtain the color compressed images corresponding to the target image, the first reference image and the second reference image; perform contrast enhancement on the color compressed images corresponding to the target image, the first reference image and the second reference image respectively to obtain the target image, the first reference image and the second reference image after image enhancement.

[0147] In a possible design, the image enhancement module 405 is also used to: perform color space transformation on the target image, the first reference image and the second reference image respectively to obtain the target image, the first reference image and the second reference image in the HSV color space; the image enhancement module 405 is specifically used to: perform image sharpening on the target image, the first reference image and the second reference image in the HSV color space respectively to obtain sharpened images corresponding to the target image, the first reference image and the second reference image.

[0148] In a possible design, the image enhancement module 405 is further used to: perform center cropping and size scaling on the target image, the first reference image and the second reference image, respectively, to obtain local images corresponding to the target image, the first reference image and the second reference image; the image enhancement module 405 is specifically used to: perform image sharpening on the local images corresponding to the target image, the first reference image and the second reference image, respectively, to obtain sharpened images corresponding to the target image, the first reference image and the second reference image.

[0149] In a possible design, the image enhancement module 405 is further configured to perform affine transformation on the target image, the first reference image, and the second reference image along a coordinate axis, respectively.

[0150] It should be noted that Figure 6 For the contents not mentioned in the corresponding embodiments, please refer to the description of the aforementioned method embodiments, which will not be repeated here.

[0151] The above device obtains a target image of the circuit board to be tested, a first reference image of a standard circuit board without component defects, and a second reference image of a defective circuit board with component defects, and then determines a first similarity between the target image and the first reference image, and a second similarity between the target image and the second reference image, and determines the component defect detection result of the circuit board to be tested based on the first similarity and the second similarity. Since the component defect detection result of the circuit board to be tested is determined by comparing the image of the circuit board to be tested with the image with component defects and the image without component defects, there is not only a positive reference but also a reverse reference. When the pad or device is blocked, the component defect of the circuit board can be detected more accurately, thereby improving the accuracy of detection.

[0152] See also Figure 7 , Figure 7 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application, wherein the computer device 50 includes a processor 501 and a memory 502. The memory 502 is connected to the processor 501, for example, via a bus.

[0153] The processor 501 is configured to support the computer device 50 to perform the corresponding functions in the method in the above method embodiment. The processor 501 can be a central processing unit (CPU), a network processor (NP), a hardware chip or any combination thereof. The above hardware chip can be an application specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0154] The memory 502 is used to store program codes, etc. The memory 502 may include a volatile memory (VM), such as a random access memory (RAM); the memory 502 may also include a non-volatile memory (NVM), such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); the memory 502 may also include a combination of the above-mentioned types of memories.

[0155] The processor 501 may call the program code to perform the following operations:

[0156] Acquire a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, wherein the target image is an image of a circuit board to be tested, the first reference image is an image of a standard circuit board without component defects, and the second reference image is an image of a defective circuit board with component defects;

[0157] Determining a first similarity between the target image and the first reference image, and determining a second similarity between the target image and the second reference image;

[0158] A component defect detection result of the circuit board to be tested is determined according to the first similarity and the second similarity.

[0159] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method described in the above embodiment.

[0160] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0161] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A circuit board defect detection method, characterized in that: include: Acquire a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, wherein the target image is an image of a circuit board to be tested, the first reference image is an image of a standard circuit board without component defects, and the second reference image is an image of a defective circuit board with component defects; Determining a first similarity between the target image and the first reference image, and determining a second similarity between the target image and the second reference image; A component defect detection result of the circuit board to be tested is determined according to the first similarity and the second similarity.

2. The method according to claim 1, characterized in that The step of determining a component defect detection result of the target image according to the first similarity and the second similarity includes: If the first similarity is greater than the second similarity, it is determined that there is no component defect in the circuit board to be tested; If the first similarity is smaller than the second similarity, it is determined that a component defect exists in the circuit board to be tested.

3. The method according to claim 1, characterized in that The determining a first similarity between the target image and the first reference image, and determining a second similarity between the target image and the second reference image, comprises: Performing feature extraction on the target image, the first reference image, and the second reference image respectively to obtain image features corresponding to the target image, the first reference image, and the second reference image; The similarity between the image features corresponding to the target image and the image features corresponding to the first reference image is calculated to obtain the first similarity, and the similarity between the image features corresponding to the target image and the image features corresponding to the second reference image is calculated to obtain the second similarity.

4. The method according to claim 3, characterized in that The extracting features of the target image, the first reference image, and the second reference image respectively to obtain image features corresponding to the target image, the first reference image, and the second reference image includes: The target image, the first reference image and the second reference image are input into a three-input twin neural network for feature extraction to obtain image features corresponding to the target image, the first reference image and the second reference image, wherein the three-input twin neural network includes three feature extraction modules, and the structure and weight parameters of each of the three feature extraction modules are the same.

5. The method according to claim 4, characterized in that The method further comprises: Acquire a target sample image, a positive sample image corresponding to the target sample image, and a negative sample image corresponding to the target sample image, wherein the component defect condition of the positive sample image is the same as the component defect condition of the target sample image, and the component defect condition of the negative sample image is different from the component defect condition of the target sample image, and one of the positive sample image and the negative sample image is an image of a standard circuit board without component defects, and the other of the positive sample image and the negative sample image is an image of a defective circuit board with component defects; The three-input twin neural network is trained based on the target sample image, the positive sample image and the negative sample image.

6. The method according to any one of claims 1 to 5, characterized in that: Before determining the first similarity between the target image and the first reference image, and determining the second similarity between the target image and the second reference image, the method further includes: Performing image enhancement processing on the target image, the first reference image and the second reference image respectively to obtain the target image, the first reference image and the second reference image after image enhancement; The determining a first similarity between the target image and the first reference image, and determining a second similarity between the target image and the second reference image, comprises: A first similarity between the image-enhanced target image and the image-enhanced first reference image is determined, and a second similarity between the image-enhanced target image and the image-enhanced second reference image is determined.

7. The method according to claim 6, characterized in that The performing image enhancement processing on the target image, the first reference image and the second reference image respectively to obtain the target image, the first reference image and the second reference image after image enhancement, comprises: Performing image sharpening on the target image, the first reference image, and the second reference image respectively to obtain sharpened images corresponding to the target image, the first reference image, and the second reference image; Performing color compression on the target image, the first reference image, and the sharpened images corresponding to the second reference image, respectively, to obtain color compressed images corresponding to the target image, the first reference image, and the second reference image; Contrast enhancement is performed on the target image, the first reference image, and the color compressed images corresponding to the second reference image to obtain the target image, the first reference image, and the second reference image after image enhancement.

8. A circuit board defect detection device, characterized in that: include: An image acquisition module, used to acquire a target image, a first reference image corresponding to the target image, and a second reference image corresponding to the target image, wherein the target image is an image of a circuit board to be tested, the first reference image is an image of a standard circuit board without component defects, and the second reference image is an image of a defective circuit board with component defects; a similarity determination module, configured to determine a first similarity between the target image and the first reference image, and to determine a second similarity between the target image and the second reference image; The result determination module is used to determine the component defect detection result of the circuit board to be tested according to the first similarity and the second similarity.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory is connected to the processor, and the processor is used to execute one or more computer programs stored in the memory. When the processor executes the one or more computer programs, the computer device implements the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 7.