CN117635608B - Hole deviation defect detection method, device, equipment and storage medium - Google Patents

Hole deviation defect detection method, device, equipment and storage medium Download PDF

Info

Publication number
CN117635608B
CN117635608B CN202410095442.2A CN202410095442A CN117635608B CN 117635608 B CN117635608 B CN 117635608B CN 202410095442 A CN202410095442 A CN 202410095442A CN 117635608 B CN117635608 B CN 117635608B
Authority
CN
China
Prior art keywords
hole
edge
image
round hole
point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410095442.2A
Other languages
Chinese (zh)
Other versions
CN117635608A (en
Inventor
请求不公布姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shencun Technology Wuxi Co ltd
Original Assignee
Shencun Technology Wuxi Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shencun Technology Wuxi Co ltd filed Critical Shencun Technology Wuxi Co ltd
Priority to CN202410095442.2A priority Critical patent/CN117635608B/en
Publication of CN117635608A publication Critical patent/CN117635608A/en
Application granted granted Critical
Publication of CN117635608B publication Critical patent/CN117635608B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The application relates to a hole deviation defect detection method, a device, equipment and a storage medium, which are applied to the field of computer vision, wherein the method comprises the following steps: recognizing a round hole area in the round hole image, and generating an image to be detected according to the round hole area; determining rough hole contours and corresponding round hole edge points in an image to be detected; performing circular contour fitting operation on the circular hole edge points to obtain middle hole contours corresponding to the circular hole edge points, and correcting the middle hole contours to obtain target hole contours; determining an insulating layer edge point, and calculating the minimum distance between the insulating layer edge point and a round hole edge point in the outline of the target hole; and comparing the minimum distance with a preset first threshold value, and if the minimum distance is smaller than the preset first threshold value, determining that the hole deviation defect exists in the hole image. The technical effect that this application had is: the method relieves the misjudgment condition of the prior art under the condition of shadow and other interference, and greatly improves the accuracy of hole deviation defect detection.

Description

Hole deviation defect detection method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of computer vision, and in particular, to a method, an apparatus, a device, and a storage medium for detecting hole deviation defects.
Background
A Printed Circuit Board (PCB) is one of key components of an electronic product, the quality and performance of which are directly related to the reliability and stability of the whole electronic device, and in the PCB manufacturing process, drilling is an important channel connecting circuits of different levels, however, due to factors such as a production process, equipment precision, and the like, hole deviation defects may occur, mainly including two aspects of deviation of hole positions and hole deletion, and the existence of the hole deviation defects directly affects the functions and performance of the PCB, so it becomes important to discover and accurately detect the hole deviation defects early in the PCB manufacturing process.
For the detection of hole deviation defects, an edge detection technology is generally adopted, firstly, gray level and smooth processing is carried out on a color image, and then an edge detection algorithm such as Sobel, prewitt, canny is adopted to highlight the hole edges in the image; the structure of the hole is further emphasized through binarization and morphological treatment, and a circular structure in the image is detected through Hough circle transformation; finally, the test results are analyzed and compared with the design specifications to identify deviations, deletions or other shape anomalies of the holes, providing accurate feedback and recording of the production process.
However, due to the influence of factors such as illumination, shadow areas with different degrees possibly exist around the round hole, so that redundant edges appear, the round hole edges cannot be effectively distinguished and filtered out from a plurality of edges by directly applying the existing edge detection technology, and further, the work such as circle fitting and edge distance measuring and calculating cannot be accurately performed, so that the accuracy of hole deviation defect detection is low.
Disclosure of Invention
In order to improve the accuracy of hole deviation defect detection, the application provides a hole deviation defect detection method, device and equipment and a storage medium.
In a first aspect, the present application provides a hole deviation defect detection method, which adopts the following technical scheme: the method comprises the following steps:
acquiring a round hole image, identifying a round hole area in the round hole image, and generating an image to be detected according to the round hole area;
extracting a rough hole outline in the image to be detected, and determining a round hole edge point corresponding to the rough hole outline;
performing circular contour fitting operation on the circular hole edge points to obtain middle hole contours corresponding to the circular hole edge points, and correcting the middle hole contours to obtain target hole contours;
determining an insulating layer edge point, and calculating the minimum distance between the insulating layer edge point and a round hole edge point in the outline of the target hole;
and comparing the minimum distance with a preset first threshold value, and if the minimum distance is smaller than the preset first threshold value, determining that the hole deviation defect exists in the hole image.
In a specific embodiment, the identifying the circular hole area in the circular hole image, and generating the image to be detected according to the circular hole area includes:
sequentially executing dynamic binarization operation and closing operation on the image to be detected, and converting the image to be detected into a binary image;
confirming the circle center and the radius of a round hole in the binary diagram, and determining a round hole area by combining the circle center and the radius of the round hole;
and generating a minimum circumscribed rectangle corresponding to the round hole area, and cutting out an image to be detected according to the area where the minimum circumscribed rectangle is located.
In a specific embodiment, the extracting the rough hole profile in the image to be detected comprises:
obtaining a filtered image by executing bilateral filtering operation on the image to be detected;
sequentially performing Canny edge detection operation and edge filtering operation on the filtered image to obtain a first round hole edge;
sequentially performing Canny edge detection operation and edge filtering operation on the image to be detected to obtain a second round hole edge;
and generating a rough hole outline corresponding to the image to be detected by sequentially performing difference analysis and connected domain analysis on the first round hole edge and the second round hole edge.
In a specific embodiment, the generating the rough hole profile corresponding to the image to be detected by sequentially performing the difference analysis and the connected domain analysis on the first hole edge and the second hole edge includes:
determining a difference circular hole edge based on the difference pixel points of the first circular hole edge and the second circular hole edge;
performing connected domain analysis operation on the first round hole edge and the difference round hole edge, and supplementing the difference round hole edge into the first round hole edge to obtain a combined round hole edge;
and performing a circular contour fitting operation on the edges of the combined circular holes to obtain rough hole contours corresponding to the images to be detected.
In a specific embodiment, the determining the round hole edge point corresponding to the rough hole profile includes:
each pixel point on the rough hole contour is determined to be a datum point, and a preset pixel window around the datum point is determined to be a search area corresponding to the datum point;
calculating the gray value of each pixel point in the search area and the gradient value of each pixel point along the radial direction of the round hole;
if the gradient value corresponding to the target pixel point exceeds a preset second threshold value and the gray value of the pixel point adjacent to the target pixel point is not smaller than a preset third threshold value, determining the target pixel point as a round hole edge point.
In a specific embodiment, said modifying said intermediate hole profile to obtain a target hole profile comprises:
determining pixel points where the upper, lower, left and right sides of the middle hole outline are located as reference boundaries;
respectively calculating a first average gray value of the reference boundary, and a second average gray value of a pixel edge adjacent to the reference boundary and close to the circle center direction of the round hole;
if the second average gray value is larger than the first average gray value, performing an outward expansion operation on the reference boundary until the average gray value of the reference boundary after outward expansion is reduced to exceed a preset fourth threshold;
if the second average gray value is smaller than the first average gray value, performing a shrinking operation on the reference boundary until the average gray value of the reference boundary after shrinking rises to exceed a preset fifth threshold value;
and determining the middle hole profile after the expansion operation or the contraction operation is performed as a target hole profile.
In a specific embodiment, the determining the insulation layer edge point includes:
generating a plurality of matrix masks corresponding to the round hole edge points based on a pixel matrix with a preset size;
and traversing pixel points positioned outside the outline of the target hole in the matrix mask, and determining the edge pixel points as insulating layer edge points if the edge pixel points with gray values smaller than a preset sixth threshold value exist.
In a second aspect, the present application provides a hole deviation defect detection device, which adopts the following technical scheme: the device comprises:
the detection image acquisition module is used for acquiring a round hole image, identifying a round hole area in the round hole image and generating an image to be detected according to the round hole area;
the rough contour extraction module is used for extracting rough hole contours in the image to be detected and determining round hole edge points corresponding to the rough hole contours;
the target contour obtaining module is used for obtaining a middle hole contour corresponding to the round hole edge point by executing round contour fitting operation on the round hole edge point, and correcting the middle hole contour to obtain a target hole contour;
the minimum distance calculation module is used for determining an insulating layer edge point and calculating the minimum distance between the insulating layer edge point and a round hole edge point in the outline of the target hole;
and the hole deviation defect determining module is used for comparing the minimum distance with a preset first threshold value, and determining that the hole deviation defect exists in the circular hole image if the minimum distance is smaller than the preset first threshold value.
In a third aspect, the present application provides a computer device, which adopts the following technical scheme: comprises a memory and a processor, wherein the memory stores a computer program which can be loaded by the processor and execute any hole deviation defect detection method.
In a fourth aspect, the present application provides a computer readable storage medium, which adopts the following technical solutions: a computer program capable of being loaded by a processor and executing any one of the hole deviation defect detection methods described above is stored.
In summary, the present application has the following beneficial technical effects:
according to the scheme, a plurality of steps are comprehensively utilized, including the steps of obtaining and generating an image to be detected, extracting a rough hole outline, fitting and correcting a circular outline, calculating the distance of the edge point of the insulating layer, and capturing and describing the shape of the circular hole more accurately through the fitting and correcting of the circular outline; by considering the minimum distance between the edge point of the insulating layer and the edge point of the round hole, the method has more robustness for detecting the hole deviation defect, and can improve the detection accuracy in a more complex environment; through carrying out multi-level analysis and correction to the round hole, not only improved the reduction precision to the round hole shape, considered the distance relation of insulating layer border point moreover, alleviated the erroneous judgement condition that uses prior art to appear under the interference condition such as existence shadow, promoted the accuracy of hole deviation defect detection greatly.
Drawings
Fig. 1 is a flowchart of a method for detecting hole deviation defects in an embodiment of the present application.
Fig. 2 is a schematic diagram for explaining generation of an image to be detected in the embodiment of the present application.
Fig. 3 is a schematic diagram for explaining generation of a rough circular contour in the embodiment of the present application.
Fig. 4 is a schematic diagram for explaining finding a round hole edge point in the embodiment of the present application.
Fig. 5 is a schematic diagram for illustrating circular hole edge point fitting in an embodiment of the present application.
Fig. 6 is a schematic diagram for explaining the adjustment of the contour of the middle hole in the embodiment of the present application.
Fig. 7 is a schematic diagram for explaining finding an edge point of an insulating layer in the embodiment of the present application.
Fig. 8 is a block diagram of a hole deviation defect detection device in an embodiment of the present application.
Fig. 9 is a block diagram of a computer device in an embodiment of the present application.
Reference numerals: 801. a detection image acquisition module; 802. a rough contour extraction module; 803. a target profile acquisition module; 804. a minimum distance calculation module; 805. and a hole deviation defect determining module.
Detailed Description
The present application is described in further detail below in conjunction with figures 1-9.
The embodiment of the application discloses a hole deviation defect detection method which is applied to a hole deviation defect detection system, wherein the hole deviation defect detection system comprises a detection image acquisition unit for acquiring a round hole image, wherein the round hole image is a drilling image in the manufacturing process of a PCB or other electronic equipment, and the images are used for detecting and analyzing key information such as drilling quality, position and size on the PCB; kong Pian defects refer to defects or deviations in the position or size of holes on a PCB from design requirements during manufacturing, including positional deviations, dimensional deviations, shape deviations, and the like; the hole deviation defect detection system further comprises a hole deviation defect detection unit, and an execution main body of the hole deviation defect detection method disclosed by the embodiment of the application is the hole deviation defect detection unit.
As shown in fig. 1, the method comprises the steps of:
s10, acquiring a round hole image, identifying a round hole area in the round hole image, and generating an image to be detected according to the round hole area.
Specifically, a detection image acquisition unit acquires a round hole image, wherein the image contains round holes on the surface of a PCB; after the round hole image is obtained, the hole deviation defect detection unit performs image processing and analysis to identify a round hole area in the image, wherein the round hole area comprises edge detection, hough transformation and the like; once the circular hole areas are identified, the system generates images to be detected from the circular hole areas for subsequent hole deviation defect detection.
S20, extracting a rough hole outline in the image to be detected, and determining a round hole edge point corresponding to the rough hole outline.
Specifically, the rough hole contour in the image to be detected refers to preliminary edge extraction or drawing of the round holes in the image to form an approximate contour, and the system further analyzes to determine edge points of actual round holes corresponding to the contours to fit the circle most conforming to the shape of the rough contour.
S30, performing circular contour fitting operation on the circular hole edge points to obtain middle hole contours corresponding to the circular hole edge points, and correcting the middle hole contours to obtain target hole contours.
Specifically, by performing a circular contour fitting operation on the extracted circular hole edge points, a circular contour that best matches these edge points can be found; the middle hole profile is corrected by removing abnormal points, smoothing profile curves, adjusting profile shapes and the like, and the obtained target hole profile can describe the shape and position of the round hole more accurately.
S40, determining the edge point of the insulating layer, and calculating the minimum distance between the edge point of the insulating layer and the edge point of the round hole in the outline of the target hole.
Specifically, the insulating layer is a layer of insulating material on the surface of the PCB, and the edge point of the insulating layer refers to the junction point between the insulating layer and the area where the round hole is located; once the insulating layer edge points are determined, the system calculates the minimum distance between each insulating layer edge point and the circular hole edge point in the target hole profile, and then selects the minimum value from all the minimum distances as the final minimum distance.
S50, comparing the minimum distance with a preset first threshold value, and if the minimum distance is smaller than the preset first threshold value, determining that the hole deviation defect exists in the hole image.
Specifically, the first threshold is a predefined distance limit for determining whether the distance between the hole edge and the insulating layer boundary exceeds a normal range; if the minimum distance is less than a preset first threshold, indicating that the distance between the insulating layer and the hole edge is too small, there may be problems requiring further attention and inspection.
By adopting the hole deviation defect detection method and adopting advanced image processing technologies such as edge detection, hough transformation and the like, the system can rapidly and accurately identify the round hole area in the PCB image, and provide high-quality images to be detected for subsequent hole deviation defect detection; by extracting the rough hole profile, fitting the circular profile and correcting the middle hole profile, the target hole profile generated by the system is more accurate and smooth, and a reliable basis is provided for subsequent defect detection; by calculating the minimum distance between the hole edge point and the insulating layer edge point, the system can more comprehensively consider the relation between the hole and the insulating layer, so that whether the hole deviation defect exists or not can be judged more accurately; by introducing an automatic decision mechanism, the system can make decisions in real time when the hole deviation defect is detected, so that the detection speed is greatly improved, and the system is beneficial to realizing instant production control and adjustment.
In one embodiment, to help improve the efficiency and accuracy of subsequent hole deviation defect detection, the step of identifying a hole region in the hole image, and generating an image to be detected from the hole region may be specifically performed as:
firstly, performing dynamic binarization operation on a circular hole image to determine whether each pixel belongs to a target area, then performing closed operation on the obtained binary image, filling and connecting holes in the image to enable the target area to be more complete, and converting the circular hole image into the binary image through binarization and closed operation as shown in fig. 2; in the binary diagram, circle center and circle radius of a round hole corresponding to the round hole in the binary diagram are confirmed by using Hough circle detection, and the accurate position and the size of the round hole can be determined by combining the circle center and the circle radius obtained by Hough circle detection, so that the round hole area where the round hole is located is determined; and generating a minimum circumscribed rectangle corresponding to the round hole area, namely, a minimum rectangle surrounding the whole round hole, attaching the boundary of the minimum circumscribed rectangle to the round hole, cutting out an image to be detected from the original image according to the minimum circumscribed rectangle, and ensuring that the image to be detected only contains information related to the round hole.
It should be noted that, when the hough circle detection does not detect a circle, the threshold value of the circle center accumulator in the hough circle detection (the super parameter in the hough circle detection is reduced, and the number of detected circles can be increased) can be reduced to perform detection again; when a plurality of results appear in the circle detection, traversing each detected circle, taking each circle as a mask, counting the average gray value in each circle, and selecting the circle with the largest average gray value in the circle as the result of Hough circle detection.
The dynamic binarization in the embodiment is a method for determining a binarization threshold according to the local characteristics of an image, and compared with a static threshold, the dynamic binarization can be better adapted to illumination and contrast changes of different areas in the image, so that the adaptability to complex images is improved; the closed operation is helpful for filling the cavity in the image and connecting the target area in the image, so that the target area is more complete, and the stability and accuracy of the subsequent processing steps are improved; through Hough circle detection, the system can accurately determine the position and the radius of the round hole, and important information is provided for the subsequent determination of the round hole area; the minimum circumscribed rectangle corresponding to the round hole area is generated, so that the finally cut image to be detected is ensured to more compactly contain round holes, and the efficiency and the accuracy of the follow-up hole deviation defect detection are improved.
In one embodiment, to provide a more reliable basis for subsequent hole deviation defect detection, the step of extracting the rough hole profile in the image to be detected may be specifically performed as:
obtaining a filtered image by executing bilateral filtering operation on the image to be detected; as shown in fig. 3, a Canny edge detection operation and an edge filtering operation are sequentially performed on a filtered image, namely, firstly, the Canny edge detection is used for extracting edges of the filtered image, then, four points of an upper point, a lower point, a left point and a right point of each edge point are searched, and once the average gray value of the points around the current edge point is smaller than a threshold value, the edge point is regarded as an edge of an insulating layer and is filtered, so that a first circular hole edge is obtained by utilizing the characteristic that the brightness of pixels around a circular hole boundary is large and the brightness of pixels around an insulating layer boundary is small; because the influence of redundant edges is reduced by using bilateral filtering on one hand, and part of round hole edges are lost on the other hand, canny edge detection operation and edge filtering operation are performed on the image to be detected before filtering in the same way, and a second round hole edge is obtained; the method comprises the steps of sequentially executing differential analysis and connected domain analysis on the first round hole edge and the second round hole edge, calculating the differential round hole edge of the first round hole edge and the second round hole edge, performing connected domain analysis on the differential round hole edge and the first round hole edge, supplementing four connected regions in the differential round hole edge into the filtered first round hole edge, further improving fitting accuracy, and finally performing circular contour fitting on the boundary output in the process to generate a rough hole contour corresponding to an image to be detected.
According to the embodiment, the bilateral filtering considers the space and gray information in the filtering process, so that edge details in an image can be reserved, the influence of redundant information is reduced, and the accuracy of subsequent edge detection can be improved; the first and second round hole edges are effectively extracted by means of Canny edge detection and edge filtering operation, and the insulation layer edges are filtered out by considering the brightness characteristics of surrounding pixels, so that the accuracy of the hole edges is improved; by carrying out difference analysis and connected domain analysis on the edges of the first round hole and the second round hole, the change between the edges of the two round holes can be captured, so that the fitting precision is improved; finally, the output boundary is subjected to circular contour fitting, so that a rough hole contour can be generated, the formation of a hole contour with continuity and smoothness is facilitated, and a more reliable basis is provided for subsequent hole deviation defect detection.
In one embodiment, in order to provide a more reliable basis for subsequent hole deviation defect detection, by sequentially performing differential analysis and connected domain analysis on the first circular hole edge and the second circular hole edge, the step of generating a rough hole profile corresponding to the image to be detected may be specifically performed as follows:
performing difference analysis between the first round hole edge and the second round hole edge, finding out difference pixel points of the first round hole edge and the second round hole edge, and determining a difference round hole edge based on the difference pixel points of the first round hole edge and the second round hole edge; identifying a pixel set, namely a connected domain, which is connected with each other in the first round hole edge and the difference round hole edge by executing connected domain analysis operation on the first round hole edge and the difference round hole edge; supplementing the result of the difference value round hole edge through the connected domain analysis to the first round hole edge to obtain a combined round hole edge; and (3) performing a circular contour fitting operation on the edges of the combined circular holes to obtain rough hole contours corresponding to the images to be detected, and generating a smoother and more compact hole contour so as to facilitate subsequent hole deviation defect detection.
Through the embodiment, the system can find out the difference pixel points of the first round hole edge and the second round hole edge by carrying out difference analysis between the two round hole edges, and the accurate difference analysis is helpful for capturing small changes between the edges, so that high-quality input is provided for subsequent hole contour combination; the connected domain analysis is used for identifying pixel sets connected with each other in the edges of the difference round holes, namely the connected domain, so that adjacent difference areas can be combined to form larger difference areas, and more comprehensive information is provided for subsequent edge merging; the system realizes the combination of edges by supplementing the result of the analysis of the difference value round hole edge through the connected domain into the first round hole edge, and the process can treat the irregularity of the hole edge to form smoother and more compact rough hole outline, thereby improving the accuracy of the whole outline; and finally, performing circular contour fitting operation on the combined circular hole edges to generate a smoother and more compact hole contour, and providing a more reliable basis for subsequent hole deviation defect detection.
In one embodiment, to help improve accuracy and stability of hole deviation defect detection, the step of determining the round hole edge points corresponding to the rough hole profile may be specifically performed as follows:
determining each pixel point on the rough hole contour as a reference point, and determining a preset pixel window around the reference point as a search area corresponding to the reference point, wherein for each reference point, searching is performed within a range of 2 pixels in the upward, downward, left, right and diagonal directions, as shown in fig. 4, a left rectangular frame area of the figure is a search range for a single round hole boundary point, and a right rectangular frame area of the figure is a sum of the search ranges after all round hole boundaries are traversed; calculating the gray value of each pixel point in the search area and the gradient value of each pixel point along the radial direction of the round hole; if the gradient value corresponding to the target pixel point exceeds the preset second threshold value and the gray value of the pixel point adjacent to the target pixel point is not smaller than the preset third threshold value, determining the target pixel point as a round hole edge point, finally obtaining all round hole edge points shown in the leftmost side of fig. 5, and facilitating the fitting of the round outline to obtain the middle hole outline.
Through the embodiment, each datum point is searched in the up, down, left, right and diagonal directions, the system can comprehensively cover the possible positions of the round hole edge points, comprehensive detection of the edge points is increased, and the capturing of edge changes in different directions is facilitated; the situation that a plurality of round holes are possibly close to each other is considered, comprehensive search of edge points of the plurality of holes is ensured, and robustness of the system is enhanced; by comprehensively utilizing the gray value of each pixel point in the search area and the gradient value along the radial direction of the round hole, the system can more accurately judge whether the target pixel point exists or not, and whether the point meets the condition of the round hole edge point or not, so that the judgment precision of the edge point is improved; through a preset second threshold value and a preset third threshold value, the system screens the gradient value and the gray value of the adjacent pixels, and only the target pixel points meeting the conditions are determined to be round hole edge points, so that the algorithm is more adjustable due to the setting of the threshold values, the characteristics of different images are adapted, and the accuracy and the stability of hole deviation defect detection are improved.
In one embodiment, to enable the system to flexibly correct the middle hole profile according to the actual situation of the image, the step of obtaining the target hole profile may be specifically performed as:
since part of the circular holes are elliptical, the rough hole profile needs to be modified. Determining pixel points where the upper, lower, left and right sides of the middle hole outline are located as reference boundaries; respectively calculating a first average gray value of a reference boundary and a second average gray value of a pixel edge adjacent to the reference boundary and close to the circle center direction of the round hole; if the second average gray value is larger than the first average gray value, performing the outward expansion operation on the reference boundary until the average gray value of the outward expanded reference boundary is reduced to exceed a preset fourth threshold value; if the second average gray value is smaller than the first average gray value, performing the shrinking operation on the reference boundary until the average gray value of the shrunk reference boundary rises to exceed a preset fifth threshold value; as shown in fig. 6, a1 and b1 are two reference boundaries on the left side and the upper side of the rough hole outline, a2 is a pixel edge adjacent to a1 and close to the circle center direction of the round hole, b2 is a pixel edge adjacent to b1 and close to the circle center direction of the round hole, average gray values of the reference boundaries a1 and b1 are calculated, average gray values of the reference boundaries adjacent to a2 and b2 are calculated, the average gray value of a2 is smaller than the average gray value of a1, the average gray value of b2 is larger than the average gray value of b1, a distance corresponding to a pixel point is contracted into a position where a2 is located, b1 is expanded outwards by a distance corresponding to a pixel point to a position where b3 is located until a2 and b3 meet the requirement of a threshold value; and determining the middle hole profile after the expansion operation or the contraction operation is performed as a target hole profile.
According to the embodiment, partial round holes possibly present in an elliptical shape are considered, the system corrects the upper, lower, left and right sides of the outline of the rough hole so as to better adapt to the hole with the elliptical shape, the adaptability of the system to the hole with the irregular shape is improved, and the accuracy of the detection of the integral hole deviation defect is improved; the average gray value of the reference boundary and the average gray value of the adjacent boundary are used for judging to determine whether to perform expansion or contraction, and the brightness change of different areas in the image is considered, so that the correction operation can be performed more accurately; when the expansion or contraction operation is carried out, the system sets a preset fourth threshold value and a preset fifth threshold value by monitoring the change of the average gray value, so that the system can control the correction degree according to the change of the gray value difference, the sensitivity to the gray change is increased, and the correction precision is improved; the termination condition of the correction operation considers the condition that the average gray value falls or rises above a preset fourth threshold value or the condition that the average gray value rises above a preset fifth threshold value, or the correction distance reaches the distance corresponding to the preset number of pixel points, so that the system can flexibly correct according to the actual condition of the image, and the robustness of the system is improved.
In one embodiment, in order to efficiently determine edge pixel points outside the target hole profile, the step of determining the insulating layer edge points may be specifically performed as:
generating a plurality of matrix masks corresponding to the round hole edge points based on a pixel matrix with a preset size; traversing pixel points outside the outline of the target hole in the matrix mask, and determining the edge pixel points as insulating layer edge points if the edge pixel points with gray values smaller than a preset sixth threshold value exist; as shown in fig. 7, c is a round hole edge point, a black frame in the left graph is a matrix mask, pixel points located outside the outline of the target hole are traversed in the matrix mask, the gray value of the calculated pixel points is compared with a preset sixth threshold, a pixel point (such as a d pixel point) with the gray value smaller than the preset sixth threshold is determined as an edge pixel point corresponding to the matrix mask, and among all the edge pixel points, the e point is an edge point of an insulating layer closest to the round hole, and the minimum distance between the e point and the boundary of the round hole is 1 pixel point.
Through the embodiment, the pixel matrix with the preset size is generated, the concept of a matrix mask is innovatively introduced, and the application of the matrix mask enables a system to search the pixel points outside the outline of the target hole in an organized manner instead of carrying out unordered search on the whole image, so that the searching efficiency is improved; when traversing the pixel points outside the outline of the target hole in the matrix mask, the system determines the pixel points meeting the conditions as the edge points of the insulating layer by judging whether the gray value is smaller than a preset sixth threshold value, and accurately filters the edge pixel points, so that only the pixel points with enough obvious gray change are identified as the edge points; the system can adapt to the gray characteristics of different images by dynamically adjusting the sixth threshold, so that the adaptability of the system to the image difference is improved, and the robustness of the algorithm is improved; by orderly searching in the matrix mask, the system can more efficiently determine edge pixel points outside the outline of the target hole.
FIG. 1 is a flow chart of a method for detecting hole deviation defects in an embodiment. It should be understood that, although the steps in the flowchart of fig. 1 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows; the steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders; and at least a portion of the steps of fig. 1 may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor does the order in which the sub-steps or stages are performed necessarily occur in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
Based on the method, the embodiment of the application also discloses a hole deviation defect detection device.
Referring to fig. 8, the apparatus includes the following modules:
a detection image acquisition module 801, configured to acquire a circular hole image, identify a circular hole area in the circular hole image, and generate an image to be detected according to the circular hole area;
a rough contour extraction module 802, configured to extract a rough hole contour in an image to be detected, and determine a round hole edge point corresponding to the rough hole contour;
the target contour obtaining module 803 is configured to obtain a middle hole contour corresponding to the round hole edge point by performing a round contour fitting operation on the round hole edge point, and correct the middle hole contour to obtain a target hole contour;
the minimum distance calculating module 804 is configured to determine an edge point of the insulating layer, and calculate a minimum distance between the edge point of the insulating layer and an edge point of a circular hole in the outline of the target hole;
and the hole deviation defect determining module 805 is configured to compare the minimum distance with a preset first threshold, and determine that the hole deviation defect exists in the hole image if the minimum distance is smaller than the preset first threshold.
In one embodiment, the detection image obtaining module 801 is specifically configured to sequentially perform a dynamic binarization operation and a closed operation on an image to be detected, and convert the image to be detected into a binary image; confirming the circle center and the radius of a round hole in the binary diagram, and determining a round hole area by combining the circle center and the radius of the round hole; and generating a minimum circumscribed rectangle corresponding to the round hole area, and cutting out an image to be detected according to the area where the minimum circumscribed rectangle is located.
In one embodiment, the rough contour extraction module 802 is specifically configured to obtain a filtered image by performing a bilateral filtering operation on an image to be detected; sequentially executing Canny edge detection operation and edge filtering operation on the filtered image to obtain a first round hole edge; sequentially executing Canny edge detection operation and edge filtering operation on the image to be detected to obtain a second round hole edge; and generating a rough hole profile corresponding to the image to be detected by sequentially performing difference analysis and connected domain analysis on the first hole edge and the second hole edge.
In one embodiment, the rough contour extraction module 802 is specifically configured to determine a difference circular hole edge based on a difference pixel point of the first circular hole edge and the second circular hole edge; performing connected domain analysis operation on the first round hole edge and the difference round hole edge, and supplementing the difference round hole edge into the first round hole edge to obtain a combined round hole edge; and (3) performing a circular contour fitting operation on the edges of the combined circular holes to obtain rough hole contours corresponding to the images to be detected.
In one embodiment, the rough contour extraction module 802 is specifically configured to determine each pixel point on the rough hole contour as a reference point, and determine a preset pixel window around the reference point as a search area corresponding to the reference point; calculating the gray value of each pixel point in the search area and the gradient value of each pixel point along the radial direction of the round hole; if the gradient value corresponding to the target pixel point exceeds the preset second threshold value and the gray value of the pixel point adjacent to the target pixel point is not smaller than the preset third threshold value, determining the target pixel point as a round hole edge point.
In one embodiment, the target profile obtaining module 803 is specifically configured to determine, as a reference boundary, a pixel point where four edges of the middle hole profile are located; respectively calculating a first average gray value of a reference boundary and a second average gray value of a pixel edge adjacent to the reference boundary and close to the circle center direction of the round hole; if the second average gray value is larger than the first average gray value, performing the outward expansion operation on the reference boundary until the average gray value of the outward expanded reference boundary is reduced to exceed a preset fourth threshold value; if the second average gray value is smaller than the first average gray value, performing the shrinking operation on the reference boundary until the average gray value of the shrunk reference boundary rises to exceed a preset fifth threshold value; and determining the middle hole profile after the expansion operation or the contraction operation is performed as a target hole profile.
In one embodiment, the minimum distance calculating module 804 is specifically configured to generate a plurality of matrix masks corresponding to edge points of the circular hole based on a pixel matrix with a preset size; and traversing the pixel points outside the outline of the target hole in the matrix mask, and determining the edge pixel points as insulating layer edge points if the edge pixel points with gray values smaller than a preset sixth threshold value exist.
The hole deviation defect detection device provided in the embodiment of the present application may be applied to the hole deviation defect detection method provided in the above embodiment, and the relevant details refer to the above method embodiment, and the implementation principle and the technical effect are similar, and are not repeated here.
It should be noted that: in the hole deviation defect detection device provided in the embodiment of the present application, only the above-mentioned division of each functional module/functional unit is used for illustration when hole deviation defect detection is performed, and in practical application, the above-mentioned function allocation may be completed by different functional modules/functional units according to needs, i.e. the internal structure of the hole deviation defect detection device is divided into different functional modules/functional units, so as to complete all or part of the above-mentioned functions. In addition, the implementation manner of the hole deviation defect detection method provided by the above method embodiment and the implementation manner of the hole deviation defect detection device provided by the present embodiment belong to the same concept, and the specific implementation process of the hole deviation defect detection device provided by the present embodiment is detailed in the above method embodiment, and is not repeated here.
The embodiment of the application also discloses a computer device.
Specifically, as shown in fig. 9, the computer device may be a desktop computer, a notebook computer, a palm computer, a cloud server, or the like. The computer device may include, but is not limited to, a processor and a memory. Wherein the processor and the memory may be connected by a bus or other means. The processor may be a central processing unit (Central Processing Unit, CPU). The processor may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, graphics processors (Graphics Processing Unit, GPU), embedded Neural network processors (Neural-network Processing Unit, NPU) or other specialized deep learning coprocessors, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above.
The memory is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the methods in the above embodiments of the present application. The processor executes various functional applications of the processor and data processing, i.e., implements the methods of the method embodiments described above, by running non-transitory software programs, instructions, and modules stored in memory. The memory may include a memory program area and a memory data area, wherein the memory program area may store a control unit, at least one application program required for a function; the storage data area may store data created by the processor, etc. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some implementations, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The embodiment of the application also discloses a computer readable storage medium.
Specifically, the computer readable storage medium is configured to store a computer program, which when executed by a processor, implements the method in the above-described method embodiments. It will be appreciated by those skilled in the art that implementing all or part of the processes in the methods of the embodiments described above may be implemented by a computer program to instruct related hardware, and the program may be stored in a computer readable storage medium, and the program may include the processes of the embodiments of the methods described above when executed. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a Flash Memory (Flash Memory), a Hard Disk (HDD), or a Solid State Drive (SSD); the storage medium may also comprise a combination of memories of the kind described above.
The present embodiment is only for explanation of the present invention and is not to be construed as limiting the present invention, and modifications to the present embodiment, which may not creatively contribute to the present invention as required by those skilled in the art after reading the present specification, are all protected by patent laws within the scope of claims of the present invention.

Claims (8)

1. A method for detecting hole deviation defects, the method comprising:
acquiring a round hole image, identifying a round hole area in the round hole image, and generating an image to be detected according to the round hole area;
extracting a rough hole outline in the image to be detected, and determining a round hole edge point corresponding to the rough hole outline;
performing circular contour fitting operation on the circular hole edge points to obtain middle hole contours corresponding to the circular hole edge points, and correcting the middle hole contours to obtain target hole contours;
determining an insulating layer edge point, and calculating the minimum distance between the insulating layer edge point and a round hole edge point in the outline of the target hole;
comparing the minimum distance with a preset first threshold value, and if the minimum distance is smaller than the preset first threshold value, determining that the hole deviation defect exists in the hole image;
the identifying the circular hole area in the circular hole image, and generating the image to be detected according to the circular hole area comprises:
sequentially executing dynamic binarization operation and closing operation on the circular hole image, and converting the circular hole image into a binary image;
confirming the circle center and the radius of a round hole in the binary diagram, and determining a round hole area by combining the circle center and the radius of the round hole;
generating a minimum circumscribed rectangle corresponding to the round hole area, and cutting out an image to be detected according to the area where the minimum circumscribed rectangle is located;
the step of correcting the contour of the middle hole to obtain the contour of the target hole comprises the following steps:
determining pixel points where the upper, lower, left and right sides of the middle hole outline are located as reference boundaries;
respectively calculating a first average gray value of the reference boundary, and a second average gray value of a pixel edge adjacent to the reference boundary and close to the circle center direction of the round hole;
if the second average gray value is larger than the first average gray value, performing an outward expansion operation on the reference boundary until the average gray value of the reference boundary after outward expansion is reduced to exceed a preset fourth threshold;
if the second average gray value is smaller than the first average gray value, performing a shrinking operation on the reference boundary until the average gray value of the reference boundary after shrinking rises to exceed a preset fifth threshold value;
and determining the middle hole profile after the expansion operation or the contraction operation is performed as a target hole profile.
2. The method of claim 1, wherein the extracting the rough hole profile in the image to be detected comprises:
obtaining a filtered image by executing bilateral filtering operation on the image to be detected;
sequentially performing Canny edge detection operation and edge filtering operation on the filtered image to obtain a first round hole edge;
sequentially performing Canny edge detection operation and edge filtering operation on the image to be detected to obtain a second round hole edge;
and generating a rough hole outline corresponding to the image to be detected by sequentially performing difference analysis and connected domain analysis on the first round hole edge and the second round hole edge.
3. The method of claim 2, wherein the generating the rough hole profile corresponding to the image to be detected by sequentially performing a difference analysis and a connected domain analysis on the first circular hole edge and the second circular hole edge comprises:
determining a difference circular hole edge based on the difference pixel points of the first circular hole edge and the second circular hole edge;
performing connected domain analysis operation on the first round hole edge and the difference round hole edge, and supplementing the difference round hole edge into the first round hole edge to obtain a combined round hole edge;
and performing a circular contour fitting operation on the edges of the combined circular holes to obtain rough hole contours corresponding to the images to be detected.
4. The method of claim 1, wherein the determining round hole edge points corresponding to the coarse hole profile comprises:
each pixel point on the rough hole contour is determined to be a datum point, and a preset pixel window around the datum point is determined to be a search area corresponding to the datum point;
calculating the gray value of each pixel point in the search area and the gradient value of each pixel point along the radial direction of the round hole;
if the gradient value corresponding to the target pixel point exceeds a preset second threshold value and the gray value of the pixel point adjacent to the target pixel point is not smaller than a preset third threshold value, determining the target pixel point as a round hole edge point.
5. The method of claim 1, wherein determining an insulation layer edge point comprises:
generating a plurality of matrix masks corresponding to the round hole edge points based on a pixel matrix with a preset size;
and traversing pixel points positioned outside the outline of the target hole in the matrix mask, and determining the edge pixel points as insulating layer edge points if the edge pixel points with gray values smaller than a preset sixth threshold value exist.
6. An out-of-hole defect detection apparatus for implementing the out-of-hole defect detection method according to any one of claims 1 to 5, characterized in that the apparatus comprises:
a detection image acquisition module (801) for acquiring a circular hole image, identifying a circular hole area in the circular hole image, and generating an image to be detected according to the circular hole area;
a rough contour extraction module (802) for extracting a rough hole contour in the image to be detected and determining a round hole edge point corresponding to the rough hole contour;
the target contour obtaining module (803) is used for obtaining a middle hole contour corresponding to the round hole edge point by executing round contour fitting operation on the round hole edge point, and correcting the middle hole contour to obtain a target hole contour;
a minimum distance calculation module (804) for determining an insulating layer edge point, and calculating a minimum distance between the insulating layer edge point and a round hole edge point in the target hole profile;
and the hole deviation defect determining module (805) is configured to compare the minimum distance with a preset first threshold, and determine that a hole deviation defect exists in the circular hole image if the minimum distance is smaller than the preset first threshold.
7. A computer device comprising a memory and a processor, the memory having stored thereon a computer program capable of being loaded by the processor and performing the method according to any of claims 1 to 5.
8. A computer readable storage medium, characterized in that a computer program is stored which can be loaded by a processor and which performs the method according to any one of claims 1 to 5.
CN202410095442.2A 2024-01-24 2024-01-24 Hole deviation defect detection method, device, equipment and storage medium Active CN117635608B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410095442.2A CN117635608B (en) 2024-01-24 2024-01-24 Hole deviation defect detection method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410095442.2A CN117635608B (en) 2024-01-24 2024-01-24 Hole deviation defect detection method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117635608A CN117635608A (en) 2024-03-01
CN117635608B true CN117635608B (en) 2024-04-02

Family

ID=90034211

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410095442.2A Active CN117635608B (en) 2024-01-24 2024-01-24 Hole deviation defect detection method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117635608B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112504183A (en) * 2020-11-07 2021-03-16 奥士康科技股份有限公司 Hole deviation detection method
CN114998208A (en) * 2022-04-28 2022-09-02 启东旺晟电子科技有限公司 Drilling deviation detection method for PCB
CN116433701A (en) * 2023-06-15 2023-07-14 武汉中观自动化科技有限公司 Workpiece hole profile extraction method, device, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112504183A (en) * 2020-11-07 2021-03-16 奥士康科技股份有限公司 Hole deviation detection method
CN114998208A (en) * 2022-04-28 2022-09-02 启东旺晟电子科技有限公司 Drilling deviation detection method for PCB
CN116433701A (en) * 2023-06-15 2023-07-14 武汉中观自动化科技有限公司 Workpiece hole profile extraction method, device, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于RBF的人工神经网络在PCB钻孔工艺中的应用;孙远明;《中国优秀硕士论文全文数据库》》;20120715(第07期);全文 *

Also Published As

Publication number Publication date
CN117635608A (en) 2024-03-01

Similar Documents

Publication Publication Date Title
CN109242853B (en) PCB defect intelligent detection method based on image processing
CN110414507B (en) License plate recognition method and device, computer equipment and storage medium
CN113658133B (en) Gear surface defect detection method and system based on image processing
CN109325930B (en) Boundary defect detection method, device and detection equipment
CN109492642B (en) License plate recognition method, license plate recognition device, computer equipment and storage medium
CN109447117B (en) Double-layer license plate recognition method and device, computer equipment and storage medium
TW202239281A (en) Electronic substrate defect detection
CN111476804B (en) Efficient carrier roller image segmentation method, device, equipment and storage medium
CN113781406B (en) Scratch detection method and device for electronic component and computer equipment
WO2014129018A1 (en) Character recognition device, character recognition method, and recording medium
CN115018846A (en) AI intelligent camera-based multi-target crack defect detection method and device
CN112419207A (en) Image correction method, device and system
CN113240623A (en) Pavement disease detection method and device
CN115457017A (en) Wire defect detection method and device, computer equipment and storage medium
CN115272199A (en) PCB carrier plate defect detection method and system, electronic equipment and medium
CN108734709B (en) Insulator flange shape parameter identification and damage detection method
CN117635608B (en) Hole deviation defect detection method, device, equipment and storage medium
CN114627113B (en) Method, system, device and medium for detecting defects of printed circuit board
CN108898584B (en) Image analysis-based full-automatic veneered capacitor welding polarity discrimination method
CN110751623A (en) Joint feature-based defect detection method, device, equipment and storage medium
CN113378847B (en) Character segmentation method, system, computer device and storage medium
CN115809999A (en) Method and device for detecting target object on device, electronic equipment and storage medium
CN112465835B (en) Method for jadeite image segmentation and model training method
CN111932515B (en) Short circuit detection method and system for product residual defects and defect classification system
CN110580706A (en) Method and device for extracting video background model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant