Circuit board detection method and device, model training method and device, and electronic device

By acquiring images from circuit boards and using recognition models to detect mounting errors, the problem of high difficulty in detecting component mounting errors on circuit boards is solved, realizing an efficient and low-cost detection method.

CN115239683BActive Publication Date: 2026-03-24MECH MIND ROBOTICS TECH LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-04
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

In existing technologies, it is difficult to detect component placement errors on circuit boards, and AOI systems are costly and difficult to operate.

Method used

By acquiring circuit board images, sub-images are extracted according to preset configuration files, and detection processing is performed using a pre-trained recognition model. The detection results are then output and compared with the configuration files to determine whether components are incorrectly mounted.

Benefits of technology

It enables simple and accurate identification of component placement errors on circuit boards, reducing the number of inspection personnel, lowering costs, and improving inspection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115239683B_ABST
    Figure CN115239683B_ABST
Patent Text Reader

Abstract

The present disclosure provides a circuit board detection method, a model training method, an apparatus and an electronic device. The circuit board detection method comprises: obtaining a circuit board image, the circuit board image comprising a plurality of component objects; according to a preset configuration file, intercepting a plurality of sub-images of preset positions in the circuit board image, the configuration file comprising: a plurality of preset positions; based on each sub-image, inputting the sub-image into a pre-trained recognition model for detection processing, outputting a detection result, comparing the detection result with the configuration file, and determining whether the components at the preset positions are incorrectly mounted, the configuration file further comprising: whether a component is arranged at the preset position and / or a target mask image of a component that should be arranged at the preset position, so that the problem of whether a component is missing at the preset position on the substrate can be accurately determined by a simple and convenient method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method for testing circuit boards, a model training method, an apparatus, and an electronic device. Background Technology

[0002] During circuit board manufacturing, machines or manual labor are used to mount multiple components, such as terminals, capacitors, and diodes, onto a substrate according to a pre-designed circuit board layout. However, component mounting errors can occur during the mounting process, necessitating the detection of mounting errors on the circuit board.

[0003] Based on the above problems, related technologies use automated optical inspection (AOI) systems to inspect components on circuit boards. This technology specifically uses high-precision vision processing technology to automatically detect component placement errors. However, this technology has high requirements for the accuracy and quality of the automated optical inspection system, which increases the difficulty of inspecting circuit boards. Summary of the Invention

[0004] This disclosure provides a method for inspecting circuit boards, a model training method, an apparatus, and an electronic device to address the current challenges in inspecting circuit boards.

[0005] The first aspect of this disclosure provides a method for detecting a circuit board. The circuit board includes a substrate and multiple components disposed on the substrate. The method includes: acquiring a circuit board image, the circuit board image including multiple component objects; according to a preset configuration file, cropping multiple sub-images at preset positions in the circuit board image, the configuration file including multiple preset positions; based on each sub-image, inputting the sub-image into a pre-trained recognition model for detection processing, outputting detection results, comparing the detection results with the configuration file, and determining whether the components at the preset positions are incorrectly mounted. The configuration file also includes: whether components are set at the preset positions and / or target mask images of components that should be set at the preset positions.

[0006] A second aspect of this disclosure provides a model training method, comprising: acquiring training samples and sample labels, wherein the training samples include: multiple images including components and multiple images not including components, wherein the sample labels of the images including components are component type and mask image, and the sample labels of the images not including components indicate missing components; training a recognition model based on the training samples and sample labels to obtain a trained recognition model, wherein the trained recognition model is used to identify at least one of the following: image component type, mask image, and whether a missing component exists.

[0007] A third aspect of this disclosure provides a circuit board testing apparatus for performing the circuit board testing method of the first aspect. The circuit board includes: a substrate and a plurality of components disposed on the substrate. The circuit board testing apparatus includes:

[0008] The acquisition module is used to acquire circuit board images, which include multiple component objects;

[0009] The capture module is used to capture multiple sub-images at preset positions in a circuit board image according to a preset configuration file. The configuration file includes multiple preset positions.

[0010] The processing module is used to input the sub-images into a pre-trained recognition model for detection processing based on each sub-image, and output the detection results.

[0011] The comparison module is used to compare the test results with the configuration file to determine whether the components at the preset positions are incorrectly mounted.

[0012] A fourth aspect of this disclosure provides a model training apparatus for executing the model training method of the second aspect, the model training apparatus comprising:

[0013] The acquisition module is used to acquire training samples and sample labels. The training samples include: multiple images including components and multiple images not including components. The sample labels of the images including components are component type and mask image, and the sample labels of the images not including components indicate missing components.

[0014] The training module is used to train the recognition model based on training samples and sample labels to obtain the trained recognition model. The trained recognition model is used to identify at least one of the following: image component type, mask image, and whether there is a missing component.

[0015] A fifth aspect of this disclosure provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements either the circuit board detection method of the first aspect or the model training method of the second aspect.

