AOI polarity detection method, device and storage medium

Through the combination of ring light source filling, image preprocessing and inversion processing combined with normalized correlation coefficient similarity calculation, the problems of low precision and high complexity of template matching in component polarity detection are solved, and accurate detection of component polarity is achieved.

CN114820446BActive Publication Date: 2025-10-03CHINA GRIDCOM +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210279056.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-18
Publication Date
2025-10-03
Estimated Expiration
2042-03-18

AI Technical Summary

Technical Problem

The existing technology has problems of low accuracy and high complexity in template matching in component polarity detection. Especially when the polarity markings of components are not uniform, both traditional algorithms and deep learning algorithms are difficult to effectively solve the problem.

Method used

The polarity of components is determined by obtaining the similarity between the template image and the image to be detected by adopting a method of annular light source filling, image preprocessing and inversion processing combined with normalized correlation coefficient similarity calculation.

Benefits of technology

It achieves accurate detection of component polarity when the polarity markings of components are not uniform, improves detection accuracy and reduces the complexity of template matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114820446B_ABST
    Figure CN114820446B_ABST
Patent Text Reader

Abstract

The present invention discloses an AOI polarity detection method, device, and storage medium. The method comprises: obtaining a template image of an image to be detected; performing image preprocessing on the template image and the image to be detected, respectively, to obtain a target template image and a first image to be detected; inverting the first image to be detected to obtain a second image to be detected; and determining whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image. The polarity detection method of the present invention achieves accurate polarity detection of components in the image to be detected when the polarity markings of the components are inconsistent, thereby improving detection accuracy and reducing the complexity of template matching.
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 an AOI (Automated Optical Inspection) polarity detection method, a computer-readable storage medium, and an AOI polarity detection device. Background Art

[0002] Quality inspection in the circuit board manufacturing industry has traditionally relied on manual assistance. However, with the advancement of high-precision and intelligent technologies in the electronics industry, efficient and high-precision assisted quality inspection has become a pressing need. Component AOI (Automated Optical Inspection) utilizes image acquisition devices or other photoelectric sensors to capture images and other information about the target. Algorithms replace traditional manual processing and analysis of these images, significantly improving inspection speed and accuracy. Based primarily on optical principles and image processing algorithms, this technology compares the captured image to be inspected with a qualified image, thereby detecting common defects in the production process. However, component polarity detection presents a challenge due to inconsistent polarity markings.

[0003] Typically, component AOI inspection employs two approaches: traditional algorithms and deep learning algorithms. Traditional algorithms extract polarity markers through edge detection and morphology. These algorithms require a well-captured image, with clear and distinguishable polarity markers. However, the polarity markers on components on PCBs (Printed Circuit Boards) are often extremely small and difficult to discern, and some components lack clear and distinct polarity markers. Therefore, these algorithms are only suitable for scenarios where specific prior knowledge is required. Furthermore, the positioning of components under inspection is often inferred based on the position of a template. However, if the template and the image under inspection are rotated or offset due to image capture, the template mapping can produce significant deviations, leading to failure in the final result. Deep learning algorithms typically employ convolutional neural networks to extract high-level image information and calculate component orientation information. While these methods have a wide range of applications and are generally more robust, they also present limitations, as some images under inspection lack clear and distinct polarity features, making it difficult to train models that can derive orientation information. Summary of the Invention

[0004] The present invention aims to at least partially address one of the technical problems in the related art. To this end, a first object of the present invention is to provide an AOI polarity detection method that accurately detects the polarity of components in an image to be inspected, even when component polarity markings are inconsistent. This method improves detection accuracy and reduces the complexity of template matching.

[0005] A second object of the present invention is to provide a computer-readable storage medium.

[0006] The third objective of the present invention is to provide an AOI polarity detection device.

