Machine vision detection method and system for printed circuit defects, medium, program and terminal
Through machine vision detection methods, the problems of low efficiency and low accuracy of ceramic line detection are solved through technologies such as contrast enhancement, feature point extraction and affine transformation, and efficient and accurate defect detection is achieved.
Patent Information
- Application Number
- CN202510009955.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-05-06
AI Technical Summary
The existing ceramic circuit detection efficiency is low and the accuracy is low, so it is impossible to effectively detect subtle defects such as missing printing and overprinting.
By using machine vision detection method, by acquiring circuit images and template images, using the emphasize function to enhance contrast, extract feature points and perform affine transformation alignment, extract the analysis area according to the defect type to be detected, perform threshold segmentation and opening operations, and calculate the area threshold of the connecting area for comparison to obtain the detection result.
It improves the efficiency and accuracy of ceramic line defect detection, can quickly locate abnormal areas, reduce the amount of calculation, enhance the accuracy of detection, and reduce the chance of misjudgment.
Smart Images

Figure CN119941669A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of defect detection, and in particular to a printed circuit defect detection method, system, medium, program and terminal. Background Art
[0002] Ceramic circuit is a conductive circuit system based on ceramic materials and is an important component of lamps. Ceramic circuits usually adopt thick film process or thin film process, and conductive paste (such as silver, gold, copper, etc.) is printed on the ceramic substrate and sintered to form a conductive circuit. Ceramic circuits directly affect the conductivity of the light source, so its integrity is very critical. The production process of ceramic circuits includes printing, sintering and other links. Various defects may occur in these links, such as missing printing (missing printing), excessive printing (overprinting), etc. These defects will lead to poor welding of chips and components, poor contact and other phenomena.
[0003] Quality inspections on the market are generally carried out one by one after the light source process is completed. For example, each product is manually inspected using a solder paste tester. However, on the one hand, this type of inspection takes a long time, resulting in low efficiency; on the other hand, some defects cannot even be detected by the naked eye and require a microscope to observe, such as the tin coating. When there are pits on the substrate, they are usually very small, and it is difficult to determine whether the product is defective by the naked eye. Careful observation under a microscope is required to determine. Manual judgment cannot ensure the quality of each product, resulting in low detection accuracy. Summary of the invention
[0004] In view of the above-mentioned shortcomings of the prior art, the purpose of the present application is to provide a printed circuit defect detection method, system, medium, program and terminal, which are used to solve the problems of low efficiency and low accuracy of existing ceramic circuit detection.
[0005] To achieve the above-mentioned purpose and other related purposes, the first aspect of the present application provides a machine vision detection method for printed circuit defects, comprising the following steps: acquiring a circuit image and a template image; using an emphasize function to enhance the contrast of the circuit image; wherein, the neighborhood average value of each pixel in the circuit image is calculated by mean filtering, and the brightness difference between the neighborhood average value and its corresponding original value is amplified; extracting feature points of the template image and the contrast-enhanced circuit image, aligning the template image to the circuit image using an affine transformation matrix, and extracting an analysis area to be analyzed according to the defect type to be detected; wherein the defect type to be detected includes printing omission and overprinting; using the var_threshold function to perform threshold segmentation on the analysis area to obtain a target area; using the opening_circle function to perform an opening operation on the target area; extracting the connected areas in the target area after the opening operation, calculating the area threshold corresponding to each of the connected areas according to a preset process accuracy calculation method, and combining the defect type to be detected, comparing the area of the connected area with the corresponding area threshold to obtain a detection result.
[0006] In an embodiment of the first aspect of the present application, after acquiring the circuit image and before contrast enhancement of the circuit image, the following steps are also included: determining whether the circuit in the circuit image is complete; if the circuit is incomplete, splicing several circuit images corresponding to the same product to obtain a circuit image with a complete circuit.
[0007] In an embodiment of the first aspect of the present application, the extraction of the analysis area to be analyzed according to the defect type to be detected includes the following steps: when the defect type to be detected is printing omission, extracting the bright area in the matching area of the circuit image after contrast enhancement that matches the template image as the analysis area.
[0008] In an embodiment of the first aspect of the present application, the method of extracting the analysis area to be analyzed according to the defect type to be detected includes the following steps: when the defect type to be detected is overprinting, first extracting the dark area in the matching area of the circuit image after contrast enhancement that matches the template image, using a circular structure to expand the dark area to obtain an expanded area, and using the area obtained by subtracting the dark area from the expanded area point by point as the analysis area.
[0009] In an embodiment of the first aspect of the present application, obtaining a target area after performing threshold segmentation on the analysis area includes the following steps: determining whether the ambient light in the circuit image is stable; when the ambient light is stable, extracting the target area after performing global threshold segmentation on the analysis area; wherein the global threshold segmentation is segmentation according to maximum and minimum grayscales, and after comparing the grayscale value of each pixel with the set maximum and minimum grayscales, extracting the bright area between the maximum and minimum grayscales as the target area; when the ambient light is unstable, extracting the target area after performing local threshold segmentation on the analysis area; wherein the local threshold segmentation is to use a binary mask scan on each pixel using a var_threshold function, and extracting the dark area as the target area after comparing the grayscale of the pixel with the standard deviation grayscale of the mask center.
[0010] In an embodiment of the first aspect of the present application, in combination with the defect type to be detected, the area of the connected area is compared with the corresponding area threshold to obtain a detection result, which includes the following steps: when the defect type to be detected is printing deficiency, when the area of the connected area is greater than the area threshold, there is a printing deficiency defect; when the defect type to be detected is over-printing, when the area of the connected area is greater than the area threshold, there is an over-printing defect.
[0011] To achieve the above-mentioned purpose and other related purposes, the second aspect of the present application provides a machine vision detection system for printed circuit defects, including: an image acquisition module for acquiring a circuit image and a template image; an image processing and analysis module for enhancing the contrast of the circuit image using an emphasize function; wherein the neighborhood average value of each pixel in the circuit image is calculated by mean filtering, and the brightness difference between the neighborhood average value and its corresponding original value is amplified; feature points of the template image and the circuit image after contrast enhancement are extracted, the template image is aligned to the circuit image using an affine transformation matrix, and an analysis area to be analyzed is extracted according to the defect type to be detected; wherein the defect type to be detected includes printing omission and overprinting; the analysis area is threshold-segmented using the var_threshold function to obtain a target area; the target area is opened using the opening_circle function; the connected area in the target area after the opening operation is extracted, the area threshold corresponding to each of the connected areas is calculated according to a preset process accuracy calculation method, and the area of the connected area is compared with the corresponding area threshold in combination with the defect type to be detected to obtain a detection result.
[0012] To achieve the above-mentioned purpose and other related purposes, the third aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor according to any of the methods described above.
[0013] To achieve the above-mentioned purpose and other related purposes, the fourth aspect of the present application provides a computer program product, characterized in that the computer program product includes a computer program code, and when the computer program code runs on a computer, the computer implements any of the methods described above.
[0014] To achieve the above-mentioned purpose and other related purposes, the fourth aspect of the present application provides an electronic terminal, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement any of the aforementioned methods.
[0015] As described above, the present application has the following beneficial effects:
[0016] The present application provides a printed circuit defect detection method, system, medium, program and terminal. By using the emphasize function to enhance the contrast of the acquired circuit image and comparing it with the template image, the contrast enhancement is used to improve the difference between the brightness area and the darkness area in the circuit image, so that the details of the image are clearer, especially the boundaries of the light-emitting chip or the printed circuit become more obvious, and a clearer basic image is provided for subsequent image segmentation, target extraction and other operations. Compared with the simple grayscale transformation (such as linear stretching) in the prior art, the emphasize function can dynamically adjust the enhancement intensity according to the local brightness of the image through the pixel neighborhood mean calculation to avoid excessive or insufficient enhancement, and, combined with the calculation of the local mean, it can suppress high-frequency noise while enhancing the contrast, while the conventional contrast enhancement method is effective for the overall image, but the enhancement effect on local features (such as thin lines) is limited. The analysis area to be analyzed is extracted according to the defect type to be detected; the detection image is compared with the standard template image, so that the abnormal area in the circuit image can be quickly located, the irrelevant area is eliminated, and the analysis range is narrowed. Through the extracted analysis area, the calculation amount for the subsequent processing steps is reduced, and the accuracy of the detection is improved. Then, the var_threshold function is used to perform threshold segmentation on the analysis area to obtain the target area, and the area with significant brightness or darkness (such as the line part or the defective part) is extracted. Compared with the fixed threshold segmentation, var_threshold dynamically adjusts the segmentation threshold by calculating the brightness variance or standard deviation of each pixel neighborhood, and can adapt to complex lighting conditions. Then, the opening_circle function is used to perform an opening operation on the target area to remove noise, smooth the boundaries, and retain the shape of the target area. The connected areas in the target area after the opening operation are extracted, and the area threshold corresponding to each of the connected areas is calculated according to the preset process accuracy calculation method. Combined with the defect type to be detected, the area of the connected area is compared with the corresponding area threshold to obtain the detection result. In summary, due to the template comparison and binary mask, only the area of interest is processed to reduce the calculation of irrelevant areas; and through local threshold segmentation, adaptive denoising and connected area analysis, redundant operations are reduced; therefore, the time is very short. Moreover, the geometric errors are corrected to align the templates and ensure the accuracy of pixel-level comparison. The target area can be extracted more accurately by adapting to changes in ambient light. The opening operation is used for denoising to reduce the chance of misjudgment of detected defects. Therefore, the accuracy of the detection results is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Shown is a flow chart of a machine vision inspection method for printed circuit defects in one embodiment of the present application.
[0018] Figure 2Shown is a schematic diagram of the principle of a machine vision detection method for printed circuit defects in one embodiment of the present application.
[0019] Figure 3 Shown is a structural schematic diagram of a machine vision inspection system for printed circuit defects in one embodiment of the present application.
[0020] Figure 4 Shown is a schematic diagram of the structure of an electronic terminal in one embodiment of the present application. DETAILED DESCRIPTION
[0021] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0022] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first XX and the second XX are only used to distinguish different XXs, and do not limit their order. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0023] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" represent examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0024] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can represent: a, b, c, ab, ac, bc or abc, where a, b, c can be single or multiple.
[0025] like Figure 1-2 As shown, the first aspect of the present application provides a machine vision detection method for printed circuit defects, comprising the following steps:
[0026] S1: Acquire a circuit image and a template image.
[0027] It should be understood that the template image refers to a standard image used as a reference in the detection process, representing an ideal circuit image without defects. The template image acts as a benchmark in defect detection, and is compared with the circuit image to be detected to identify whether there are defects in the image (such as missing printing, excessive printing, etc.). The circuit image is an actual image of the workpiece to be detected obtained by a camera or scanning device, reflecting the actual layout of printed circuits and components on the circuit board. Unlike the template image, the circuit image comes directly from the production line and is the true performance of the workpiece in actual production during the detection link.
[0028] In an embodiment of the first aspect of the present application, after acquiring the circuit image and before contrast enhancement of the circuit image, the following steps are further included: determining whether the circuit in the circuit image is complete, and if the circuit is incomplete, splicing several circuit images corresponding to the same product to obtain a circuit image with a complete circuit. It should be understood that in actual production, the circuit board may not be able to obtain a complete circuit image through one shot due to its large size, high complexity or uneven circuit distribution, so that there may be uncovered circuit areas in a single image, especially edge areas.
[0029] S2: using an emphasize function to enhance the contrast of the circuit image; wherein, calculating the neighborhood average of each pixel in the circuit image by mean filtering to amplify the brightness difference between the neighborhood average value and its corresponding original value.
[0030] It should be understood that the core of the emphasize function is to enhance contrast by calculating the brightness difference between each pixel and its neighborhood and amplifying these differences, thereby making the bright parts of the image brighter and the dark parts darker. Mean filtering refers to calculating the mean (i.e., "smoothing" value) of the grayscale values of its neighborhood for each pixel of the circuit image using a window (neighborhood) of a certain size. The neighborhood mean represents the brightness background of the pixel in its local area. The difference between the grayscale value of a pixel and the neighborhood mean, i.e., the brightness difference, the larger the difference value, the more significant the brightness difference of the pixel relative to its neighborhood, where the new grayscale value is obtained by the following formula:
[0031] res=round((orig-mean)×Factor)+orig
[0032] Among them, orig is the original pixel value, mean is the neighborhood mean, and Factor is the enhancement factor.
[0033] Since the features of printed circuit images (such as circuits, solder joints, and light-emitting components) are usually distributed in a complex background, and the circuits may be very small, the emphasize function is used to magnify the brightness difference between pixels and neighborhoods to make these features more prominent, such as significantly strengthening the edge of the circuit to make the circuit and background more clearly distinguishable, and also to increase the brightness difference around solder joints or components, so as to facilitate the detection of whether the light emission is normal. In addition, by calculating the neighborhood mean through mean filtering, the emphasize function can suppress random noise in the image (such as isolated bright spots or dark spots) while enhancing the contrast. Compared with other direct enhancement algorithms (such as linear stretching of grayscale), the emphasize function retains the overall structural features of the target area (such as circuit shape and light-emitting area boundary) while eliminating noise. In addition, in practical applications, changes in ambient light may cause uneven global brightness of circuit images. The emphasize function can effectively deal with the problem of uneven illumination by performing local calculations based on the neighborhood of each pixel, such as enhancing local brightness in dark areas to extract key details, and suppressing overly bright parts in strong light areas to prevent detail loss.
[0034] S3: extracting feature points of the template image and the contrast-enhanced circuit image, aligning the template image to the circuit image using an affine transformation matrix, and extracting an analysis area to be analyzed according to the defect type to be detected; wherein the defect type to be detected includes printing omission and over-printing.
[0035] It should be understood that the affine transformation is a two-dimensional plane transformation used to translate, rotate, scale and shear an image. By matching feature points, the geometric relationship between the template image and the circuit image is calculated, and an affine transformation matrix is generated. The template image is aligned to the circuit image after affine transformation so that the two are in the same coordinate system. Affine transformation aligns the template image and the circuit image at the pixel level through feature point extraction and affine transformation alignment, avoiding detection errors caused by image position offset, and thus can adapt to different shooting angles, scaling ratios or slight deformations, ensuring that the template image and circuit image comparison algorithm has strong robustness in actual production.
[0036] In an embodiment of the first aspect of the present application, the extraction of the analysis area to be analyzed according to the defect type to be detected includes the following steps: when the defect type to be detected is printing omission, extracting the bright area in the matching area of the circuit image after contrast enhancement that matches the template image as the analysis area.
[0037] It should be understood that the matching area refers to the area where the circuit layout exists in the template image and the area where there is a corresponding part in the circuit image. The matching area is extracted as the analysis area for printing omissions, and then it is determined whether there are parts with insufficient grayscale values in these areas (circuits are not printed).
[0038] In an embodiment of the first aspect of the present application, the method of extracting the analysis area to be analyzed according to the defect type to be detected includes the following steps: when the defect type to be detected is overprinting, first extracting the dark area in the matching area of the circuit image after contrast enhancement that matches the template image, using a circular structure to expand the dark area to obtain an expanded area, and using the area obtained by subtracting the dark area from the expanded area point by point as the analysis area.
[0039] It should be understood that, similar to the detection of missing prints, the area matching the template image in the contrast-enhanced circuit image is first extracted, and then the matching area is expanded using a circular structural element. Expansion is a method of morphological processing, which can expand the boundary of the matching area outward to include the part that may be overprinted. Then, the expanded area is subtracted point by point from the original matching area. The obtained area represents the newly added part during the expansion process. These newly added parts are the areas where there may be redundant circuits, which are used to analyze the situation of overprinting. Since the expansion operation can include the overprinted circuits or redundant materials in the analysis range to avoid omissions, after point-by-point subtraction, only the newly appeared parts in the expanded area are retained to ensure that the detection results are concentrated in the area of redundant printing, and through expansion and subtraction operations, the analysis area is accurately limited to the boundary part where there may be overprinting problems, avoiding unnecessary regional calculations. Compared with the traditional method (directly performing pixel-by-pixel comparison or global analysis on the entire image), the present application uses the method of feature point extraction, affine transformation and regional segmentation to extract the analysis area more accurately and efficiently, which is suitable for defect detection of complex circuit layouts. The inspection processes for under-printing and over-printing are designed separately to meet the inspection requirements of different defect types, with greater flexibility and applicability.
[0040] It should be understood that under the illumination of a light source, the printed circuit will become darker, while the area without printed circuits will become brighter. Using this feature, defects in printed circuits can be detected by contrasting the bright and dark areas in the image. Specifically, the printed circuit area absorbs more light because it is covered with conductive material, and appears as a darker part in the image; while the unprinted area reflects more light and appears as a brighter part in the image.
[0041] When detecting missing prints, the bright parts of the image can be extracted, because these bright areas represent areas that are not covered by printing. During the detection process, the area of each bright area is extracted. If the area of the bright area exceeds the initially set area threshold (determined by the process standard), it can be determined that there is a missing print defect in the area. At the same time, the area of the bright area can be calculated by the number of pixels and further converted into actual physical units (such as mm 2 ) to more intuitively understand the size of the missing area. In addition, the number of bright areas in the image can also reflect the number of missing points. Each independent bright area corresponds to a missing point, so counting the number of bright areas can be used to indicate how many missing points there are in the line.
[0042] When detecting overprinting, on the contrary, it is necessary to extract the dark parts of the image, because these dark areas may not only contain normally printed circuits, but also overprinted parts. Overprinted areas usually appear as excess conductive materials, such as too large solder joints, short circuits between circuits, or material overflow. During the detection process, the area of the dark area is extracted and compared with the preset maximum area threshold. If the area of a dark area exceeds the maximum threshold, it can be determined that the area has an overprinting defect. Similar to missed printing detection, the area of the dark area can also be converted into a physical area (such as mm) through pixels. 2 ), which is used to visually assess the severity of overprinting. In addition, the number of independent dark areas in the image can also indicate the amount of overprinting, for example, multiple overflows of printed materials may correspond to multiple independent dark areas.
[0043] S4: Using the var_threshold function to perform threshold segmentation on the analysis area to obtain the target area.
[0044] In an embodiment of the first aspect of the present application, obtaining a target area after performing threshold segmentation on the analysis area includes the following steps: determining whether the ambient light in the circuit image is stable; when the ambient light is stable, extracting the target area after performing global threshold segmentation on the analysis area; wherein the global threshold segmentation is segmentation according to maximum and minimum grayscales, and after comparing the grayscale value of each pixel with the set maximum and minimum grayscales, extracting the bright area between the maximum and minimum grayscales as the target area; when the ambient light is unstable, extracting the target area after performing local threshold segmentation on the analysis area; wherein the local threshold segmentation is to use a binary mask scan on each pixel using a var_threshold function, and extracting the dark area as the target area after comparing the grayscale of the pixel with the standard deviation grayscale of the mask center.
[0045] It should be understood that changes in ambient light will affect the overall brightness and contrast of the circuit image. Therefore, analyzing the ambient light can better analyze and process the circuit image to make the detection results more accurate. To determine whether the ambient light is stable, global brightness analysis, local area brightness consistency analysis, and historical data comparison can be used. Among them, the global brightness analysis method is to calculate the average grayscale value and standard deviation of the entire image. If the standard deviation is small, the ambient light is considered stable; the local area brightness consistency analysis method refers to calculating the grayscale mean and standard deviation in different areas of the image. If the difference between the areas is small, the ambient light is considered stable; the historical data comparison method refers to comparing the brightness information of the current image with the template image to determine whether the illumination has a large fluctuation. By analyzing the stability of the ambient light, a specific threshold segmentation method is selected. For example, when the ambient light is stable, global threshold segmentation is used to quickly extract the target area; when the ambient light is unstable, local threshold segmentation is used to enhance adaptability and reduce the impact of illumination fluctuations on the results.
[0046] Specifically, global threshold segmentation means first presetting a grayscale range (maximum grayscale and minimum grayscale) to represent the brightness range of the area of interest (such as a circuit or a light-emitting element), and then comparing the grayscale value of each pixel with the maximum grayscale and the minimum grayscale. If the pixel grayscale value is between the maximum grayscale and the minimum grayscale, it is determined to be the target area, otherwise it is determined to be the background; then the bright pixels that meet the grayscale range are extracted to form the target area. Global threshold segmentation can effectively remove noise or background information with a large brightness difference from the target area by setting the grayscale range. It is simple to calculate and has a fast processing speed, which is suitable for scenes with uniform ambient light and consistent image brightness. When calculating the global threshold, the var_threshold function dynamically calculates the threshold based on the neighborhood information of each pixel (such as the mean or standard deviation) instead of using a global fixed threshold. Specifically, the threshold of each pixel is determined by the grayscale distribution characteristics of its neighborhood, and dynamic adjustment enables the algorithm to adapt to lighting changes in different scenes. This method is particularly suitable for conditions with uneven lighting or brightness fluctuations, ensuring that the target area can be accurately extracted without causing mis-segmentation or missed segmentation due to global illumination changes.
[0047] Local threshold segmentation refers to a method that dynamically adjusts the threshold based on the pixel neighborhood. The specific steps are: first use a binary mask (such as a rectangular or circular window) to scan the neighborhood of each pixel, then calculate the brightness distribution of the mask area (such as grayscale mean and standard deviation), and compare the grayscale value of the current pixel with the standard deviation grayscale of the mask center. If the pixel grayscale value is lower than a certain threshold of the mask standard deviation, it is determined to be the target area, otherwise it is the background; then dynamically adjust the threshold pixel by pixel to extract the dark part of the target area (such as missing lines or non-luminous components). Among them, the var_threshold function can use the mask to limit the detection range, only perform local threshold calculations on pixels in the area of interest, and retain the target area covered by the mask, reducing the amount of calculation and interference. Compared with the fixed threshold segmentation method, the binary segmentation of the local threshold in this application can adapt to the changes in brightness distribution of different scenes by dynamically calculating the threshold of each pixel neighborhood, and is particularly suitable for scenes with complex backgrounds or local brightness changes in printed circuit images; and, the use of the var_threshold function combined with binary mask scanning allows the local threshold segmentation to not only dynamically adjust the threshold, but also limit the analysis range, further reducing the amount of calculation and error. When calculating the local threshold, var_threshold combines neighborhood statistical characteristics (such as standard deviation, mean) for analysis. This method can more accurately describe the difference between local pixels and the background, especially when processing fine lines, solder joints or defects in printed circuit images. This method can effectively separate the target area from the background. In the local threshold calculation, var_threshold combines neighborhood characteristic analysis, which can automatically suppress the influence of local isolated pixels (such as random noise points), thereby having good anti-interference ability against background interference in the circuit image (such as circuit board material texture or dust). In addition, traditional local segmentation algorithms (such as local histogram equalization methods such as CLAHE) have a large amount of computation, while var_threshold adjusts the threshold based on the statistical characteristics of the neighborhood, which has higher computational efficiency and is suitable for real-time processing tasks, especially for detection in the process of product flow from the previous link to the next link.
[0048] S5: Use the opening_circle function to perform an opening operation on the target area.
[0049] It should be understood that opening_circle is a function based on morphological operations, which is used to perform opening operations on the target area of the image. Opening operations are an important preprocessing method in morphological processing, which is usually used to remove noise, smooth the boundaries of the target area, and retain the overall structural characteristics of the target area. Its core principle is to optimize the morphology of the target area through a combination of erosion and expansion operations.
[0050] Specifically, in the target area, small-sized isolated noise points (such as random bright spots in the background) will be removed by the corrosion operation, while the expansion operation will not restore these removed noise points. For example, dust, material defects or other tiny noises in the circuit image can be effectively removed, making the target area cleaner. Compared with the traditional mean filtering method, this denoising method more accurately retains the overall shape of the target area and removes isolated pixels. Mean filtering and Gaussian filtering methods often cause the overall image to be blurred, affecting the boundary clarity of the target area, while the opening operation suppresses the interference of random noise while retaining the edge characteristics. In the target area, the uneven boundary parts (such as burrs or jagged edges) are also optimized by the opening operation. The corrosion operation can reduce unnecessary edge details or noise points, and the expansion operation can fill the small gaps caused by corrosion, making the boundary of the target area smoother. In the circuit image, this operation can effectively repair the subtle breakpoints or irregular defects caused by printing process problems, and enhance the connectivity of the circuit and the regularity of the boundary. During the whole process, the main structure of the target area (such as the overall shape of the circuit and the geometric features of the solder joints) can be completely preserved and will not be lost due to denoising or smoothing operations. Even the complex circuit network or solder joint details in the circuit can maintain their integrity through the opening operation, providing high-quality input data for subsequent circuit integrity detection. Compared with a single erosion or dilation operation, the opening operation combines the advantages of both and can achieve the best balance between denoising and structure preservation. A single erosion operation may over-cut the target area, resulting in loss of details, while a single dilation operation may expand the noise or burr area, further reducing the image quality. The opening operation first removes noise points by erosion, and then restores the main structure and boundary integrity of the target area by dilation, making the morphological processing more stable and effective. In addition, the opening_circle function uses a circular structure element, which is particularly suitable for processing regular circular areas such as solder joints and light-emitting components in circuit images. Compared with rectangular or other asymmetric structure elements, circular structure elements can better fit the geometric characteristics of the target area, ensuring that the integrity and connectivity of the target area are retained during the processing. For the line shape or solder joint area of the printed circuit image, the circular structure element can provide a more realistic processing effect and further optimize the regional morphology.
[0051] It should be understood that after performing the open operation, the target area may contain multiple discrete connected parts (connected areas). Preferably, the connection function is used to perform connectivity analysis on the area after the open operation, marking and segmenting each connected independent area (such as each line or solder joint in the circuit). Each connected area is a separate logical area that can be analyzed separately by subsequent processing. Preferably, after the connectivity analysis, the target area may contain connected areas of different sizes, some of which are noise or non-target parts (such as tiny particles). The select_shape function is used to filter out areas that meet the requirements according to specific shape features (such as area), and the larger or size-compliant areas are filtered out by specifying the area range (removing non-target areas with too small areas, such as small noise points or burrs). Preferably, the area_center function is used to extract the area and center position of the area to provide high-precision data for specific tasks such as solder joint detection and line width measurement.
[0052] In summary, the opening_circle function has shown extremely high technical advantages in denoising, boundary optimization and structure preservation through opening operations, and is particularly suitable for processing complex lines and solder joints in printed circuits. This method can not only significantly improve the clarity and regularity of the target area, but also provide a high-quality image foundation for subsequent feature extraction and defect detection. Compared with traditional filtering methods and single morphological operations, the use of the opening_circle function is more accurate and efficient, and can well balance the contradiction between denoising and morphological preservation.
[0053] S6: extracting the connected areas in the target area after the opening operation, calculating the area threshold corresponding to each of the connected areas according to a preset process accuracy calculation method, and comparing the area of the connected area with the corresponding area threshold to obtain the detection result in combination with the defect type to be detected.
[0054] In an embodiment of the first aspect of the present application, in combination with the defect type to be detected, the area of the connected area is compared with the corresponding area threshold to obtain a detection result, which includes the following steps: when the defect type to be detected is printing deficiency, when the area of the connected area is greater than the area threshold, there is a printing deficiency defect; when the defect type to be detected is over-printing, when the area of the connected area is greater than the area threshold, there is an over-printing defect.
[0055] It should be understood that when detecting missing prints, the area of the bright part is extracted as the analysis area, that is, the missing part is extracted as the analysis area. When the missing area is higher than the preset area threshold, it is missing prints, and the number of missing prints represents the number of lines with missing prints. When detecting overprinting, the area of the dark part is extracted as the analysis area, that is, the overprinted part is extracted as the analysis area. When the overprinted area is higher than the preset area threshold, it is overprinting, and the number of overprinted areas represents the number of lines with overprinting defects.
[0056] The second aspect of the present application provides a machine vision detection system for printed circuit defects, comprising: an image acquisition module for acquiring a circuit image and a template image; an image processing and analysis module for enhancing the contrast of the circuit image using an emphasize function; wherein the neighborhood average value of each pixel in the circuit image is calculated by mean filtering, and the brightness difference between the neighborhood average value and its corresponding original value is amplified; feature points of the template image and the circuit image after contrast enhancement are extracted, the template image is aligned to the circuit image using an affine transformation matrix, and an analysis area to be analyzed is extracted according to the defect type to be detected; wherein the defect type to be detected includes printing omission and overprinting; the analysis area is threshold-segmented using the var_threshold function to obtain a target area; the target area is opened using the opening_circle function; the connected area in the target area after the opening operation is extracted, and the area threshold corresponding to each of the connected areas is calculated according to a preset process accuracy calculation method, and the area of the connected area is compared with the corresponding area threshold in combination with the defect type to be detected to obtain a detection result.
[0057] It should be understood that the specific process of each module executing the above corresponding steps has been described in detail in the above method embodiment, and for the sake of brevity, it will not be repeated here.
[0058] It should also be understood that the division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0059] like Figure 3As shown, a machine vision detection system for printed circuit defects of the present application can be used on a product production line. The production line is composed of a conveying track 301, a sensor 302, and a circuit printing section 303. The machine vision detection system for printed circuit defects can be installed in a host computer 304. After the product completes the printing of the circuit in the circuit printing section 303, it is transmitted to the bottom of the camera component 305 through the conveying track 301. At this time, after the sensor 302 senses that the product appears under the camera sub 305, the camera component 305 takes a picture to collect the circuit image. The machine vision detection system for printed circuit defects obtains the circuit image taken by the camera component 305 and performs image processing and analysis. Preferably, since the present method can quickly complete the quality inspection of the circuit line, an alarm light 306 can be installed near the camera component 305 to promptly notify the operator on the production line that there is a defective product here.
[0060] A third aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor according to any of the methods described above.
[0061] A fourth aspect of the present application provides a computer program product, characterized in that the computer program product includes a computer program code, and when the computer program code runs on a computer, the computer implements any of the methods described above.
[0062] like Figure 4 As shown, the fourth aspect of the present application provides an electronic terminal, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement any of the aforementioned methods. The electronic terminal includes: at least one processor 401, a memory 402, at least one network interface 403 and a user interface 405. The various components in the electronic terminal are coupled together through a bus system 404. It can be understood that the bus system 404 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 404 also includes a power bus, a control bus and a status signal bus.
[0063] The user interface 405 may include a display, a keyboard, a mouse, a trackball, a click gun, keys, buttons, a touch pad or a touch screen.
[0064] It is understood that the memory 402 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM). The memory described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable categories of memory.
[0065] The memory 402 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic terminal 400. Examples of these data include: any executable program used to operate on the electronic terminal 400, such as an operating system 4021 and an application 4022; the operating system 4021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application 4022 can include various applications, such as a media player (Media Player), a browser (Browser), etc., for implementing various application services. The method provided by the embodiment of the present invention can be included in the application 4022.
[0066] The method disclosed in the above embodiment of the present invention can be applied to the processor 401, or implemented by the processor 401. The processor 401 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 401 or the instruction in the form of software. The above processor 401 may be a general processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 401 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general processor 401 may be a microprocessor or any conventional processor, etc. In combination with the steps of the accessory optimization method provided in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0067] In an exemplary embodiment, the electronic terminal 400 may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD) to execute the aforementioned method.
[0068] The terms "component", "module", "system", etc. used in this specification are used to represent computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program and / or a computer. By way of illustration, both applications running on a computing device and a computing device can be components. One or more components may reside in a process and / or an execution thread, and a component may be located on a computer and / or distributed between two or more computers. In addition, these components may be executed from various computer-readable media having various data structures stored thereon. Components may, for example, communicate through local and / or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component between a local system, a distributed system and / or a network, such as the Internet interacting with other systems through signals).
[0069] Those of ordinary skill in the art will appreciate that the various illustrative logical blocks and steps described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or in a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0070] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0071] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0072] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0073] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0074] In the above embodiments, the functions of each functional unit can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions (programs). When loading and executing computer program instructions (programs) on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that contains one or more available media integrations. Available media may be magnetic media (e.g., floppy disks, hard disks, tapes), optical media (e.g., high-density digital video discs (DVDs), or semiconductor media (e.g., solid state disks (SSDs), etc.).
[0075] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0076] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0077] In summary, the present invention effectively overcomes various shortcomings of the prior art and has high industrial utilization value.
[0078] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A machine vision detection method for printed circuit defects, characterized in that: The following steps are involved: Acquire a circuit image and a template image; The contrast of the circuit image is enhanced using an emphasize function; wherein the neighborhood average value of each pixel in the circuit image is calculated by mean filtering, and the brightness difference between the neighborhood average value and its corresponding original value is amplified; Extracting feature points of the template image and the contrast-enhanced circuit image, aligning the template image to the circuit image using an affine transformation matrix, and extracting an analysis area to be analyzed according to the defect type to be detected; wherein the defect type to be detected includes printing omission and overprinting; The target area is obtained by performing threshold segmentation on the analysis area using the var_threshold function; Use the opening_circle function to open the target area; The connected areas in the target area after the opening operation are extracted, and the area threshold corresponding to each of the connected areas is calculated according to a preset process accuracy calculation method. In combination with the defect type to be detected, the area of the connected area is compared with the corresponding area threshold to obtain the detection result.
2. A machine vision detection method for printed circuit defects according to claim 1, characterized in that: After acquiring the circuit image and before contrast enhancement of the circuit image, the method further includes the following steps: It is determined whether the circuit in the circuit image is complete. If the circuit is incomplete, several circuit images corresponding to the same product are spliced together to obtain a circuit image with a complete circuit.
3. The machine vision detection method for printed circuit defects according to claim 1, characterized in that: The step of extracting the analysis area to be analyzed according to the defect type to be detected comprises the following steps: When the defect type to be detected is printing omission, a bright area in a matching area in the circuit image after contrast enhancement that matches the template image is extracted as an analysis area.
4. The method for machine vision inspection of printed circuit defects according to claim 1, characterized in that: The step of extracting the analysis area to be analyzed according to the defect type to be detected comprises the following steps: When the defect type to be detected is overprinting, the dark area in the matching area that matches the template image in the circuit image after contrast enhancement is first extracted, the dark area is expanded using a circular structure to obtain an expanded area, and the area obtained by subtracting the dark area from the expanded area point by point is used as the analysis area.
5. The method for machine vision inspection of printed circuit defects according to claim 1, characterized in that: The step of obtaining the target area after performing threshold segmentation on the analysis area comprises the following steps: determining whether the ambient light in the circuit image is stable; When the ambient light is stable, the target area is extracted after global threshold segmentation is performed on the analysis area; wherein the global threshold segmentation is segmentation according to the maximum and minimum grayscales, and after comparing the grayscale value of each pixel with the set maximum and minimum grayscales, the bright area between the maximum and minimum grayscales is extracted as the target area; When the ambient light is unstable, the analysis area is subjected to local threshold segmentation and then the target area is extracted; wherein, the local threshold segmentation is to use a var_threshold function to scan a binary mask on each pixel point, and the grayscale of the pixel point is compared with the standard deviation grayscale of the mask center to extract the dark area as the target area.
6. The method for machine vision inspection of printed circuit defects according to claim 1, characterized in that: In combination with the defect type to be detected, the detection result is obtained by comparing the area of the connected region with the corresponding area threshold, including the following steps: When the defect type to be detected is printing omission, when the area of the connected region is greater than the area threshold, there is a printing omission defect; When the defect type to be detected is overprinting, when the area of the connected region is greater than the area threshold, an overprinting defect exists.
7. A machine vision inspection system for printed circuit defects, characterized in that: include: An image acquisition module, used to acquire a circuit image and a template image; An image processing and analysis module is used to enhance the contrast of the circuit image using the emphasize function; wherein, the neighborhood average value of each pixel in the circuit image is calculated by mean filtering, and the brightness difference between the neighborhood average value and its corresponding original value is amplified; feature points of the template image and the circuit image after contrast enhancement are extracted, the template image is aligned to the circuit image using an affine transformation matrix, and the analysis area to be analyzed is extracted according to the defect type to be detected; wherein the defect type to be detected includes printing omission and overprinting; the analysis area is threshold-segmented using the var_threshold function to obtain a target area; the target area is opened using the opening_circle function; the connected area in the target area after the opening operation is extracted, and the area threshold corresponding to each of the connected areas is calculated according to a preset process accuracy calculation method, and the area of the connected area is compared with the corresponding area threshold in combination with the defect type to be detected to obtain a detection result.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. A computer program product, characterized in that The computer program product includes a computer program code, and when the computer program code is executed on a computer, the computer is enabled to implement the method as described in any one of claims 1 to 6.
10. An electronic terminal comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the method according to any one of claims 1 to 6.
Citation Information
Cited By
Battery defect detection method and system based on multi-mode sensor
CN120213952A
Circuit board drilling detection method, intelligent terminal and computer readable storage medium
CN120672656A
Label defect detection system and method based on image processing
CN120672671A
Defect detection method for reticle mask
CN120722650A
Dynamic partition refreshing method and system for global display of layout file, medium, program product and terminal
CN120724928A