[0016] A sixth aspect of this disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the circuit board detection method of the first aspect or the model training method of the second aspect.

[0017] A seventh aspect of this disclosure provides a computer program product comprising: a computer program stored in a readable storage medium, at least one processor of an electronic device being able to read the computer program from the readable storage medium, and the at least one processor executing the computer program causing the electronic device to perform a circuit board detection method of the first aspect or a model training method of the second aspect.

[0018] This disclosure applies to the scenario of component mounting inspection on a substrate. It acquires a circuit board image, which includes multiple component objects. Based on a preset configuration file, multiple sub-images at preset locations are extracted from the circuit board image. The configuration file includes multiple preset locations. For each sub-image, a pre-trained recognition model is input for detection processing, and the detection result is output. The detection result is compared with the configuration file to determine whether the component at the preset location is incorrectly mounted. This method provides a simple and convenient way to accurately determine whether there is a mounting error at a preset location on the substrate. Furthermore, this disclosure obtains detection results through image recognition using a recognition model, enabling users to easily and quickly identify component mounting errors on the circuit board, reducing the number of inspection personnel, lowering costs, and improving inspection efficiency. Attached Figure Description

[0019] The accompanying drawings, which are included to provide a further understanding of this disclosure and form part of this disclosure, illustrate exemplary embodiments of the present disclosure and are used to explain the disclosure, but do not constitute an undue limitation of the disclosure. In the drawings:

[0020] Figure 1 An application scenario diagram of a circuit board testing method provided as an exemplary embodiment of this disclosure;

[0021] Figure 2 A flowchart illustrating the steps of a circuit board testing method provided for an exemplary embodiment of this disclosure;

[0022] Figure 3 A schematic diagram of a circuit board image provided for an exemplary embodiment of this disclosure;

[0023] Figure 4 A schematic diagram of a sub-image provided for an exemplary embodiment of this disclosure;

[0024] Figure 5 A flowchart illustrating the steps of another circuit board testing method provided as an exemplary embodiment of this disclosure;

[0025] Figure 6 A schematic diagram of a sub-image provided for an exemplary embodiment of this disclosure;

[0026] Figure 7A schematic diagram of a circuit board testing method provided as an exemplary embodiment of this disclosure;

[0027] Figure 8 A schematic diagram of a target image provided for an exemplary embodiment of this disclosure;

[0028] Figure 9 A flowchart illustrating the steps of a model training method provided as an exemplary embodiment of this disclosure;

[0029] Figure 10 A structural block diagram of a circuit board testing apparatus provided for an exemplary embodiment of this disclosure;

[0030] Figure 11 Structural block diagram of a model training apparatus provided for an exemplary embodiment of this disclosure;

[0031] Figure 12 A schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this disclosure. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of this disclosure clearer, the technical solutions of this disclosure will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.

[0033] With the rapid development of integrated circuits and the continuous emergence of new specialized electronic components, PCB (Printed Circuit Board) products are also trending towards higher density and smaller components. In related technologies, AOI (Automated Optical Inspection) systems are used for the inspection of components on PCBs. AOI systems have powerful functions, not only for detecting component placement errors but also for inspecting packaging lines, glass templates, film templates, ceramic packages, and wafer packages. To meet these functional requirements, AOI systems are automated devices integrating precision instruments, automatic control, optical image processing, and software systems. This leads to the problem that AOI systems, when limited to detecting component placement errors, suffer from high costs and operational difficulties.

[0034] Based on the above problems, the circuit board detection method provided in this disclosure is applied to the scenario of component mounting detection on a substrate. It acquires a circuit board image, which includes multiple component objects; according to a preset configuration file, it extracts multiple sub-images at preset positions in the circuit board image, the configuration file including multiple preset positions; based on each sub-image, it inputs the sub-image into a pre-trained recognition model for detection processing, outputs the detection result, compares the detection result with the configuration file, and determines whether the component at the preset position is incorrectly mounted. This method can accurately determine whether there is a mounting error at a preset position on the substrate using a simple and convenient approach.

[0035] In this embodiment, the circuit board inspection method can be a method for inspecting the entire circuit board using a cloud computing system. Furthermore, the server executing the circuit board inspection method can be a cloud server, so as to leverage the advantages of cloud resources to run various algorithms; relative to the cloud, the circuit board inspection method can also be applied to conventional servers or server arrays and other server-side devices, and is not limited thereto.

[0036] Furthermore, one application scenario of this disclosure embodiment is as follows: Figure 1 , Figure 1 The circuit board includes a substrate 11 and multiple components (A1 to A8) disposed on the substrate 11. The components on the substrate 11 are of various types, such as resistors, capacitors, diodes, and terminals. Each type of component has its own attribute characteristics, such as color, shape, size, and text information on the component. Furthermore, the components on the substrate 11 are mounted manually or by machine. Each component on the substrate 11 has standard mounting requirements. Incorrect mounting will affect the quality of the circuit board. Therefore, this disclosure describes the detection of the mounting accuracy of the components on the substrate 11 to ensure the quality of the circuit board.