[0007] To achieve the above-mentioned objectives, an embodiment of the first aspect of the present invention proposes an AOI polarity detection method, comprising: obtaining a template image of an image to be detected; performing image preprocessing on the template image and the image to be detected, respectively, to obtain a target template image and a first image to be detected; performing inversion processing on the first image to be detected to obtain a second image to be detected; and determining whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image, respectively.

[0008] According to an embodiment of the present invention, the AOI polarity detection method obtains a template image of the image to be detected; performs image preprocessing on the template image and the image to be detected to obtain a target template image and a first image to be detected; inverts the first image to be detected to obtain a second image to be detected; and determines whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image. This method thus achieves accurate detection of the polarity of components in the image to be detected even when component polarity markings are inconsistent, improving detection accuracy and reducing the complexity of template matching.

[0009] In addition, the AOI polarity detection method according to the above embodiment of the present invention may also have the following additional technical features:

[0010] According to one embodiment of the present invention, performing image preprocessing on the template image includes: performing edge detection on the template image and performing binarization processing to obtain a target template image.

[0011] According to one embodiment of the present invention, image preprocessing is performed on the image to be detected, including: binarizing the image to be detected in an iterative manner according to a set step size to obtain a binary image; and processing the binary image in a morphological manner to obtain a first image to be detected.

[0012] According to one embodiment of the present invention, performing inversion processing on the first image to be detected includes: flipping the image to be detected by 180° in a clockwise or counterclockwise direction to obtain a second image to be detected.

[0013] According to one embodiment of the present invention, whether the polarity of components in the images to be detected is correct is determined based on the similarity between the first image to be detected and the second image to be detected and the target template image respectively, including: using normalized correlation coefficients to calculate the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image respectively, recorded as the first similarity and the second similarity; when the first similarity is greater than or equal to a preset threshold, determining that the polarity of components in the images to be detected is correct; when the second similarity is greater than or equal to the preset threshold, determining that the polarity of components in the images to be detected is incorrect.

[0014] According to an embodiment of the present invention, the above-mentioned AOI polarity detection method further includes: using an annular light source to fill in the edge of the image to be detected.

[0015] To achieve the above objectives, a second embodiment of the present invention provides a computer-readable storage medium on which an AOI polarity detection program is stored. When the AOI polarity detection program is executed by a processor, the above-mentioned AOI polarity detection method is implemented.

[0016] According to the computer-readable storage medium of an embodiment of the present invention, by executing the above-mentioned AOI polarity detection method, it is possible to accurately detect the polarity of components in the image to be detected, improve the accuracy of detection, and reduce the complexity of template matching.

[0017] To achieve the above-mentioned objectives, an embodiment of the third aspect of the present invention proposes an AOI polarity detection device, comprising: an acquisition module for acquiring a template image of an image to be detected; a first image processing module for performing image preprocessing on the template image and the image to be detected, respectively, to obtain a target template image and a first image to be detected; a second image processing module for performing inversion processing on the first image to be detected to obtain a second image to be detected; and a determination module for determining whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image, respectively.

[0018] According to an embodiment of the present invention, the AOI polarity detection device comprises an acquisition module that acquires a template image of an image to be detected; a first image processing module performs image preprocessing on the template image and the image to be detected, respectively, to obtain a target template image and a first image to be detected; a second image processing module performs inversion processing on the first image to be detected to obtain a second image to be detected; and a determination module determines whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image. Thus, the device achieves accurate detection of the polarity of components in the image to be detected when the polarity markings of the components are inconsistent, improving detection accuracy and reducing the complexity of template matching.

[0019] In addition, the AOI polarity detection device according to the above embodiment of the present invention may also have the following additional technical features:

[0020] According to an embodiment of the present invention, the first image processing module performs image preprocessing on the template image, specifically for: performing edge detection and binarization processing on the template image to obtain a target template image.

[0021] According to one embodiment of the present invention, the first image processing module performs image preprocessing on the image to be detected, specifically for: binarizing the image to be detected in an iterative manner according to a set step size to obtain a binary image; processing the binarized image in a morphological manner to obtain a first image to be detected.

