Circuit board size and flaw detection method, device, equipment and medium

By using the correlation matching method between grayscale images and template images in circuit board detection, the existing circuit board detection methods are solved, and high-precision and low-cost circuit board size and defect detection are achieved.

CN119784677AInactive Publication Date: 2025-04-08苏州秒测高新科技有限公司

Patent Information

Application Number
CN202411688146.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-04-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing circuit board detection methods have problems such as low efficiency, difficulty in guaranteeing accuracy, high cost, risk to operator health, and difficulty in detection under complex backgrounds and variable lighting conditions.

Method used

Using a circuit board size and defect detection method, by obtaining the grayscale image and template image of the area to be detected, the template image is slided on the image of the area to be detected, the correlation between the two is calculated, and the maximum correlation position is obtained to detect the defect and obtain the size.

Benefits of technology

It realizes high-accurate board size and defect detection, does not rely on artificial vision, reduces detection costs, eliminates risks to operator health, has little impact when light changes, and can simultaneously efficiently detect board size and defects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119784677A_ABST
    Figure CN119784677A_ABST
Patent Text Reader

Abstract

The invention discloses a circuit board size and flaw detection method, device and equipment and a medium, and relates to the technical field of circuit board detection. Not only can the surface defects of the circuit board be detected, but also the internal defects and dimensional deviation of the circuit board can be detected; the risk on the health of operators is eliminated; the influence on the illumination aspect is small; the size and defects of the circuit board can be simultaneously detected, and the efficiency is high. According to the scheme, a to-be-detected area gray image is acquired; obtaining a template image; the image is slid on the gray level image of the area to be detected, and all positions are traversed; calculating the correlation between the template image and the gray level image sub-region of the to-be-detected region; obtaining the maximum correlation between the template image and the gray level image sub-region of the to-be-detected region; acquiring a matching result of the to-be-detected area image to detect whether the current to-be-detected circuit board has flaws or not; and obtaining the size of the circuit board. The circuit board detection device is used for circuit board detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of the electronics industry, circuit boards have become an indispensable component of modern electronic devices. The manufacturing quality of circuit boards is directly related to the performance and reliability of electronic products. Therefore, accurate size inspection and defect inspection of circuit boards is a key step to ensure product quality.

[0003] The existing circuit board inspection methods mainly include the following: (1) manual visual inspection, which mainly relies on manual visual inspection; (2) automated optical inspection, which captures images through high-resolution cameras and uses preset algorithms to analyze the images to identify defects on the circuit board; (3) X-ray inspection, as the name suggests, uses X-rays to inspect the internal structure of the circuit board to be inspected; (4) machine vision inspection, by using machine learning algorithms, machine vision systems can identify and classify various types of defects.

[0004] All of the above-mentioned circuit board inspection methods have defects. Manual visual inspection relies on manual vision, which is not only inefficient but also easily affected by operator fatigue and subjective judgment, making it difficult to ensure the consistency and accuracy of the inspection results. Automated optical inspection can usually only detect surface defects, but is powerless for more subtle internal defects and dimensional deviations. X-ray inspection is not only costly but also poses potential risks to the health of operators. Machine vision inspection still has difficulties in dealing with complex backgrounds, changing lighting conditions and high-speed inspection. Summary of the invention

[0005] The present invention provides a circuit board size and defect detection method, device, equipment and medium, which are independent of artificial vision and have high detection result accuracy; can detect not only circuit board surface defects, but also some internal defects and size deviations with slight shape changes, complex textures or blurred focus; while reducing the detection cost, the risk to the health of operators is eliminated; the impact on light is relatively small; the size and defects of the circuit board can be detected simultaneously, and the efficiency is high, that is, the product size can be detected quickly and accurately while the product defect can be detected quickly and accurately.

[0006] In order to achieve the above object, the present invention adopts the following technical scheme:

[0007] A first aspect of the present invention provides a circuit board size and defect detection method, comprising:

[0008] Get the grayscale image of the area to be detected.

[0009] Acquire a template image; the template image is a grayscale image.

[0010] The template image is slid on the grayscale image of the area to be detected to traverse all positions on the grayscale image of the area to be detected.

[0011] For each position (x, y), the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected is calculated, and the formula is:

[0012]

[0013] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0014] The maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected is obtained, that is, the position where the template image best matches the grayscale image of the area to be detected is obtained.