[0037] in, Figure 1 This is merely one exemplary application scenario, and the embodiments disclosed herein can be applied to any circuit board inspection scenario. The embodiments disclosed herein do not limit the specific application scenario.

[0038] Figure 2 This is a flowchart illustrating the steps of a circuit board testing method provided for an exemplary embodiment of the present disclosure. The circuit board includes a substrate and multiple components disposed on the substrate; specifically, it includes the following steps:

[0039] S201, Obtain circuit board image.

[0040] The circuit board image includes multiple component objects. For example, a circuit board image like this... Figure 3 As shown, 31 is the object corresponding to the substrate, and a1 to a8 are respectively Figure 1The component objects corresponding to components A1 to A8 in the middle.

[0041] Furthermore, the circuit board image can be obtained by taking a picture of the side of the circuit board where the components are located. In the circuit board image, each component object has positional information.

[0042] S202, according to the preset configuration file, extracts multiple sub-images at preset positions from the circuit board image.

[0043] The configuration file includes multiple preset locations. Specifically, the configuration file is a pre-configured file that specifies the preset locations to be detected, namely whether there are any missing parts in the preset locations to be detected.

[0044] Furthermore, the multiple preset positions can be partial or complete locations within the circuit board image, and each preset position can be a region within the circuit board image. The preset positions are represented in pixel positions. For example, if the length * width of the circuit board image is 9000 pixels * 9000 pixels, then a preset position can be represented by the pixel coordinates of multiple corner points, as shown below. Figure 3 The preset position (B7) can be represented as (0,0), (0,3500), (3500,0) and (3500,3500), and the preset position (B8) can be represented as (0,3500), (3500,0), (3500,6000) and (6000,0).

[0045] In this disclosure, reference is made to Figure 3 The circuit board image has 9 regions (B1 to B9). If the preset positions in the configuration file are the positions corresponding to B4, B7 and B8, then the sub-images corresponding to the preset positions are cropped from the circuit board image based on the preset positions, and one sub-image is cropped for each preset position.

[0046] For example, refer to Figure 4 By cropping B4, B7, and B8 respectively, three sub-images are obtained: sub-image 41, sub-image 42, and sub-image 43. Sub-image 41 includes component object a4, sub-image 42 does not contain component object, and sub-image 43 includes component object a7.

[0047] In practical applications, the number of components on a circuit board is enormous, and the number of pre-defined locations is also very large. Figure 1 , Figure 3 and Figure 4 The above is merely an illustrative example.

[0048] S203: Based on each sub-image, input the sub-image into the pre-trained recognition model for detection processing, and output the detection result.

[0049] In this disclosure, the recognition model may employ one or more of the following techniques, including but not limited to Mask R-CNN (Instance Segmentation Network), U-Net (Semantic Segmentation Network), and FCN (Fully Convolutional Neural Network). The recognition model is pre-trained and can perform recognition processing on sub-images input to the recognition model to obtain detection results.

[0050] Furthermore, each sub-image is sequentially input into the recognition model for processing, yielding the detection result for each sub-image. For example, refer to... Figure 4 First, input sub-image 41 into the recognition model to obtain the detection result of sub-image 41. Then, input sub-image 42 into the recognition model to obtain the detection result of sub-image 42. Next, input sub-image 43 into the recognition model to obtain the detection result of sub-image 43.

[0051] S204. Compare the test results with the configuration file to determine whether the components in the preset positions are incorrectly mounted.

[0052] The configuration file also includes: whether to set components at preset locations and / or the target mask image of the components that should be set at preset locations.

[0053] Specifically, if the detection result differs from the configuration file, it is determined whether the component at the preset position is incorrectly placed. Placement errors include any one of the following: missing component, wrong component, reversed component, and misaligned component. Specifically, a missing component means that the configuration file indicates a component should be placed at the preset position, but the detection result indicates that no component is actually placed at the preset position; in this case, a missing component is confirmed. A wrong component means that the configuration file indicates component A should be placed at the preset position, but the detection result indicates that component B is actually placed at the preset position; in this case, a wrong component is confirmed. A reversed component means that the configuration file indicates component A should be placed in the correct orientation at the preset position, but component A is actually placed in the reverse orientation; in this case, a reversed component is confirmed. Misaligned component placement refers to a component being inserted at an inverted position.

[0054] This embodiment of the invention is applied to a scenario of component mounting inspection on a substrate. By acquiring a circuit board image, which includes multiple component objects, and according to a preset configuration file, multiple sub-images at preset positions are extracted from the circuit board image. The configuration file includes multiple preset positions. Based on each sub-image, the sub-image is input into a pre-trained recognition model for detection processing, and the detection result is output. By comparing the detection result with the configuration file, it is determined whether the component at the preset position is incorrectly mounted. This method can accurately determine whether there is a mounting error at a preset position on the substrate using a simple and convenient method.