[0022] According to one embodiment of the present invention, the second image processing module performs inversion processing on the first image to be detected, specifically for: flipping the image to be detected by 180° in a clockwise or counterclockwise direction to obtain a second image to be detected.

[0023] According to one embodiment of the present invention, a determination module determines whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image respectively, and is specifically used to: use normalized correlation coefficients to calculate the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image, respectively, which are recorded as first similarity and second similarity; when the first similarity is greater than or equal to a preset threshold, it is determined that the polarity of components in the image to be detected is correct; when the second similarity is greater than or equal to the preset threshold, it is determined that the polarity of components in the image to be detected is incorrect.

[0024] According to one embodiment of the present invention, the acquisition module is further configured to use a ring light source to fill in the edges of the image to be detected.

[0025] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a flow chart of an AOI polarity detection method according to an embodiment of the present invention;

[0027] Figure 2 FIG. 4 is a block diagram of an AOI polarity detection device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The following describes embodiments of the present invention in detail, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and are not to be construed as limiting the present invention.

[0029] The following describes an AOI polarity detection method, an AOI polarity detection device, and a computer-readable storage medium according to embodiments of the present invention with reference to the accompanying drawings.

[0030] Figure 1 FIG. 4 is a flow chart of an AOI polarity detection method according to an embodiment of the present invention.

[0031] like Figure 1 As shown, the AOI polarity detection method according to the embodiment of the present invention may include the following steps:

[0032] S1, obtaining a template image of the image to be detected, wherein the template image is an image of components with polarity (such as diodes, voltage regulators, etc.) on the PCB board.

[0033] According to one embodiment of the present invention, when acquiring an image to be detected, an annular light source is used to fill in the edge of the image to be detected.

[0034] Specifically, in the SMT (Surface Mounted Technology) patch process, the AOI inspection equipment can inspect the PCB board after the patch is completed, and analyze the acquired image after taking a photo with a camera to detect whether the components on the PCB board have missing patches, cold solder joints, short circuits, reverse polarity, etc. However, the light source of the existing AOI inspection equipment usually adopts an incandescent light source with a fixed lighting angle. When inspecting the PCB board, there are problems of insufficient and uneven lighting, and there is a phenomenon of reflection, which causes the polarity of the components or other information to be lost, affecting the detection accuracy of the AOI equipment. Since the annular light source has the advantage of uniform lighting, in this embodiment, when the annular light source is used to fill in the light on the edge of the image to be inspected, a better captured image can be obtained, and filling in the light on the edge of the image to be inspected can effectively reduce the loss of component polarity or other information caused by reflection, so that a clear image to be inspected can be obtained.

[0035] S2, performing image preprocessing on the template image and the image to be detected respectively to obtain a target template image and a first image to be detected.

[0036] According to one embodiment of the present invention, performing image preprocessing on the template image includes: performing edge detection on the template image and performing binarization processing to obtain a target template image.

[0037] Specifically, since the template image obtained by the camera on the AOI detection equipment is in color, it is necessary to convert the color image into a grayscale image before performing edge detection. The grayscale value range of the grayscale image is 0-255. Then, edge detection is performed on the grayscale image, that is, all points with large grayscale value changes in the grayscale image are detected, and these points are connected to form a number of lines. These lines are the edges of the template image, thereby obtaining the edge image of the template image. In some embodiments of the present invention, the edge detection algorithm can be one of Soble edge detection, Laplace edge detection and Canny edge detection. After obtaining the edge image of the template image, it is binarized to obtain the target template image. By binarizing the template image, the influence of unimportant features on subsequent processing can be reduced, the accuracy of template matching can be improved, and the complexity of template matching can be reduced.