[0015] Similarly, taking the template image as a standard, the matching result of the image of the inspection area of ​​each circuit board to be tested is obtained to detect whether the current circuit board to be tested has defects; and the size of the current circuit board to be tested is obtained through the template image.

[0016] Furthermore, the circuit board size and defect detection method obtains the maximum correlation between the template image and the grayscale image sub-region I(x, y) of the area to be detected, that is, obtains the position where the template image best matches the grayscale image of the area to be detected, including:

[0017] All pixels in the template image are organized into a row vector a in column order, namely, a feature vector of the template image, and a region vector b that best matches the template image in the grayscale image of the region to be detected is obtained.

[0018] Calculate the angle between the row vector a and the region vector b to obtain the probability of matching:

[0019]

[0020] Wherein, θ represents the angle between the row vector a and the region vector b, a represents the row vector, and b represents the region vector.

[0021] Furthermore, the circuit board size and defect detection method, after calculating the correlation between the template image and the grayscale image sub-region I(x, y) of the area to be detected for each position (x, y), obtains the maximum correlation between the template image and the grayscale image sub-region I(x, y) of the area to be detected, that is, before obtaining the position where the template image best matches the grayscale image of the area to be detected, further includes:

[0022] The correlation between the template image and the grayscale image sub-region I(x, y) of the region to be detected is normalized:

[0023]

[0024] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0025] Furthermore, the circuit board size and defect detection method, obtaining the grayscale image of the area to be detected, includes:

[0026] The grayscale image of the area to be inspected is acquired through auxiliary positioning by an industrial area array camera and scanning by a line scan camera.

[0027] or,

[0028] A color image of the area to be detected is obtained through a camera, and grayscale processing is performed on the color image to obtain a grayscale image of the area to be detected.

[0029] Furthermore, the circuit board size and defect detection method, obtaining the template image, includes:

[0030] The template image is generated by importing design data.

[0031] or,

[0032] The template image is obtained by scanning the standard product with the line scan camera.

[0033] Furthermore, the circuit board size and defect detection method, the template image and the grayscale image of the area to be detected include:

[0034] The size of the template image is smaller than the grayscale image of the area to be detected.

[0035] Furthermore, the circuit board size and defect detection method obtains the size of the current circuit board to be tested through the template image, including:

[0036] The size of the circuit board to be tested is obtained through blob analysis and circle and line fitting image processing algorithms.

[0037] A second aspect of the present invention provides a circuit board size and defect detection device, comprising:

[0038] The first acquisition unit is used to acquire a grayscale image of the area to be detected.

[0039] The second acquisition unit is used to acquire a template image; the template image is a grayscale image.

[0040] The sliding unit is used to slide the template image on the grayscale image of the area to be detected, and traverse all positions on the grayscale image of the area to be detected.

[0041] The calculation unit is used to calculate the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected for each position (x, y), and the formula is:

[0042]

[0043] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0044] The third acquisition unit is used to acquire the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, to acquire the position where the template image best matches the grayscale image of the area to be detected.

[0045] The detection unit is used to obtain the matching result of the image of the detection area of ​​each circuit board to be tested based on the template image to detect whether the current circuit board to be tested has defects, and obtain the size of the current circuit board to be tested through the template image.

[0046] A third aspect of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0047] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0048] The present invention provides a circuit board size and defect detection method, device, equipment and medium, including: obtaining a grayscale image of a to-be-detected area; obtaining a template image; sliding the template image on the grayscale image of the to-be-detected area to traverse all positions on the grayscale image of the to-be-detected area; calculating the correlation between the template image and the sub-region of the grayscale image of the to-be-detected area for each position; obtaining the maximum correlation between the template image and the sub-region of the grayscale image of the to-be-detected area; similarly, taking the template image as a standard, obtaining the matching results of the to-be-detected area images of each to-be-detected circuit board to detect whether the current to-be-detected circuit board has defects; and obtaining the size of the current to-be-detected circuit board through the template image. Compared with the prior art, the present invention does not rely on artificial vision and has high detection result accuracy; not only can the surface defects of the circuit board be detected, but also some internal defects and size deviations with slight changes in shape, complex texture or blurred focus can be detected; while reducing the detection cost, the risk to the health of the operator is eliminated; the influence on the light is relatively small; the size and defects of the circuit board can be detected simultaneously, and the efficiency is high, that is, the product size can be detected quickly and accurately while the product defect can be detected quickly and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. The drawings are only used to illustrate the implementation methods and are not to be considered as limitations of the present invention.