[0055] Figure 5 A flowchart illustrating another method for detecting a circuit board provided as an exemplary embodiment of this disclosure specifically includes the following steps:

[0056] S501 controls the camera to capture images of the side of the circuit board where the components are located, and obtains an initial image.

[0057] The camera is a two-dimensional camera with a certain number of pixels. For example, the camera could have 5 megapixels. Furthermore, the camera captures images of the circuit board at a certain shooting angle. The initial image obtained can be an image including the circuit board background, an image with a pixel value lower than a preset pixel value, or an image with a certain tilt angle.

[0058] For example, refer to Figure 6 The initial image 60 has a certain tilt angle, and the initial image 60 includes a background 61 and an image 62 corresponding to the circuit board.

[0059] S502 corrects the initial image to obtain the circuit board image.

[0060] The process of correcting the initial image includes at least one of cropping, angle adjustment, and pixel adjustment, resulting in a circuit board image as shown below. Figure 3 .

[0061] Furthermore, pixel adjustment refers to adjusting the pixels of the circuit board image to a preset pixel value. In this disclosure, the configuration file also includes preset pixels.

[0062] For example, if the preset pixel is 9000*9000, and the pixel of the initial image after cropping and angle adjustment is 8000*8000, then the pixel of the circuit board image obtained after correcting the initial image is 9000*9000.

[0063] In this disclosure, since the preset positions in the configuration file are saved in the form of pixel coordinates, adjusting the circuit board image to the preset pixels can ensure the accuracy of sub-image cropping using the preset pixels.

[0064] S503, according to a preset configuration file, extracts multiple sub-images at preset positions from the circuit board image.

[0065] The configuration file includes: multiple preset locations, the target device type of the component to be set at the preset location, the target color value of the component to be set at the preset location, and the target mask image of the component to be set at the preset location.

[0066] For example, refer to Figure 3The preset positions are B4, B7, and B8. Specifically, the target device type for the component to be set at preset position B4 is a terminal, at preset position B7 it is a diode, and at preset position B8 it is a capacitor. The target color value for the component to be set at preset position B4 is blue, while there are no corresponding target color values ​​for preset positions B7 and B8. The target mask image for the component to be set at preset position B4 is 2000 pixels * 1000 pixels, for preset position B7 it is 1800 pixels * 800 pixels, and for preset position B8 it is 400 pixels * 400 pixels.

[0067] Furthermore, the shape of the target mask image can be set to a rectangle.

[0068] Furthermore, the specific implementation process of this step is described in S202 and will not be repeated here.

[0069] S504: Based on each sub-image, input the sub-image into the pre-trained recognition model for detection processing, and output the detection result.

[0070] Furthermore, the specific implementation process of this step is described in S203 and will not be repeated here.

[0071] S505, if the detection result is different from the component set at the preset position, then the component placement error at the preset position is determined to be a missing component error.

[0072] The configuration file also includes setting components at preset locations, and the detection results are used to indicate whether components are set at the preset locations corresponding to the sub-images. Specifically, if the configuration file includes setting components at preset locations, but the detection results indicate that components are not set at those preset locations, then it is determined that there is a missing component error at the preset locations.

[0073] Furthermore, "missing component" refers to the situation where, during the manual or machine placement of components at a preset location, that preset location is missed, and no component is placed at that location. Regarding the detection result, if the result is 0, it indicates that a missing component exists at the corresponding preset location; if the result is not 0, it indicates that no missing component exists at the corresponding preset location.

[0074] For example, refer to Figure 4 If the detection result of sub-image 41 is 1, it means that there is no missing component at the preset position B4 corresponding to sub-image 41. If the detection result of sub-image 42 is 0, and the configuration file indicates that there is a component at the preset position B7 corresponding to sub-image 42, it means that there is a missing component at the preset position B7 corresponding to sub-image 42. If the detection result of sub-image 43 is 2, it means that there is no missing component at the preset position B8 corresponding to sub-image 43.

[0075] Furthermore, if the test result is the same as the component set at the preset position, it is determined that there is no mounting error of the component at the preset position.

[0076] Furthermore, the identification model can be configured in the server. The server can use the identification model to determine whether there are any missing parts at preset locations. If so, the system can send a notification message indicating the presence of missing parts and their preset locations to the target terminal. This will remind relevant personnel to reinstall the missing parts at the preset locations, thereby ensuring the quality of the circuit board.

[0077] S506, compare whether the detection device type and the target device type are the same.

[0078] The detection result is used to indicate whether there is a missing component at a preset location corresponding to the sub-image. If there is no missing component at the preset location, the detection result is also used to indicate the detection device type of the component object in the sub-image.

[0079] Furthermore, in this disclosure, a pre-defined location on the substrate is first checked for missing components. If a missing component is found, the pre-defined location and the result of the missing component are sent to the terminal to prompt the operator to install the component at the pre-defined location. If no missing component is found, the component type at the pre-defined location is checked. The detected component type can be represented by the detection result output by the recognition model. For example, if the detection result of sub-image 41 is 1, it indicates that the detected component type at the pre-defined location B4 corresponding to sub-image 41 is a terminal. If the detection result of sub-image 43 is 2, it indicates that the detected component type at the pre-defined location B8 corresponding to sub-image 43 is a resistor.

[0080] In one embodiment, the detection result further includes a detection mask image of the component object in the sub-image. The detection mask image is the smallest rectangle that can cover the corresponding component object. In this disclosure, after inputting the sub-image into the recognition model, the detection result corresponding to the sub-image can be output. The detection result includes a value indicating the detection device type corresponding to the component object in the sub-image and a detection mask image.

[0081] For example, refer to Figure 7After inputting sub-image 41 into the recognition model, the output detection result 71 includes the value 1 and the detection mask image C1. The value 1 indicates that the detection device type of component object a4 (component A4) is a terminal, and the detection mask image C1 is the smallest mask image that can cover component object a4. After inputting sub-image 42 into the recognition model, the output detection result 72 includes the value 0 and has no detection mask image. The value 0 indicates that there is no component object in sub-image 42, which is a missing component problem. After inputting sub-image 43 into the recognition model, the output detection result 73 includes the value 2 and the detection mask image C3. The value 2 indicates that the detection device type of component object a7 (component A7) is a resistor, and the detection mask image C3 is the smallest mask image that can cover component object a7.

[0082] S507, if different, then the mounting error of the preset position of the substrate is determined to be a wrong part.

[0083] If no missing parts are found, then it is determined whether an incorrect part exists. Specifically, this involves determining whether the type of the detected device is the same as the type of the target device. For example, refer to... Figure 7 If the detection device type of sub-image 41 is a terminal, and the target device type of sub-image 41 in the configuration file is also a terminal, then the detection device type of sub-image 41 is determined to be the same as the target device type. If the detection device type of sub-image 43 is a resistor, and the target device type of sub-image 43 in the configuration file is also a capacitor, then the detection device type of sub-image 43 is determined to be different from the target device type.

[0084] Furthermore, subsequent detection is performed on sub-images where the detected device type is the same as the target device type. For sub-images where the detected device type is different from the target device type, it is determined that there is a component error at a preset position corresponding to the sub-image, i.e., the actual component installed is different from the component that should be installed. Then, the information of the component error and the preset position of the component error (the preset position corresponding to sub-image 43) can be sent to the terminal to remind the user to install the correct component at the preset position.

[0085] Furthermore, if the detection device type and the target device type are the same, then determine whether the detection device type is a terminal; if it is a terminal, execute S508.

[0086] S508 determines the detection color value of the sub-image when the target device type is a terminal.

[0087] Terminals are components that connect the battery to external conductors. Different colored terminals have different uses; for example, green terminals are used to connect to rotating motors, and yellow terminals are used to connect to transformers. Therefore, when both the detection device type and the target device type are terminals, the correctness of the terminal placement is determined by comparing color values. This applies when the detection device type and the target device type are the same.

[0088] Furthermore, the detection color value of the sub-image is determined by obtaining the RGB value of each pixel in the sub-image and then determining the average RGB value of the pixels in the sub-image as the detection color value.

[0089] S509, if the difference between the detected color value and the target color value is greater than the color threshold, then the mounting error at the preset position of the substrate is determined to be a faulty component.

[0090] If the difference between the detected color value and the target color value is greater than the color threshold, it is determined that the difference between the detected color value and the target color value is large, and it is determined that there is a misfit at the preset position of the substrate. If the difference between the detected color value and the target color value is not greater than the color threshold, it is determined that the difference between the detected color value and the target color value is small, and it is determined that there is no misfit at the preset position of the substrate. Then, S511 and / or S512 are executed to detect other problems.

[0091] In this disclosure, if the target device type is not a terminal, after determining that the detection device type is the same as the target device type, it is determined that there is no faulty component at the preset position of the substrate, and S510 and / or S512 are executed to detect other problems.

[0092] S510, determine the size difference between the detection mask image and the target mask image.

[0093] The configuration file also includes: the target mask image of the component to be set at the preset position, and the detection result also includes: the detection mask image of the component object in the sub-image.

[0094] In this disclosure, the size difference can indicate whether the component corresponding to the sub-image has a floating height, i.e. whether it is inserted crookedly.

[0095] S511, if the size difference is greater than the size difference threshold, then the mounting error at the preset position of the substrate is determined to be that the component has floating height.

[0096] If a component is found to be misaligned, it is determined that the component is inserted incorrectly. For example, refer to... Figure 7 If the size difference between the detection mask image C1 and the target mask image of sub-image 41 is greater than the difference threshold, then it is determined that the corresponding component A4 is misaligned.

[0097] Furthermore, the presence of a floating component and its preset location can be sent to the terminal to alert the device that the component at that preset location is misaligned. If the size difference is less than or equal to a size difference threshold, it is determined that the component at the preset location on the substrate does not have a floating component, and the device can then be checked to determine if it is a reversed component.

[0098] S512, input the sub-image into the pre-trained classification model for classification processing, and obtain the classification result.

[0099] The classification result indicates whether the component corresponding to the sub-image is an inverted component. In this disclosure, the classification model is also pre-trained. If the classification result is 0, it indicates that the component corresponding to the sub-image has an inverted component; if the classification result is 1, it indicates that the component corresponding to the sub-image does not have an inverted component.

[0100] In one optional embodiment, the configuration file further includes: a target image of the component, the target image containing correctly mounted component objects. The sub-image and the target image are then compared to determine if any component objects in the sub-image are reversed. Specifically, half of the component object can be cropped and compared with half of the target image; if they differ, a reversed component problem is identified.

[0101] For example, refer to Figure 8 In the target image 81, the direction in which component A4 should be mounted is shown. However, the mounting direction of component A4 in sub-image 41 is opposite to that of component A4 in the target image 81. Therefore, there is a reverse mounting problem in the actual mounting method of component A4.

[0102] This disclosure allows for accurate detection of various issues related to components, including missing components, incorrect components, floating components, and reversed components, thereby improving the quality of circuit boards. Furthermore, this disclosure can detect one or more of these issues, and the detection order in steps S501 to S512 can be adjusted according to actual circumstances. Optionally, this disclosure first detects missing components; if a missing component is found, the detection of the corresponding sub-image ends. If no missing components are found, incorrect components are detected; if an incorrect component is found, the detection of the corresponding sub-image ends. If no incorrect components are found, floating and / or reversed components are detected. This progressive detection improves detection efficiency. Further, this disclosure uses a recognition model to identify images and obtain detection results, enabling users to easily and quickly identify errors in components on circuit boards, reducing the number of inspection personnel, lowering costs, and improving detection efficiency.

[0103] Reference Figure 9 This disclosure also provides a model training method, which specifically includes the following steps:

[0104] S901, obtain training samples and sample labels.

[0105] The training samples include: multiple images including components and multiple images excluding components. The sample labels for the images including components are component type and mask image, while the sample labels for the images excluding components indicate missing components.

[0106] In this disclosure, an image of a sample circuit board can be acquired. This image is then segmented to obtain multiple sub-images. Each sub-image is manually labeled to determine its representation of a missing component or component type, as well as its mask image. For example, if a sub-image does not contain any component objects, its component type is labeled as 0, indicating a missing component, and the mask image is empty. If a sub-image contains terminals, its component type is labeled as 1, indicating a terminal, and the mask image is the smallest rectangular mask image covering the terminals in the sub-image.

[0107] Furthermore, when multiple sample sub-images and corresponding label data are obtained, data augmentation can be performed on the sample sub-images to expand the number of training samples. Data augmentation methods include expanding the size of the sample sub-images and randomly shifting the sample sub-images.

[0108] S902, the recognition model is trained based on the training samples and sample labels to obtain the trained recognition model.

[0109] The trained recognition model is used to identify at least one of the following: image component type, mask image, and whether there are missing components.

[0110] Specifically, training samples are input into the recognition model, which outputs predicted device types and predicted mask images. A first loss value is calculated for the predicted device type and the component type of the sample label. If the first loss value is greater than a first loss threshold, the model parameters of the recognition model are adjusted using the first loss value. A second loss value is calculated for the predicted mask image and the mask image of the sample label. If the second loss value is greater than a second loss threshold, the model parameters of the recognition model are adjusted using the second loss value. This process continues until the first loss value is less than the first loss threshold and the second loss value is less than the second loss threshold, at which point the training of the recognition model is complete. The trained recognition model can then be used for the recognition processing of the aforementioned sub-images.

[0111] In one optional embodiment, the method further includes: training the classification model, specifically by acquiring image samples that are not reversed and image samples that are reversed as training samples, and using whether or not the image is reversed as label data to train the classification model.

[0112] In this disclosure, the trained recognition model can accurately identify at least one of the following in a sub-image: component type, mask image, and presence of missing components; and the obtained classification model can accurately determine whether a sub-image is a reversed component.

[0113] In this embodiment of the disclosure, reference is made to Figure 10In addition to providing a method for testing circuit boards, a testing device 100 for circuit boards is also provided. The circuit board includes a substrate and multiple components disposed on the substrate. The testing device 100 for circuit boards includes:

[0114] The acquisition module 101 is used to acquire a circuit board image, which includes multiple component objects;

[0115] The capture module 102 is used to capture multiple sub-images at preset positions in a circuit board image according to a preset configuration file. The configuration file includes multiple preset positions.