[0038] According to one embodiment of the present invention, image preprocessing of an image to be detected includes: performing binarization processing on the image to be detected in an iterative manner according to a set step size to obtain a binary image; and processing the binary image using a morphological method to obtain a first image to be detected. The set step size refers to the amount of change in the initial threshold during the iterative operation. For example, the set step size can be 5.

[0039] Specifically, the image to be detected is preprocessed by first graying the image to be detected, and then binarizing the image to be detected in an iterative manner according to a set step size to obtain a binary image. The specific steps are as follows:

[0040] (1) Select an initial threshold value T0, such as 50, within the range of the initially set upper and lower threshold limits (such as 50-200);

[0041] (2) According to the initial threshold T, the image is divided into two groups of images, denoted as R1 and R2;

[0042] (3) Calculate the mean values ​​μ1 and μ2 of the grayscale of image R1 and image R2;

[0043] (4) Select a new threshold T, where T = (μ1 + μ2) / 2;

[0044] (5) Reselect the initial threshold T0 according to the set step size, such as 55, and repeat steps (2) to (4) for iterative calculation until the difference between two consecutive T values ​​is less than a preset value;

[0045] (6) Obtain a binary image of the image to be detected.

[0046] Therefore, by setting the step size iteration method, the segmentation threshold of different images to be detected can be dynamically adjusted, which has a wider scope of application and can effectively segment different component areas, thereby improving the reliability of the subsequent similarity calculation of the algorithm.

[0047] After obtaining the binarized image of the image to be detected, the binarized image is processed by morphological means to reduce unimportant features in the binarized image, thereby obtaining a better binarized image (the first image to be detected), thereby reducing the impact of unimportant features on subsequent processing of the binarized image.

[0048] Furthermore, in order to obtain the precise positioning of the component area in the first image to be detected, the target template image can be used as a convolution kernel to perform convolution processing on the first image to be detected, and the binary image (first image to be detected) after morphological processing is matched with the target template image, thereby quickly finding the final position of the component in the first image to be detected. The advantage of template matching is that it does not require prior knowledge of the polarity of the component, and does not need to consider whether the polarity mark of the component is determined, and the area of ​​the component to be detected can be better obtained. Although the computational complexity of template matching is relatively high, its computational complexity can be greatly reduced by the above-mentioned binarization. Therefore, matching the binary image with the binary image of the template image can improve the accuracy of template matching and effectively reduce the complexity of template matching.

[0049] S3, performing inversion processing on the first image to be detected to obtain a second image to be detected.

[0050] According to one embodiment of the present invention, performing inversion processing on the first image to be detected includes: flipping the image to be detected by 180° in a clockwise or counterclockwise direction to obtain a second image to be detected.

[0051] It should be noted that the inversion processing performed on the first image to be detected may also be performed by flipping the image to be detected by an odd multiple of 180° in a clockwise or counterclockwise direction to obtain the second image to be detected.

[0052] S4, determining whether the polarity of the components in the images to be detected is correct according to the similarities between the first image to be detected and the second image to be detected and the target template image respectively.

[0053] According to one embodiment of the present invention, determining whether the polarity of components in a first image to be detected and a second image to be detected are correct based on the similarity between the first image to be detected and the second image to be detected and a target template image, includes: using a normalized correlation coefficient to calculate the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image, respectively, recorded as a first similarity and a second similarity; when the first similarity is greater than or equal to a preset threshold, determining that the polarity of the components in the image to be detected is correct; when the second similarity is greater than or equal to the preset threshold, determining that the polarity of the components in the image to be detected is incorrect. The preset threshold can be calibrated based on the specific conditions of the components during the detection process.

[0054] Specifically, image similarity is used to measure the degree of similarity between two images. Smaller similarity values ​​indicate smaller similarity and greater differences between the images; larger similarity values ​​indicate greater similarity. Normalization is a method of simplifying calculations by transforming dimensional expressions into dimensionless quantities. The normalized correlation coefficient is designed to have a range of [-1, 1] for image similarity. Mapping image similarity data within this range makes judgments more efficient and convenient. Specifically, the closer the similarity is to 1, the more similar the images are; the closer the similarity is to -1, the less similar the images are.

[0055] Specifically, a normalized correlation coefficient is used to calculate the similarity between the first image to be detected and the target template image, which is recorded as a first similarity. The normalized correlation coefficient is also used to calculate the similarity between the second image to be detected and the target template image, which is recorded as a second similarity. The first similarity and the second similarity are respectively compared with a preset threshold value. When the first similarity is greater than or equal to the preset threshold value, it indicates that the first image to be detected and the target template image are more similar, thereby determining that the polarity of the components in the image to be detected is correct; when the second similarity is greater than or equal to the preset threshold value, it indicates that the second image to be detected and the target template image are more similar, and the first image to be detected and the target template image are less similar, thereby determining that the polarity of the components in the image to be detected is incorrect.

[0056] It should be noted that the Euclidean distance may also be used to respectively calculate the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image, which is not limited here.

[0057] Therefore, the method of the present invention, by adopting template matching, can accurately detect the polarity of components in the image to be inspected even when the polarity marks of the components are not uniform. At the same time, by preprocessing the image to be inspected and the template image, the computational complexity brought by template matching can be reduced.

[0058] In summary, according to an embodiment of the present invention, the AOI polarity detection method obtains a template image of the image to be detected; preprocesses the template image and the image to be detected to obtain a target template image and a first image to be detected; inverts the first image to be detected to obtain a second image to be detected; and determines whether the polarity of the components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image. This method thus achieves accurate detection of the polarity of components in the image to be detected when the polarity markings of the components are inconsistent, improving detection accuracy and reducing computational complexity.

[0059] Corresponding to the above embodiment, the present invention further proposes a computer-readable storage medium.

[0060] The computer-readable storage medium of the embodiment of the present invention stores an AOI polarity detection program, and the AOI polarity detection program is executed by a processor to implement the above-mentioned AOI polarity detection method.

[0061] According to the computer-readable storage medium of an embodiment of the present invention, by executing the above-mentioned AOI polarity detection method, it is possible to accurately detect the polarity of components in the image to be detected, improve the accuracy of detection, and reduce the complexity of template matching.

[0062] Corresponding to the above embodiment, the present invention further proposes an AOI polarity detection device.

[0063] Figure 2 FIG. 4 is a block diagram of an AOI polarity detection device according to an embodiment of the present invention.

[0064] like Figure 2 As shown, the AOI polarity detection device according to the embodiment of the present invention includes: an acquisition module 10 , a first image processing module 20 , a second image processing module 30 and a determination module 40 .

[0065] The acquisition module 10 is used to acquire a template image of the image to be detected. The first image processing module 20 is used to perform image preprocessing on the template image and the image to be detected, respectively, to obtain a target template image and a first image to be detected. The second image processing module 30 is used to invert the first image to be detected to obtain a second image to be detected. The determination module 40 is used to determine whether the polarity of the components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image.

[0066] According to an embodiment of the present invention, the first image processing module 20 performs image preprocessing on the template image, specifically for: performing edge detection and binarization processing on the template image to obtain a target template image.

[0067] According to one embodiment of the present invention, the first image processing module 20 performs image preprocessing on the image to be detected, specifically for: binarizing the image to be detected in an iterative manner according to a set step size to obtain a binary image; processing the binarized image in a morphological manner to obtain a first image to be detected.

[0068] According to an embodiment of the present invention, the second image processing module 30 performs inversion processing on the first image to be detected, specifically for: flipping the image to be detected by 180° in a clockwise or counterclockwise direction to obtain a second image to be detected.