[0050] Figure 1 A schematic diagram of a circuit board size and defect detection method according to an embodiment of the present invention;

[0051] Figure 2 A schematic diagram of another circuit board size and defect detection method according to an embodiment of the present invention;

[0052] Figure 3A schematic diagram of the structure of a circuit board size and defect detection device according to an embodiment of the present invention;

[0053] Figure 4 It is a schematic diagram of the structure of another circuit board size and defect detection device according to an embodiment of the present invention;

[0054] Figure 5 The figure is a schematic diagram of the structure of an electronic device for detecting size and defects of a circuit board according to an embodiment of the present invention. DETAILED DESCRIPTION

[0055] The technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only a part of the embodiment of the present invention, not all of the embodiments. Based on the embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0056] Unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as commonly understood by technicians in the field of the present invention; the terms used in the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings, and are intended to cover non-exclusive inclusions.

[0057] In the description of the embodiments of the present invention, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present invention, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.

[0058] In the description of the embodiments of the present invention, the term "and / or" is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0059] In the description of the embodiments of the present invention, the term "multiple" refers to more than two (including two). Similarly, "multiple groups" refers to more than two groups (including two groups), and "multiple pieces" refers to more than two pieces (including two pieces).

[0060] In the description of the embodiments of the present invention, the technical terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the embodiments of the present invention.

[0061] In the description of the embodiments of the present invention, unless otherwise clearly specified and limited, technical terms such as "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the embodiments of the present invention can be understood according to the specific circumstances.

[0062] Embodiment 1

[0063] The embodiment of the present invention provides a circuit board size and defect detection method, such as Figure 1 As shown, including:

[0064] S101, obtaining a grayscale image of the area to be detected.

[0065] In the field of circuit board inspection, the area to be inspected refers to the specific area in the circuit board that needs to be measured and inspected for defects. A grayscale image is an image that only contains brightness information. It is usually represented by a single channel. The value of each pixel represents the brightness of the pixel. The brightness value range of a grayscale image is usually 0 to 255.

[0066] S102, obtaining a template image; the template image is a grayscale image.

[0067] In the field of image processing and computer vision, a template image refers to a predefined small-size image used for a specific purpose. In this embodiment, the template image is a grayscale image.

[0068] S103, sliding the template image on the grayscale image of the area to be detected, traversing all positions on the grayscale image of the area to be detected.

[0069] Specifically, the template image is placed at a starting position of the grayscale image of the area to be detected, usually starting from the upper left corner of the image, and each pixel of the template image is compared with the pixel at the corresponding position in the grayscale image to be detected, that is, all positions on the grayscale image to be detected are traversed.

[0070] S104, for each position (x, y), calculate the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected, the formula is:

[0071]

[0072] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0073] The correlation between the template image and the grayscale image sub-region of the region to be detected refers to a statistical measure of the similarity between the two.

[0074] S105 , obtaining the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, obtaining the position where the template image and the grayscale image of the area to be detected best match.

[0075] Obtaining the maximum correlation between the template image and the grayscale image sub-region I(x,y) of the area to be detected, that is, obtaining the position where the template image and the grayscale image of the area to be detected best match each other, is the core goal of template matching. This process involves calculating the similarity between the template image and each sub-region of the image to be detected, and obtaining the position with the highest similarity.

[0076] S106. Similarly, using the template image as a standard, obtaining the matching results of the images of the inspection areas of each circuit board to be tested, so as to detect whether the current circuit board to be tested has defects; and obtaining the size of the current circuit board to be tested through the template image.