[0116] The processing module 103 is used to input the sub-images into a pre-trained recognition model for detection processing based on each sub-image, and output the detection results;

[0117] The comparison module 104 is used to compare the detection results and the configuration file to determine whether the components at the preset positions are incorrectly mounted. The configuration file also includes: whether the components are set at the preset positions and / or the target mask images of the components that should be set at the preset positions.

[0118] In one optional embodiment, the acquisition module 101 is specifically used to: control the camera to acquire an image of the side of the circuit board where the components are located, and obtain an initial image; and correct the initial image to obtain a circuit board image.

[0119] In one optional embodiment, the configuration file further includes: setting components at preset positions, the detection result being used to indicate whether components are set at the preset positions corresponding to the sub-image, and the comparison module 104 being specifically used to: if the detection result is different from the component setting at the preset position, then determine that the component placement error at the preset position is a missing component error.

[0120] In one optional embodiment, the configuration file further includes: a target mask image of the component to be set at a preset position, and the detection result further includes: a detection mask image of the component object in the sub-image. The comparison module 104 is specifically used to: determine the size difference between the detection mask image and the target mask image; if the size difference is greater than the size difference threshold, then determine that the mounting error at the preset position of the substrate is that the component has a floating height.

[0121] In one optional embodiment, the circuit board detection device 100 further includes a classification processing module (not shown) for inputting the sub-image into a pre-trained classification model for classification processing to obtain a classification result. The classification result is used to indicate whether the component corresponding to the sub-image is a reverse component.

[0122] In one optional embodiment, the configuration file further includes: the target device type of the component to be set at the preset position; if there is no missing component at the preset position, the detection result is also used to indicate the detection device type of the component object in the sub-image; the comparison module 84 is specifically used to compare whether the detection device type and the target device type are the same; if they are different, the mounting error at the preset position of the substrate is determined to be an incorrect component.

[0123] In one optional embodiment, the configuration file further includes: the target color value of the component to be set at the preset position. The comparison module 84 is specifically used to: determine the detection color value of the sub-image if the detected device type and the target device type are the same, and the target device type is a terminal; if the difference between the detected color value and the target color value is greater than the color threshold, then determine that the mounting error at the preset position of the substrate is a wrong component.

[0124] The circuit board inspection device provided in this disclosure acquires a circuit board image, which includes multiple component objects; according to a preset configuration file, it extracts multiple sub-images at preset positions in the circuit board image, the configuration file including multiple preset positions; based on each sub-image, it inputs the sub-image into a pre-trained recognition model for detection processing and outputs the detection result; it compares the detection result with the configuration file to determine whether the component at the preset position is incorrectly mounted. This device can accurately determine whether there is a mounting error at a preset position on the substrate using a simple and convenient method. Furthermore, this disclosure obtains the detection result by recognizing the image through the recognition model, enabling users to conveniently and quickly identify mounting errors of components in the circuit board, reducing the number of inspection personnel, lowering costs, and improving inspection efficiency.

[0125] In this embodiment of the disclosure, reference is made to Figure 11 A model training apparatus 110 is also provided for performing the above-described model training method, comprising:

[0126] The acquisition module 111 is used to acquire training samples and sample labels. The training samples include: multiple images including components and multiple images not including components. The sample labels of the images including components are component type and mask image, and the sample labels of the images not including components indicate missing components.

[0127] Training module 112 is used to train a recognition model based on training samples and sample labels to obtain a trained recognition model. The trained recognition model is used to identify at least one of the following: image component type, mask image, and whether there is a missing component.

[0128] The model training device provided in this disclosure can train a recognition model that can accurately identify at least one of the following in a sub-image: component type, mask image, and presence of missing components. The resulting classification model can accurately determine whether a sub-image is a reversed component.

[0129] Furthermore, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The sequence numbers are merely used to distinguish different operations, and the sequence numbers themselves do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0130] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an example embodiment of this disclosure. For example... Figure 12 As shown, the electronic device 120 includes a processor 121 and a memory 122 communicatively connected to the processor 121, the memory 122 storing computer-executed instructions.

[0131] The processor executes computer execution instructions stored in the memory to implement the circuit board detection method or model training method provided in any of the above method embodiments. The specific functions and technical effects to be achieved will not be elaborated here.

[0132] This disclosure also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the circuit board detection method or model training method provided in any of the above method embodiments.

[0133] This disclosure also provides a computer program product, which includes a computer program stored in a readable storage medium. At least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the electronic device to perform the circuit board detection method or model training method provided in any of the above method embodiments.

[0134] In the embodiments provided in this disclosure, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or units may be electrical, mechanical, or other forms.

[0135] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0136] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.

[0137] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this disclosure. 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.