[0069] According to one embodiment of the present invention, the determination module 40 determines whether the polarity of the components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image respectively, and is specifically used to: use the normalized correlation coefficient to calculate the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image, respectively, which are recorded as the first similarity and the second similarity; when the first similarity is greater than or equal to a preset threshold, it is determined that the polarity of the components in the image to be detected is correct; when the second similarity is greater than or equal to the preset threshold, it is determined that the polarity of the components in the image to be detected is incorrect.

[0070] According to an embodiment of the present invention, the acquisition module 10 is further configured to use a ring light source to fill in the edges of the image to be detected.

[0071] It should be noted that for details not disclosed in the AOI polarity detection device of the embodiment of the present invention, please refer to the details disclosed in the AOI polarity detection method of the embodiment of the present invention, and the details will not be repeated here.

[0072] According to an embodiment of the present invention, the AOI polarity detection device comprises an acquisition module that acquires a template image of an image to be detected; a first image processing module performs image preprocessing on the template image and the image to be detected, respectively, to obtain a target template image and a first image to be detected; a second image processing module performs inversion processing on the first image to be detected to obtain a second image to be detected; and a determination module determines whether the polarity of components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image. Thus, the device achieves accurate detection of the polarity of components in the image to be detected when the polarity markings of the components are inconsistent, improving detection accuracy and reducing the complexity of template matching.

[0073] It should be noted that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic device), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and portable compact disc read-only memory (CDROM). Furthermore, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing it in another suitable manner if necessary, and then storing it in a computer memory.

[0074] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0075] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

[0076] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0077] In the present invention, unless otherwise specified or limited, the terms "installed," "connected," "connect," "fixed," etc. should be understood in a broad sense. For example, they can refer to fixed connection, detachable connection, or integration; mechanical connection, electrical connection; direct connection, or indirect connection through an intermediate medium; internal communication between two components, or interaction between two components, unless otherwise specified. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.

[0078] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

Claims

1. An AOI polarity detection method, characterized in that: include: Acquire a template image of an image to be detected; wherein the image to be detected includes components to be detected and polarity of the components to be detected; the template image includes target components and polarity of the target components; the components to be detected correspond to the target components; Performing edge detection on the template image and performing binarization processing to obtain a target template image; Determining a first initial segmentation threshold within a preset segmentation threshold range; Segmenting the grayscale image of the image to be detected according to the first initial segmentation threshold to obtain a first segmented image and a second segmented image; performing an averaging operation on the grayscale mean of the first segmented image and the grayscale mean of the second segmented image to obtain a first target segmentation threshold; Obtaining a second initial segmentation threshold based on the first initial segmentation threshold and a preset step size; Segmenting the grayscale image of the image to be detected according to the second initial segmentation threshold to obtain a third segmented image and a fourth segmented image; performing an average operation based on the grayscale mean of the third segmented image and the grayscale mean of the fourth segmented image to obtain a second target segmentation threshold; If the difference between the first target segmentation threshold and the second target segmentation threshold is greater than or equal to a preset difference threshold, the second initial segmentation threshold is used as the first initial segmentation threshold, and the process returns to the step of obtaining the second initial segmentation threshold based on the first initial segmentation threshold and the preset step size until the difference between the first target segmentation threshold and the second target segmentation threshold is less than the preset difference threshold; performing binarization processing on the image to be detected according to a second target segmentation threshold to obtain a binarized image; The binary image is processed by morphological means to obtain a first image to be detected; wherein the first image to be detected contains the component to be detected and the polarity of the component to be detected; performing inversion processing on the first image to be detected to obtain a second image to be detected; Whether the polarity of the component to be detected in the image to be detected is correct is determined according to the similarity between the first image to be detected and the second image to be detected and the target template image respectively.

2. The AOI polarity detection method according to claim 1, wherein: Performing inversion processing on the first image to be detected, comprising: The image to be detected is flipped 180° in a clockwise or counterclockwise direction to obtain the second image to be detected.