[0077] The embodiment of the present invention provides a circuit board size and defect detection method, comprising: obtaining a grayscale image of a region to be detected; obtaining a template image; sliding the template image on the grayscale image of the region to be detected, traversing all positions on the grayscale image of the region to be detected; calculating the correlation between the template image and the sub-region of the grayscale image of the region to be detected for each position; obtaining the maximum correlation between the template image and the sub-region of the grayscale image of the region to be detected; similarly, taking the template image as a standard, obtaining the matching results of the images of the regions to be detected of each circuit board to be tested, so as to detect whether the current circuit board to be tested has defects; and obtaining the size of the current circuit board to be tested through the template image. Compared with the prior art, the embodiment of the present invention does not rely on artificial vision, and the detection result has high accuracy; not only can the surface defects of the circuit board be detected, but also some internal defects and size deviations with slight changes in shape, complex texture or blurred focus can be detected; while reducing the detection cost, the risk to the health of the operator is eliminated; the impact on the light is relatively small; the size and defects of the circuit board can be detected at the same time, and the efficiency is high, that is, the product size can be detected quickly and accurately while the product defect can be detected quickly and accurately.

[0078] Embodiment 2

[0079] The embodiment of the present invention provides a circuit board size and defect detection method, such as Figure 2 As shown, including:

[0080] S201, obtaining a grayscale image of the area to be detected.

[0081] In this embodiment, there are two methods for obtaining the grayscale image of the area to be detected:

[0082] The first method is to use industrial area array cameras to assist in positioning and line scan cameras to obtain a grayscale image of the area to be inspected.

[0083] Among them, the industrial area array camera is a high-tech imaging device widely used in the fields of automation and quality control. It is widely used and can obtain two-dimensional image information of the target. It is suitable for a variety of measurements such as area, shape, size, position, etc. The line scan camera is a camera specially designed for continuous scanning of scenes. Unlike traditional area array cameras, the line scan camera captures a line of images at each exposure through its line array sensor, and then merges multiple one-dimensional images to form a complete two-dimensional image. The line scan camera has high resolution and high-speed scanning capabilities in the horizontal direction, which is particularly suitable for high-speed moving object detection.

[0084] The second method is to obtain a color image of the area to be detected through a camera, perform grayscale processing on the color image, and obtain a grayscale image of the area to be detected.

[0085] Specifically, the color image of the area to be detected obtained by the camera is gray-scale processed, that is, the RGB values ​​of the color image are combined into a single gray-scale value, so as to obtain a gray-scale image of the area to be detected. The gray-scale processing method includes but is not limited to the weighted average method, the average method, and the maximum method. The following is a detailed introduction to each gray-scale processing method:

[0086] (1) Weighted average method:

[0087] Y=0.299R+0.578G+0.114B

[0088] Among them, R represents the value of the red channel, G represents the value of the green channel, B represents the value of the blue channel, and Y represents the calculated grayscale value.

[0089] (2) Average value method:

[0090]

[0091] Among them, R represents the value of the red channel, G represents the value of the green channel, B represents the value of the blue channel, and Y represents the calculated grayscale value.

[0092] (3) Maximum method:

[0093] Y=max(R,G,B)

[0094] Among them, R represents the value of the red channel, G represents the value of the green channel, B represents the value of the blue channel, and Y represents the calculated grayscale value.

[0095] It should be noted here that the method for grayscale processing of color images in this embodiment is not limited to the above three methods, namely the weighted average method, the average method, and the maximum method. The implementer may also adopt other grayscale processing methods during implementation. Any method that can process a color image into a grayscale image is within the protection scope of this embodiment.

[0096] S202, obtaining a template image; the template image is a grayscale image.

[0097] In order to compare and match with the grayscale image of the area to be detected, the template image is also a grayscale image, and the size of the template image is smaller than the grayscale image of the area to be detected.

[0098] There are two methods for obtaining the template image in this embodiment:

[0099] The first method: Generate a template image by importing design data.

[0100] Specifically, determine the design data of the template image, which can be a design drawing of the product, a CAD file, or any document containing a detailed description of the features to be detected; use an image generation tool, such as Canva, which is an online design platform that allows users to generate images by describing content.

[0101] The second method is to obtain a template image by scanning a standard product with a line scan camera.

[0102] Specifically, prepare a standard product to ensure that the standard product has no defects and represents the features or objects identified during the inspection process; configure the parameters of the line scan camera, including exposure, gain, trigger mode, etc., according to the characteristics of the product and the inspection requirements. The line scan camera needs to be synchronized with the pulse generator (encoder) integrated with the conveyor belt to ensure that the line frequency of the camera is consistent with the speed of the object; use the line scan camera to scan the standard product. Since the line scan camera only captures one line as an image and sends it to the computer, the host computer organizes and splices all the lines to create an infinitely large image; pre-process the captured image, including denoising, contrast enhancement, etc., to improve image quality. Image processing software (such as Halcon) can be used for image processing, including binarization, morphological operations, etc.; extract the image template from the processed image.