[0138] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional modules is merely an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0139] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0140] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A method for testing a circuit board, characterized in that, The circuit board includes: a substrate and multiple components disposed on the substrate; the detection method for the circuit board includes: Obtain a circuit board image, which includes multiple component objects; According to a preset configuration file, multiple sub-images at preset positions are extracted from the circuit board image. The configuration file includes: multiple preset positions, whether components are set at the preset positions, the target component type of the components to be set at the preset positions, the target mask image of the components to be set at the preset positions, and the target color value of the components to be set at the preset positions. Based on each sub-image, the sub-image is input into a pre-trained recognition model for detection processing, and the detection result is output. The detection result includes at least one of the following: whether a component is set at a preset position corresponding to the sub-image, the detection device type of the component object in the sub-image, and the detection mask image of the component object in the sub-image. By comparing the detection results and the configuration file, it is determined whether the component at the preset position is incorrectly mounted. If the configuration file indicates that a component should be placed at the preset position and provides a target mask image, and the detection results indicate that a component object has been detected and output a detection mask image, then by comparing whether the size difference between the detection mask image and the target mask image is greater than a size difference threshold, it is determined whether there is a floating height at the preset position.

2. The circuit board testing method according to claim 1, characterized in that, The acquisition of the circuit board image includes: The camera is controlled to capture an image of the side of the circuit board where the components are located, thus obtaining an initial image; The initial image is corrected to obtain the circuit board image.

3. The circuit board testing method according to claim 1, characterized in that, The configuration file further includes: setting components at the preset positions; the detection result is used to indicate whether components are set at the preset positions corresponding to the sub-image; and comparing the detection result and the configuration file to determine whether the components at the preset positions are incorrectly mounted includes: If the detection result is different from the component set at the preset position, then the component placement error at the preset position is determined to be a missing component error.

4. The method for testing a circuit board according to any one of claims 1 to 3, characterized in that, The circuit board testing method further includes: The sub-image is input into a pre-trained classification model for classification processing to obtain a classification result, which is used to indicate whether the component corresponding to the sub-image is a reverse component.

5. The method for testing a circuit board according to any one of claims 1 to 3, characterized in that, The configuration file also includes: the target device type of the component to be set at the preset position; if there are no missing components at the preset position, the detection result is also used to indicate the detected device type of the component object in the sub-image; the comparison of the detection result and the configuration file to determine whether the component at the preset position is incorrectly mounted includes: Compare whether the type of the detection device and the type of the target device are the same; If they are different, then the mounting error at the preset position of the substrate is determined to be a faulty part.

6. The circuit board testing method according to claim 5, characterized in that, The configuration file also includes: the target color value of the component to be set at the preset position; the step of comparing the detection result and the configuration file to determine whether the component at the preset position is incorrectly mounted includes: If the detection device type and the target device type are the same, and the target device type is a terminal, then the detection color value of the sub-image is determined; If the difference between the detected color value and the target color value is greater than the color threshold, then the mounting error at the preset position of the substrate is determined to be a faulty component.

7. A model training method, characterized in that, include: Acquire training samples and sample labels. The training samples include: multiple images including components and multiple images not including components. The sample labels for the images including components are component type and mask image, and the sample labels for the images not including components indicate missing components. The recognition model is trained based on the training samples and the sample labels to obtain the trained recognition model. The trained recognition model is used to perform the circuit board detection method according to any one of claims 1-6 to identify at least one of the following: image component type, mask image, and whether there is a missing component.

8. A circuit board testing apparatus for performing the circuit board testing method according to any one of claims 1 to 6, characterized in that, The circuit board includes: a substrate and multiple components disposed on the substrate; the circuit board detection device includes: An acquisition module is used to acquire a circuit board image, wherein the circuit board image includes multiple component objects; The cropping module is used to crop multiple sub-images at preset positions in the circuit board image according to a preset configuration file, wherein the configuration file includes multiple preset positions; The processing module is used to input the sub-image into a pre-trained recognition model for detection processing based on each sub-image, and output the detection result; The comparison module is used to compare the detection results with the configuration file to determine whether the components at the preset positions are incorrectly mounted.

9. A model training apparatus for executing the model training method of claim 7, characterized in that, The model training device includes: The acquisition module is used to acquire training samples and sample labels. The training samples include: multiple images including components and multiple images not including components. The sample labels of the images including components are component type and mask image, and the sample labels of the images not including components indicate missing components. The training module is used to train a recognition model based on the training samples and the sample labels to obtain a trained recognition model. The trained recognition model is used to execute the circuit board detection method according to any one of claims 1-7 to identify at least one of image component type, mask image, and whether there are missing components.

10. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the detection method for the circuit board as described in any one of claims 1 to 6 or the model training method as described in claim 7.

Citation Information

Patent Citations

  • Component detection method and device, electronic equipment and readable storage medium

    CN111914508A

  • Circuit board detection method, visual detection equipment and device with storage function

    CN113804704A

  • Floating height detection method, detection system and device with storage function

    CN114723648A