3. The AOI polarity detection method according to claim 1, wherein: Determining whether the polarity of components in the images to be detected is correct according to the similarities between the first image to be detected and the second image to be detected and the target template image, including: Calculating the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image using normalized correlation coefficients, respectively, and recording them as first similarity and second similarity; When the first similarity is greater than or equal to a preset threshold, determining that the polarity of the component in the image to be detected is correct; When the second similarity is greater than or equal to the preset threshold, it is determined that the polarity of the component in the image to be detected is wrong.

4. The AOI polarity detection method according to claim 1, wherein: Also includes: A ring light source is used to fill in the edge of the image to be detected.

5. A computer-readable storage medium, characterized in that An AOI polarity detection program is stored thereon, and when the AOI polarity detection program is executed by a processor, the AOI polarity detection method according to any one of claims 1 to 4 is implemented.

6. An AOI polarity detection device, characterized in that: include: An acquisition module is configured to acquire a template image of an image to be detected; wherein the image to be detected includes components to be detected and polarity of the components to be detected; the template image includes target components and polarity of the target components; and the components to be detected correspond to the target components; A first image processing module is used to perform edge detection and binarization processing on the template image to obtain a target template image; The first image processing module is further configured to determine a first initial segmentation threshold within a preset segmentation threshold range; segment the grayscale image of the image to be detected according to the first initial segmentation threshold to obtain a first segmented image and a second segmented image; perform an average operation based on the grayscale mean of the first segmented image and the grayscale mean of the second segmented image to obtain a first target segmentation threshold; obtain a second initial segmentation threshold based on the first initial segmentation threshold and a preset step size; segment the grayscale image of the image to be detected according to the second initial segmentation threshold to obtain a third segmented image and a fourth segmented image; perform an average operation based on the grayscale mean of the third segmented image and the grayscale mean of the fourth segmented image , obtaining a second target segmentation threshold; if the difference between the first target segmentation threshold and the second target segmentation threshold is greater than or equal to a preset difference threshold, using the second initial segmentation threshold as the first initial segmentation threshold, and returning to the step of obtaining the second initial segmentation threshold based on the first initial segmentation threshold and the preset step size, until the difference between the first target segmentation threshold and the second target segmentation threshold is less than the preset difference threshold; binarizing the image to be detected according to the second target segmentation threshold to obtain a binarized image; processing the binarized image by a morphological method to obtain a first image to be detected; wherein, the first image to be detected contains the component to be detected and the polarity of the component to be detected; A second image processing module is used to perform inversion processing on the first image to be detected to obtain a second image to be detected; A determination module is used to determine whether the polarity of the component to be detected in the image to be detected is correct according to the similarity between the first image to be detected and the second image to be detected and the target template image respectively.

7. The AOI polarity detection device according to claim 6, characterized in that: The second image processing module performs inversion processing on the first image to be detected, specifically for: The image to be detected is flipped 180° in a clockwise or counterclockwise direction to obtain the second image to be detected.

8. The AOI polarity detection device according to claim 6, characterized in that: The determination module determines whether the polarity of the components in the image to be detected is correct based on the similarity between the first image to be detected and the second image to be detected and the target template image, and is specifically used to: Calculating the similarity between the first image to be detected and the target template image and the similarity between the second image to be detected and the target template image using normalized correlation coefficients, respectively, and recording them as first similarity and second similarity; When the first similarity is greater than or equal to a preset threshold, determining that the polarity of the component in the image to be detected is correct; When the second similarity is greater than or equal to the preset threshold, it is determined that the polarity of the component in the image to be detected is wrong.

9. The AOI polarity detection device according to claim 6, characterized in that: The acquisition module is further configured to use a ring light source to fill in the edge of the image to be detected.

Citation Information

Patent Citations

  • Element wrong part detection method and system

    CN106530275A

  • A PCB appearance detection system and detection method based on the Internet

    CN109726777A

  • Polarity recognition recognition method and recognition device, electronic equipment and storage medium

    CN111738247A