[0103] S203, sliding the template image on the grayscale image of the area to be detected, traversing all positions on the grayscale image of the area to be detected.

[0104] Specifically, the template image is slid on the grayscale image of the area to be detected, usually starting from the upper left corner of the image and moving one pixel at a time until the entire image is covered.

[0105] S204, for each position (x, y), calculate the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected, the formula is:

[0106]

[0107] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0108] S205, normalize the correlation between the template image and the grayscale image sub-region I (x, y) of the region to be detected:

[0109]

[0110] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, It represents the average value of sub-region T of the gray image I of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the gray image of the area to be detected.

[0111] S206, obtaining the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, obtaining the position where the template image and the grayscale image of the area to be detected best match.

[0112] Specifically, all pixels in the template image are organized into a row vector a in column order, namely, a feature vector of the template image, and a region vector b that best matches the template image in the grayscale image of the region to be detected is obtained.

[0113] Calculate the angle between the row vector a and the area vector b to get the probability of a match:

[0114]

[0115] Among them, θ represents the angle between the row vector a and the area vector b, a represents the row vector, and b represents the area vector.

[0116] When the correlation between the template image and the grayscale image of the area to be detected is better, the smaller the angle θ is, the larger the cosθ is, and the closer it is to 1, the better the correlation is.

[0117] S207 . Similarly, using the template image as a standard, obtaining the matching results of the images of the inspection areas of each circuit board to be tested, so as to detect whether the current circuit board to be tested has defects; and obtaining the size of the current circuit board to be tested through the template image.

[0118] The specific method of obtaining the size of the current circuit board to be tested through the template image is: obtaining the size of the current circuit board to be tested through blob analysis and circle and line fitting image processing algorithms. Specifically, the following steps are included:

[0119] (1) Apply image segmentation technology, such as threshold segmentation, to separate the foreground pixels from the background pixels of the template image. Adaptive threshold method or Otsu method can be used for binarization processing.

[0120] (2) Perform blob analysis to identify connected regions in grayscale images. Extract regional features such as area, center of gravity, rotation angle, etc. These features help identify and measure specific elements on the circuit board.

[0121] (3) For circular features on the circuit board, a circle fitting algorithm, such as the least squares method, is used to determine the center and radius of the circle. For straight line features, a polynomial fitting algorithm (such as Polyfit) is used to determine the parameters of the line.

[0122] (4) Use the extracted geometric features, such as the radius of a circle, the length of a line segment, etc., to determine the size of the circuit board.

[0123] The embodiment of the present invention provides a circuit board size and defect detection method, comprising: obtaining a grayscale image of a region to be detected; obtaining a template image; sliding the template image on the grayscale image of the region to be detected, traversing all positions on the grayscale image of the region to be detected; calculating the correlation between the template image and the sub-region of the grayscale image of the region to be detected for each position; obtaining the maximum correlation between the template image and the sub-region of the grayscale image of the region to be detected; similarly, taking the template image as a standard, obtaining the matching results of the images of the regions to be detected of each circuit board to be tested, so as to detect whether the current circuit board to be tested has defects; and obtaining the size of the current circuit board to be tested through the template image. Compared with the prior art, the embodiment of the present invention does not rely on artificial vision, and the detection result has high accuracy; not only can the surface defects of the circuit board be detected, but also some internal defects and size deviations with slight changes in shape, complex texture or blurred focus can be detected; while reducing the detection cost, the risk to the health of the operator is eliminated; the impact on the light is relatively small; the size and defects of the circuit board can be detected at the same time, and the efficiency is high, that is, the product size can be detected quickly and accurately while the product defect can be detected quickly and accurately.

[0124] Embodiment 3

[0125] The embodiment of the present invention provides a circuit board size and defect detection device, such as Figure 3 As shown, including:

[0126] The first acquisition unit 31 is used to acquire a grayscale image of the area to be detected.

[0127] The second acquisition unit 32 is used to acquire a template image; the template image is a grayscale image.

[0128] The sliding unit 33 is used to slide the template image on the grayscale image of the area to be detected, and traverse all positions on the grayscale image of the area to be detected.

[0129] The calculation unit 34 is used to calculate the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected for each position (x, y), and the formula is:

[0130]

[0131] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0132] The third acquisition unit 35 is used to acquire the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, to acquire the position where the template image best matches the grayscale image of the area to be detected.

[0133] The detection unit 36 ​​is used to obtain the matching result of the image of the detection area of ​​each circuit board to be tested based on the template image to detect whether the current circuit board to be tested has defects, and obtain the size of the current circuit board to be tested through the template image.

[0134] It should be noted here that the detailed description of each component structure in this embodiment can refer to other embodiments and will not be repeated here.

[0135] The embodiment of the present invention provides a circuit board size and defect detection device, comprising: a first acquisition unit, used to acquire a grayscale image of a region to be detected; a second acquisition unit, used to acquire a template image; a sliding unit, used to slide the template image on the grayscale image of the region to be detected, and traverse all positions on the grayscale image of the region to be detected; a calculation unit, used to calculate the correlation between the template image and a sub-region of the grayscale image of the region to be detected for each position; a third acquisition unit, used to acquire the maximum correlation between the template image and the sub-region of the grayscale image of the region to be detected; a detection unit, used to obtain the matching result of the image of the region to be detected of each circuit board to be detected based on the template image as a standard; The result is used to detect whether the current circuit board to be tested has defects; and the size of the current circuit board to be tested is obtained through the template image. Compared with the prior art, the embodiment of the present invention does not rely on artificial vision and has a high detection result accuracy; not only can surface defects of the circuit board be detected, but also some internal defects and size deviations with slight changes in shape, complex texture or blurred focus can be detected; while reducing the detection cost, the risk to the health of operators is eliminated; the impact on lighting is relatively small; the size and defects of the circuit board can be detected at the same time, with high efficiency, that is, high-precision and rapid detection of product size can be achieved while quickly and accurately detecting product defects.

[0136] Embodiment 4

[0137] The embodiment of the present invention provides a circuit board size and defect detection device, such as Figure 4 As shown, including:

[0138] The first acquisition unit 41 is used to acquire a grayscale image of the area to be detected.

[0139] The second acquisition unit 42 is used to acquire a template image; the template image is a grayscale image.

[0140] The sliding unit 43 is used to slide the template image on the grayscale image of the area to be detected, and traverse all positions on the grayscale image of the area to be detected.

[0141] The calculation unit 44 is used to calculate the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected for each position (x, y), and the formula is:

[0142]

[0143] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0144] The normalization unit 45 performs normalization processing on the correlation between the template image and the grayscale image sub-region I(x, y) of the region to be detected:

[0145]

[0146] Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of sub-region I of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at position (x+i,y+j) in the grayscale image of the area to be detected.

[0147] The third acquisition unit 46 is used to acquire the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, to acquire the position where the template image best matches the grayscale image of the area to be detected.

[0148] The detection unit 47 is used to obtain the matching result of the image of the detection area of ​​each circuit board to be tested based on the template image to detect whether the current circuit board to be tested has defects, and obtain the size of the current circuit board to be tested through the template image.

[0149] It should be noted here that the detailed description of each component structure in this embodiment can refer to other embodiments and will not be repeated here.

[0150] The embodiment of the present invention provides a circuit board size and defect detection device, comprising: a first acquisition unit, used to acquire a grayscale image of a region to be detected; a second acquisition unit, used to acquire a template image; a sliding unit, used to slide the template image on the grayscale image of the region to be detected, and traverse all positions on the grayscale image of the region to be detected; a calculation unit, used to calculate the correlation between the template image and a sub-region of the grayscale image of the region to be detected for each position; a normalization unit, used to normalize the correlation between the template image and the sub-region I(x, y) of the grayscale image of the region to be detected; a third acquisition unit, used to acquire the maximum correlation between the template image and the sub-region of the grayscale image of the region to be detected; a detection unit, used to calculate the maximum correlation between the template image and the sub-region of the grayscale image of the region to be detected with the template image; As a standard, the matching results of the images of the areas to be tested of each circuit board to be tested are obtained to detect whether the current circuit board to be tested has defects; and the size of the current circuit board to be tested is obtained through the template image. Compared with the prior art, the embodiment of the present invention does not rely on artificial vision, and the detection result has high accuracy; not only can the surface defects of the circuit board be detected, but also some internal defects and size deviations with slight changes in shape, complex texture or blurred focus can be detected; while reducing the detection cost, the risk to the health of the operator is eliminated; the impact on lighting is relatively small; the size and defects of the circuit board can be detected at the same time, and the efficiency is high, that is, the product size can be detected quickly and accurately while the product defect can be detected quickly and accurately.

[0151] Embodiment 5

[0152] An embodiment of the present invention provides an electronic device for detecting size and defects of a circuit board, such as Figure 5 As shown, it includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned circuit board size and defect detection method are implemented.

[0153] A processing device (e.g., a central processing unit, a graphics processor, etc.) 51 can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 52 or a program loaded from a storage device 58 into a random access memory (RAM) 53. Various programs and data required for the operation of the electronic device are also stored in the RAM 53. The processing device 51, the ROM 52, and the RAM 53 are connected to each other via a bus 54. An input / output (I / O) interface 55 is also connected to the bus 54.

[0154] Typically, the following devices may be connected to the I / O interface 55: an input device 56 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 57 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 58 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 59. The communication device 59 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Figure 5 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 5 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0155] In particular, according to some embodiments of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network through the communication device 59, or installed from the storage device 58, or installed from the ROM 52. When the computer program is executed by the processing device 51, the above-mentioned functions defined in the method of some embodiments of the present invention are executed.

[0156] The embodiment of the present invention provides an electronic device for detecting the size and defects of a circuit board, which is independent of artificial vision and has a high accuracy in detection results; it can detect not only surface defects of the circuit board, but also internal defects and size deviations with slight changes in shape, complex textures or blurred focus; it reduces the detection cost and eliminates the risk to the health of operators; it is less affected by lighting; it can detect the size and defects of the circuit board at the same time and has high efficiency, that is, it can quickly detect the product size with high precision and accurately detect the product defects at the same time.

[0157] Embodiment 6

[0158] An embodiment of the present invention provides a computer-readable storage medium for circuit board size and defect detection. A computer program is stored on the computer-readable storage medium. When the computer program is executed by one or more processors, the steps of the above-mentioned circuit board size and defect detection method are implemented.

[0159] It should be noted that in some embodiments of the present invention, the computer-readable medium mentioned above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In some embodiments of the present invention, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0160] In some implementations, the client and server can use HTTP

[0161] The communication network may communicate with any currently known or future developed network protocol such as HyperText Transfer Protocol (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an adhoc peer-to-peer network), as well as any currently known or future developed network.

[0162] The computer-readable medium may be included in the device; or it may exist independently without being assembled into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a grayscale image of the area to be detected; obtains a template image; slides the template image on the grayscale image of the area to be detected, traversing all positions on the grayscale image of the area to be detected; calculates the correlation between the template image and the sub-region of the grayscale image of the area to be detected for each position; obtains the maximum correlation between the template image and the sub-region of the grayscale image of the area to be detected; similarly, taking the template image as a standard, obtains the matching results of the images of the areas to be detected of each circuit board to be tested, so as to detect whether the current circuit board to be tested has defects; and obtains the size of the current circuit board to be tested through the template image. The computer program code for performing the operations of some embodiments of the present invention may be written in one or more programming languages ​​or a combination thereof, and the programming language includes an object-oriented programming language, such as Java, Smalltalk, C++, and a conventional procedural programming language, such as "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0163] The embodiment of the present invention provides a computer-readable storage medium for detecting the size and defects of a circuit board, which is independent of artificial vision and has a high accuracy in detection results. It can detect not only surface defects of the circuit board, but also internal defects and size deviations with slight changes in shape, complex textures, or blurred focus. It reduces the detection cost and eliminates the risk to the health of operators. It is less affected by lighting. It can detect the size and defects of the circuit board at the same time with high efficiency, that is, it can quickly and accurately detect product defects while quickly detecting product size with high precision.

[0164] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, not to limit them; although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention. In particular, as long as there is no structural conflict, the various technical features mentioned in each embodiment can be combined in any way. The present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions that fall within the scope of the claims.

Claims

1. A circuit board size and defect detection method, characterized in that: include: Obtain a grayscale image of the area to be detected; Get the template image; The template image is a grayscale image; Slide the template image on the grayscale image of the area to be detected to traverse all positions on the grayscale image of the area to be detected; For each position (x, y), the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected is calculated, and the formula is: Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, N represents the width of the template image, and T represents the average value of the template image. represents the average value of the I sub-region of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at the position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at the position (x+i,y+j) in the grayscale image of the area to be detected; Obtaining the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, obtaining the position where the template image best matches the grayscale image of the area to be detected; Similarly, taking the template image as a standard, the matching result of the image of the area to be tested of each circuit board to be tested is obtained to detect whether the current circuit board to be tested has defects; And the size of the current circuit board to be tested is obtained through the template image.

2. The circuit board size and defect detection method according to claim 1, characterized in that: Obtaining the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, obtaining the position where the template image best matches the grayscale image of the area to be detected, includes: All pixels in the template image are organized into a row vector a in column order, namely, a feature vector of the template image, and a region vector b that best matches the template image in the grayscale image of the region to be detected is obtained; Calculate the angle between the row vector a and the region vector b to obtain the probability of matching: Wherein, θ represents the angle between the row vector a and the region vector b, a represents the row vector, and b represents the region vector.

3. The circuit board size and defect detection method according to claim 1, characterized in that: After calculating the correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected for each position (x, y), obtaining the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, before obtaining the position where the template image best matches the grayscale image of the area to be detected, the method further includes: The correlation between the template image and the grayscale image sub-region I(x, y) of the region to be detected is normalized: Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, I represents the average value of the I sub-region of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at the position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at the position (x+i,y+j) in the grayscale image of the area to be detected.

4. The circuit board size and defect detection method according to claim 1, characterized in that: Acquiring the grayscale image of the area to be detected, including: Acquire the grayscale image of the area to be inspected by using an industrial area array camera to assist positioning and a line scan camera to scan; or, A color image of the area to be detected is obtained through a camera, and grayscale processing is performed on the color image to obtain a grayscale image of the area to be detected.

5. The circuit board size and defect detection method according to claim 1, characterized in that: Acquiring the template image includes: Generate the template image by importing design data; or, The template image is obtained by scanning the standard product with the line scan camera.

6. The circuit board size and defect detection method according to claim 1, characterized in that: The template image and the grayscale image of the area to be detected include: The size of the template image is smaller than the grayscale image of the area to be detected.

7. The circuit board size and defect detection method according to claim 1, characterized in that: Obtaining the size of the current circuit board to be tested through the template image includes: The size of the circuit board to be tested is obtained through blob analysis and circle and line fitting image processing algorithms.

8. A circuit board size and defect detection device, characterized in that: include: A first acquisition unit, used to acquire a grayscale image of the area to be detected; A second acquisition unit, used for acquiring a template image; The template image is a grayscale image; A sliding unit, used for sliding the template image on the grayscale image of the area to be detected, traversing all positions on the grayscale image of the area to be detected; The calculation unit is used to calculate the correlation between the template image and the grayscale image sub-region I (x, y) of the area to be detected for each position (x, y), and the formula is: Wherein, T represents the template image, I represents the grayscale image of the area to be detected, M represents the length of the template image, and N represents the width of the template image. represents the average value of the template image, represents the average value of the I sub-region of the grayscale image of the area to be detected, i represents the index of the template image in the row direction, j represents the index of the template image in the column direction, T(i,j) represents the pixel value at the position (i,j) in the template image, and I(x+i,y+j) represents the pixel value at the position (x+i,y+j) in the grayscale image of the area to be detected; A third acquisition unit is used to acquire the maximum correlation between the template image and the sub-region I(x, y) of the grayscale image of the area to be detected, that is, to acquire the position where the template image best matches the grayscale image of the area to be detected; The detection unit is used to obtain the matching result of the image of the detection area of ​​each circuit board to be tested based on the template image to detect whether the current circuit board to be tested has defects, and obtain the size of the current circuit board to be tested through the template image.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • RGB vector matching rapid-recognition system and method

    CN103559499A

  • Paper label character defect detection method

    CN109934809A

  • Die-cutting product detection method and software

    CN111707667A

  • Template matching detection method, computer equipment and storage medium

    CN114091620A

  • Defect image detection method and system, intelligent terminal and medium

    CN114332092A

Cited By

  • Method and system for automatically measuring size of camera module

    CN120411004A