Method and system for visually detecting printing defects and quantity of round adhesive labels

By combining multi-scale edge extraction with RANSAC and least squares fitting, the problems of false detection and missed detection in the detection of circular self-adhesive labels are solved, and efficient and accurate detection is achieved in complex backgrounds.

CN122115489AActive Publication Date: 2026-05-29SILICON TECH (CHENGDU) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SILICON TECH (CHENGDU) CO LTD
Filing Date
2026-04-27
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing methods for detecting circular self-adhesive labels are prone to false positives and false negatives in complex backgrounds and with interfering edges. They are also sensitive to adhesion contours and noise, resulting in unstable detection results and low efficiency.

Method used

A method combining multi-scale edge extraction, RANSAC and least squares fitting, along with circle quality evaluation and geometric constraints, is employed to eliminate false circles and duplicate detection circles, thereby improving the accuracy of the detection results.

Benefits of technology

It effectively reduces false negatives and false positives, improves detection efficiency and accuracy, can adapt to multi-scale features, cope with complex backgrounds and edge interference, and provides independent contours for subsequent analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115489A_ABST
    Figure CN122115489A_ABST
Patent Text Reader

Abstract

The application discloses a printing defect and quantity visual detection method and system of a circular adhesive label, and relates to the technical field of machine vision and industrial automatic detection. The method comprises the following steps: acquiring a label image to be detected; performing multi-scale Gaussian filtering on the label image to be detected, performing edge extraction on the Gaussian filtered image based on adaptive threshold Canny edge detection, and obtaining an edge image; dividing the edge image into connected edges, and performing connected component analysis on the edge divided edge image to obtain independent contours and edge point sets; traversing each contour point set in the edge point set, fitting each independent contour based on a RANSAC algorithm and a least square method, and obtaining a fitting result of the label; removing invalid circles and repeated detection circles based on circle quality evaluation and combined with geometric constraints, and obtaining a circle detection result; and judging whether the label image meets printing requirements based on the circle detection result, combined with preset label quantity, size range and printing position information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of machine vision and industrial automation inspection technology, specifically to a visual inspection method and system for printing defects and quantity of circular self-adhesive labels. Background Technology

[0002] In modern printed materials quality control systems, accurately counting and positioning multiple circular self-adhesive labels on the surface of a single printed surface (such as cardboard, film, or special materials) is a critical and fundamental production inspection requirement. Errors in label quantity or significant positional deviations can lead to chaos in subsequent processes such as sheet separation, quality inspection, or automated labeling, and may even cause batch production quality problems and material losses. Circular detection, as a fundamental task in industrial vision inspection, currently employs three main methods: Hough circle transform, random sampling, and contour analysis. While these methods perform well under ideal conditions, they all reveal significant inherent limitations in complex printed materials inspection.

[0003] 1. The Hough circle transform principle maps edge points in image space to a three-dimensional parameter space, and obtains the detected circle through voting accumulation and peak detection. When local adhesion or burrs occur at the label edge due to uneven die-cutting pressure, blurred or incomplete circles will be produced, making the peak in the parameter space indistinct, thus leading to missed detections. Due to the lack of semantic understanding, it is easily affected by approximate arc textures, irrelevant line segments, and noise interference under the background texture of the backing paper, generating false peaks in the parameter space, resulting in a high false detection rate. Large radius search leads to computational explosion, and fixed-scale edge detection also struggles to capture edges of different thicknesses simultaneously.

[0004] 2. Random circle detection is based on random sampling and consistency iterative optimization. In scenarios with dense label edge points and a lot of interference, a large number of non-circular edge points exist as "outer points", resulting in a very low inner point rate. This leads to a sharp increase in the algorithm's computation time and may not be able to find the correct solution within the preset number of iterations. The result is random and has limited ability to distinguish between close or concentric circles.

[0005] 3. Contour fitting obtains connected components or contours through image segmentation and edge extraction. For contours whose geometric features meet the threshold, the least squares method is used to fit circles. The premise of this method is that a complete and independent contour corresponding to a single circle can be obtained through segmentation. Slight stretching and deformation of printing materials, ink smudges or ink splatter can form sticky contours or pseudo contours. These contours participating in the fitting analysis will affect the accuracy of the results. Any noise points or positioning deviations (non-subpixel level) on the contour will directly affect the fitting results.

[0006] The root cause of these shortcomings lies in the over-reliance on the integrity and consistency of low-level features, or in the strategy of searching for the global optimum in complex data, which is inefficient and yields unstable results. Therefore, there is an urgent need for a circle detection method that can adapt to multi-scale features, effectively segment adhered contours, and robustly handle edge incompleteness and background interference. Summary of the Invention

[0007] The purpose of this invention is to provide a visual detection method and system for printing defects and quantity of circular self-adhesive labels. (1) To address the problem that Hough circle transform is prone to false detection and missed detection due to complex background and interference edges: This invention adopts multi-scale edge extraction to ensure that the edges of blurred or incomplete circles are still detected in the initial stage, reducing the possibility of missed detection; for the detected independent contours, geometric feature screening is performed in advance to reduce the false detection rate. (2) To address the problem that random circle detection is slow to converge and unstable in scenarios with dense edge points and many interferences: This invention adopts a combination of RANSAC (Random Sample Consensus) purification of interior points and least squares fitting to improve the accuracy of detection results; and for the problem of insufficient ability to distinguish between close circles or concentric circles, this invention uses circle quality evaluation and geometric constraints to eliminate false circles and duplicate detection circles in the detection results. (3) To address the problem that conventional contour fitting is sensitive to noise and the positioning error of adhered edges: In the preprocessing stage of this invention, bilateral filtering is used to smooth noise and preserve edges, and multi-scale adaptive edge extraction is used to improve edge quality and ensure that edges of different thicknesses can be extracted; and skeletonization and branch point detection are performed on the edge image to divide the adhered contours for subsequent analysis.

[0008] This invention is achieved through the following technical solution:

[0009] In a first aspect, the present invention provides a visual inspection method for printing defects and quantity of circular self-adhesive labels, the method comprising:

[0010] Obtain the image of the label to be detected;

[0011] Multi-scale Gaussian filtering is applied to the image of the label to be detected to obtain the Gaussian-filtered image; edge extraction is performed on the Gaussian-filtered image based on adaptive threshold Canny edge detection to obtain the edge image;

[0012] The edge image is segmented into contiguous edges to obtain the edge image after edge segmentation; then, connectivity analysis is performed on the edge image after edge segmentation to obtain independent contours and edge point sets.

[0013] Traverse each contour point set in the edge point set, and fit each independent contour based on the RANSAC algorithm and the least squares method to obtain the fitting results for the label; the fitting results include the center coordinates and radius;

[0014] Based on the fitting results of the labels, and using circle quality evaluation combined with geometric constraints, invalid circles and duplicate detection circles are eliminated to obtain the circle detection results;

[0015] Based on the circle detection results, combined with preset information on the number of labels, size range, and printing position, it is determined whether the label image meets the printing requirements.

[0016] Furthermore, the method also includes:

[0017] The image of the label to be detected is preprocessed to obtain a preprocessed image;

[0018] The preprocessing includes: converting the image of the label to be detected to grayscale to obtain a grayscale image; and applying bilateral filtering to the grayscale image to smooth noise and preserve edges to obtain a preprocessed image.

[0019] Furthermore, edge extraction is performed on the Gaussian-filtered image based on adaptive threshold Canny edge detection to obtain an edge image, including:

[0020] Based on local image contrast, the high and low thresholds of Canny edge detection are automatically adjusted; the high threshold is equal to the product of scale and standard deviation, and the low threshold is equal to the product of a preset multiple of scale and standard deviation, where the standard deviation is the standard deviation of the image after Gaussian filtering calculated based on OpenCV.

[0021] Based on the high and low thresholds, edge extraction is performed on the Gaussian filtered image using Canny edge detection to obtain the edge image corresponding to the current scale.

[0022] Obtain edge images at a preset scale by following the above steps, and perform multi-scale edge fusion on all edge images to obtain a multi-scale edge fused image;

[0023] Post-processing is performed on the multi-scale edge fusion image to obtain the final edge image; post-processing includes performing morphological closing operations on the multi-scale edge fusion image, connecting broken edges and filling small holes.

[0024] Furthermore, the edge image is segmented into cohesive edges to obtain a segmented edge image; and connectivity analysis is performed on the segmented edge image to obtain independent contours and edge point sets, including:

[0025] The Zhang-Suen thinning algorithm is used to extract the skeleton from the edge image to obtain the skeleton map.

[0026] For non-zero pixels in the skeleton image, perform 8-neighborhood branch point detection. For pixel positions where the number of branch points is greater than a first set threshold, segment the adhered edges at the corresponding positions in the edge image to obtain the edge image after edge segmentation.

[0027] Connectivity analysis is performed on the edge image after edge segmentation to obtain the area of ​​the connected components; contours with connected component areas smaller than a second set threshold are removed to obtain independent contours; the pixels of the independent contours are stored separately to obtain edge point sets.

[0028] Furthermore, the specific process of fitting each independent contour based on the RANSAC algorithm and the least squares method is as follows:

[0029] From a certain contour point set of the edge point set, three points are randomly selected to initialize a circle model. The RANSAC algorithm is used to iteratively calculate and find the candidate circle model with the most support points, i.e., the inner point set with the most interior points.

[0030] Using the set of interior points as a clean dataset, we perform circle fitting based on the least squares method to obtain the sub-pixel center coordinates and radius of each label, and use this as the fitting result for the current label.

[0031] Furthermore, based on the label fitting results, and using circle quality evaluation combined with geometric constraints, invalid circles and duplicate detection circles are eliminated to obtain circle detection results, including:

[0032] Based on the fitting results of the labels, the average contrast of the circular edges is calculated; when the average contrast is less than the third set threshold, the circle is determined to be an invalid circle and is removed.

[0033] Based on the fitting results of the labels, the integrity score of the circle is calculated; when the integrity score is less than the fourth set threshold, the circle is determined to be an invalid circle and is removed.

[0034] Using a double loop comparison, the outer loop traverses all circles, while the inner loop compares the current circle with other circles, calculating the center distance and radius difference. Based on the center distance and radius difference, two circles that are both close in position and similar in size are considered duplicate detection circles, and one of the duplicate detection circles is retained.

[0035] Furthermore, the expression for average contrast is:

[0036] ;

[0037] ;

[0038] ;

[0039] ;

[0040] In the formula, The average contrast is N; N is the number of edge points. is the contrast of the normal direction of the i-th edge point; g is the gradient vector at the edge point; n is the unit normal vector at the edge point; and These are the coordinates of the edge point and the current center of the circle, respectively. This represents a vector pointing from the center of the circle to the edge points. The Euclidean length of a vector is its modulus. and These are the gradient components in the x and y directions, i.e., the horizontal rate of change and the vertical rate of change, respectively. This is the transpose symbol.

[0041] Furthermore, the completeness score expression is:

[0042] ;

[0043] ;

[0044] In the formula, S is the integrity score of the circle; M is the number of edge points that meet the radius tolerance condition; , , They are circular The x and y coordinates of the center of the circle and the radius of the circle; For edge point set The Middle The coordinates of the edge points; Let be the Euclidean distance from the edge point to the center of the circle; For indicator functions, when The value is 1 if the condition is true, and 0 otherwise. This is the tolerance threshold.

[0045] Furthermore, one of the duplicate detection circles is retained using any of the following methods:

[0046] Keep the circles with higher integrity scores and delete the circles with lower integrity scores;

[0047] Based on the completeness score and average contrast, a comprehensive score is calculated using a weighted scoring approach; circles with higher comprehensive scores are retained, while circles with lower comprehensive scores are deleted.

[0048] Merge the two or more edge sets corresponding to the same circle that are identified as duplicate detections, then refit the circle using the merged edge set to obtain the fitting result, and use the fitting result as the final retained circle.

[0049] Secondly, the present invention provides a visual inspection system for printing defects and quantity of circular self-adhesive labels, the system comprising:

[0050] The acquisition unit is used to acquire the image of the label to be detected;

[0051] The edge extraction unit is used to perform multi-scale Gaussian filtering on the image of the label to be detected to obtain the Gaussian-filtered image; and to extract the edge image from the Gaussian-filtered image based on adaptive threshold Canny edge detection.

[0052] The independent contour filtering unit is used to divide the edge image into contiguous edges to obtain the edge image after edge division; and to perform connectivity analysis on the edge image after edge division to obtain independent contours and edge point sets.

[0053] The fitting unit is used to traverse each contour point set in the edge point set, and fit each independent contour based on the RANSAC algorithm and the least squares method to obtain the fitting result of the label; the fitting result includes the center coordinates and radius.

[0054] The circle elimination unit is used to eliminate invalid circles and duplicate detection circles based on the fitting results of the labels, the circle quality evaluation, and geometric constraints, so as to obtain the circle detection results.

[0055] The judgment unit is used to determine whether the label image meets the printing requirements based on the circle detection result and in combination with preset label quantity, size range and printing position information.

[0056] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0057] 1. The present invention provides a visual detection method and system for printing defects and quantity of circular self-adhesive labels. Combining the ideas of contour fitting and random circle detection, and based on multi-size edge extraction, it has better performance for images with large differences in circle size and varying edge thickness.

[0058] 2. The present invention provides a visual detection method and system for printing defects and quantity of circular self-adhesive labels. By using skeleton diagrams and branch point detection, it effectively divides the partially adhered contours in the edge diagram, providing more independent contours for the subsequent fitting process.

[0059] 3. The present invention provides a visual inspection method and system for printing defects and quantity of circular self-adhesive labels. For contour edge points, it uses a coarse-to-fine RANSAC and least squares fitting method to reduce the error caused by random sampling and improve the accuracy of the fitting results.

[0060] 4. The present invention provides a visual inspection method and system for printing defects and quantity of circular self-adhesive labels. Based on circle quality evaluation and geometric constraints, it eliminates false circles and duplicate detection circles to obtain more accurate circle detection results. At the same time, it combines preset information such as label quantity, size range and printing position to effectively judge whether the label image meets the printing requirements. Attached Figure Description

[0061] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and form part of this application, do not constitute a limitation thereof. In the drawings:

[0062] Figure 1 This is a flowchart of the visual inspection method for printing defects and quantity of circular self-adhesive labels according to the present invention.

[0063] Figure 2 The image shown is the label to be detected in this invention.

[0064] Figure 3 The grayscale image of this invention is gray.

[0065] Figure 4 The image preprocessed for this invention;

[0066] Figure 5 This describes the edge image extraction process of the present invention;

[0067] Figure 6 Images showing the edge division of the local adhesion area in this invention before and after;

[0068] Figure 7 This refers to the fitting process for each independent contour in this invention;

[0069] Figure 8 This is a qualified label image for the present invention;

[0070] Figure 9 This is an image of a label that was missing in the present invention;

[0071] Figure 10 This is an image of the misaligned label of the present invention;

[0072] Figure 11 Results are from conventional testing methods;

[0073] Figure 12 The results are the detection results of the method of the present invention;

[0074] Figure 13 This is the detection result of the label area of ​​the present invention;

[0075] Figure 14 This is a block diagram of the visual inspection system for printing defects and quantity of circular self-adhesive labels according to the present invention. Detailed Implementation

[0076] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of this invention are only for explaining this invention and are not intended to limit this invention.

[0077] The main design features of this invention are as follows:

[0078] (1) To address the problem that Hough circle transform is prone to false detection and false detection due to complex background and interference edges: This invention uses multi-scale edge extraction to ensure that the edges of blurred or incomplete circles are still detected in the initial stage, reducing the possibility of false detection; for the detected independent contours, geometric feature screening is performed in advance to reduce the false detection rate.

[0079] (2) To address the problem of slow convergence and unstable results in random circle detection in scenarios with dense edge points and many interferences: This invention adopts a combination of RANSAC (Random Sample Consensus) purification of interior points and least squares fitting to improve the accuracy of detection results; and for the problem of insufficient ability to distinguish between circles close to each other or concentric circles, this invention uses circle quality evaluation and geometric constraints to eliminate false circles and duplicate detection circles in the detection results.

[0080] (3) To address the problem that conventional contour fitting is sensitive to noise and the positioning error of adhered edges: In the preprocessing stage of this invention, bilateral filtering is used to smooth noise and preserve edges, and multi-scale adaptive edge extraction is used to improve edge quality and ensure that edges of different thicknesses can be extracted; and skeletonization and branch point detection are performed on the edge image to divide the adhered contours for subsequent analysis.

[0081] This invention is applicable to the visual inspection of printing defects and quantity of round self-adhesive labels in the printing and packaging industry, improving inspection efficiency, etc.

[0082] Example 1

[0083] like Figure 1 As shown, the present invention provides a visual inspection method for printing defects and quantity of circular self-adhesive labels, the method comprising:

[0084] S1, acquire the image of the label to be detected; the image of the label to be detected includes, but is not limited to, the original image of the label to be detected (img) loaded locally or acquired in real time by the camera, such as Figure 2 As shown.

[0085] As a further implementation, the method also includes: preprocessing the image img of the label to be detected to obtain a preprocessed image pre;

[0086] Specifically, preprocessing includes:

[0087] The image (img) of the label to be detected is converted to grayscale to obtain a grayscale image (gray). Figure 3 As shown; subsequent detection processes are all based on this grayscale image;

[0088] The grayscale image (gray) is denoised and enhanced using bilateral filtering, which smooths noise while preserving edges relatively well. This yields the preprocessed image (pre), as shown below. Figure 4 As shown. Depending on the type of noise in different images, and considering the requirements for processing speed and image quality, other image denoising and enhancement algorithms can be used, including but not limited to mean filtering, median filtering, wavelet denoising, low-pass filtering, etc.

[0089] S2, perform multi-scale Gaussian filtering on the image of the label to be detected to obtain the Gaussian-filtered image; extract the edge image from the Gaussian-filtered image based on adaptive threshold Canny edge detection to obtain the edge image;

[0090] In this embodiment, as Figure 5 As shown, Figure 5 This refers to the edge image extraction process. Step S2 specifically includes:

[0091] S21, Multi-scale parameter settings: First, set a reference scale as edge_scale, and use the following three scales:

[0092] scale1 = 0.8 × edge_scale;

[0093] scale2 = edge_scale;

[0094] scale3 = 1.2 × edge_scale;

[0095] Different scales can capture edges of varying thickness and contrast, and the number of scales and magnification ratios can be adjusted according to the actual situation of the image.

[0096] S22: Multi-scale edge detection loop, performing the following operations for each scale:

[0097] (1) Adaptive Gaussian filtering: The kernel size is equal to twice the scale minus 1 plus 3. After rounding, it is necessary to ensure that the kernel size is odd. Then, Gaussian filtering is performed using the kernel size to obtain the Gaussian filtered image.

[0098] (2) Adaptive threshold calculation: Based on the local contrast of the image, the high and low thresholds of Canny edge detection are automatically adjusted. Specifically, the standard deviation avg_contrast of the image after Gaussian filtering is calculated based on OpenCV. The low threshold thre_low is equal to 0.5 times the scale multiplied by avg_contrast, and the high threshold thre_high is equal to the scale multiplied by avg_contrast.

[0099] (3) Canny edge detection: Canny edge detection is performed on the Gaussian filtered image using adaptively solved high threshold thre_high and low threshold thre_low to obtain the edge image edge corresponding to the current scale.

[0100] S23: Multi-scale edge fusion: Perform a logical OR operation on the edge images edge at the above three or a specified number of scales to obtain multi-scale edge fused images edges.

[0101] S24: Post-processing: Perform morphological closing operation on the scale edge fusion image edges, connect the broken edges and fill the small holes to obtain the final edge image img_edge. This operation makes the edges in the image more continuous, which is convenient for subsequent circular feature detection.

[0102] The edge image extraction method in step S2 of the above technical solution is better able to handle problems such as uneven lighting, contrast changes, and inconsistent edge thickness in real-world application scenarios than Canny detection with single-scale Gaussian filtering and fixed high and low thresholds, providing more complete and higher-quality candidate edges for subsequent fitting.

[0103] S3, perform adhesion edge segmentation on the edge image to obtain the edge image after edge segmentation; and perform connectivity analysis on the edge image after edge segmentation to obtain independent contours and edge point sets;

[0104] In this embodiment, step S3 specifically includes:

[0105] S31, Adhesive Edge Segmentation: Based on the Zhang-Suen thinning algorithm, the skeleton of the edge image img_edge is extracted to obtain the skeleton image skeleton; 8-neighbor branch point detection is performed on the non-zero pixels in the skeleton image skeleton; for pixels with more than a first set threshold neighbors_thre, the adhesive edges are segmented at the corresponding positions in the edge image img_edge to achieve contour segmentation, obtaining the edge image img_seg after edge segmentation; For example... Figure 6 As shown, Figure 6 Images before and after defining the edges of the locally adhered region.

[0106] S32, perform connectivity analysis on the edge image img_seg after edge segmentation to obtain the area of ​​the connected components; remove contours whose area of ​​the connected components is less than the second set threshold fit_thre to obtain independent contours; store the pixels of the independent contours to obtain the edge point set all_points.

[0107] S4, traverse each contour point set point in the edge point set all_points, fit each independent contour based on the RANSAC algorithm and the least squares method, and obtain the fitting result of the label; the fitting result includes the center coordinates and radius;

[0108] Specifically, such as Figure 7 As shown, Figure 7 The fitting process for each independent contour. The specific process of fitting each independent contour based on the RANSAC algorithm and least squares method is as follows:

[0109] S41. Randomly select three points from a certain contour point set (points) of the edge point set to initialize a circle model. Use the RANSAC algorithm to iteratively calculate and find the candidate circle model (i.e. the best model) with the most support points (i.e. the most interior points). At the same time, save the interior point set (inlier_points).

[0110] S42 uses the inlier_points set as a clean dataset and performs accurate circle fitting based on the least squares method, which can reduce the error caused by random sampling. It obtains the sub-pixel circle center coordinates (x,y) and radius r of each label and uses them as the fitting result of the current label.

[0111] S5. Based on the fitting results of the labels, and in conjunction with the circle quality evaluation and geometric constraints, invalid circles and duplicate detection circles are eliminated to obtain the circle detection results.

[0112] In this embodiment, step S5 specifically includes:

[0113] S51, Calculate the average contrast of the circular edge based on the fitting result of the label; when the average contrast is less than the third set threshold, the circle is determined to be an invalid circle and is removed.

[0114] Specifically, for a circular edge, ideally, its gradient direction should be consistent with the edge normal direction, and the gradient magnitude should reflect the local contrast intensity. The calculation process for the average contrast is as follows: First, the Sobel operator is used to calculate the gradient components of the grayscale image in the x and y directions; for each edge point, the normal direction is calculated and the gradient value of the current point is obtained. After gradient projection calculation and numerical normalization, the average contrast of all valid edge points is calculated and used as the average contrast of the entire circle.

[0115] For each edge point :

[0116] (1) Normal vector n: , and These are the coordinates of the edge point and the current center of the circle, respectively. This represents a vector pointing from the center of the circle to the edge points. Represents the Euclidean length (modulus) of a vector;

[0117] (2) Image gradient vector g: , and These are the gradient components in the x and y directions, i.e., the horizontal rate of change and the vertical rate of change, respectively. It is the transpose symbol;

[0118] (3) Contrast in normal direction : , Let be the contrast of the i-th normal direction.

[0119] Obtain the normal direction contrast of all edge points Afterwards, the average edge contrast is: Where N is the number of edge points. When the average contrast... If the value is less than the third set threshold contrast_thre, the circle is determined to be an invalid circle.

[0120] S52, Calculate the completeness score of the circle based on the fitting results of the label; when the completeness score is less than the fourth set threshold, the circle is determined to be an invalid circle and is removed.

[0121] Specifically, the distance from each edge point to the center of the circle is calculated, and it is determined whether the difference between this distance and the theoretical radius is within the tolerance range. The number of all points within the tolerance range is counted, and the ratio of the number of points that conform to the circumference to the theoretical circumference is calculated as the completeness score of the current circle.

[0122] For circles and edge point set :

[0123] The number of points that meet the radius tolerance condition is: ;

[0124] The completeness score of the circle is: ;

[0125] In the formula, S is the integrity score of the circle; M is the number of edge points that meet the radius tolerance condition; , , They are circular The x and y coordinates of the center of the circle and the radius of the circle; For edge point set The Middle The coordinates of the edge points; Let be the Euclidean distance from the edge point to the center of the circle; For indicator functions, when The value is 1 if the condition is true, and 0 otherwise. This is the tolerance threshold.

[0126] The above is the completeness score. If the score is less than the fourth set threshold (score_thre), the circle is determined to be an invalid circle and is removed.

[0127] S53 utilizes geometric constraints to eliminate duplicate circles in the detection results, ensuring that each circle is unique in the image. Specifically, a double-loop comparison is used: the outer loop iterates through all circles, while the inner loop compares the current circle with other circles, calculating the center distance and radius difference. Based on the center distance and radius difference, two circles that are both close in position and similar in size are considered duplicate detection circles. For duplicate detection circles, the following three methods can be used to determine how to retain them:

[0128] (1) Completeness score Higher circles are selected, and circles with low integrity scores are removed;

[0129] (2) Based on the completeness score and average contrast, calculate the comprehensive score using the weighted scoring method. Keep the circles with higher overall scores and delete the circles with lower overall scores;

[0130] (3) Merge two or more edge sets corresponding to the same circle that are determined to be duplicate detection, and then use the merged edge set to refit the circle to obtain the fitting result. The fitting result is used as the final retained circle (for example, edge set A and edge set B detect the same circle. After removing the two circles fitted by A and B respectively, A and B are combined to obtain edge set C; C is used to refit to obtain a circle, and the circle fitted by C is retained).

[0131] Depending on the label arrangement, different methods can be used to handle duplicate detection circles. After completing the geometric constraints, the remaining circles are all qualified circles, which constitute the circle detection results. The qualified circles are then sorted according to requirements, and the number of circles, the radius of each circle, and the coordinates of its center are output. Sorting methods can include radius size, center position, score, contrast level, etc.

[0132] S6, based on the circle detection results, combined with the preset label quantity, size range and printing position information, determines whether the label image meets the printing requirements.

[0133] In this embodiment, step S6 specifically includes:

[0134] S61: Quantitative statistics: Count all fitted samples whose radii are within the preset range. The number of circles inside, num, is compared with the standard number, num_std, to determine if there are any missing or extra circles.

[0135] S62: Size measurement, iterate through the circle radius r of each label, if If the size does not meet the printing tolerance, mark the label as non-compliant and record whether it is too large or too small.

[0136] S63: Position and spacing detection. Calculate the standard deviation of row / column spacing based on the coordinates of all qualified circle centers. If it exceeds the threshold, it is marked as a layout deviation.

[0137] S64: Based on different scenario requirements, add inspection items for printing quality aspects such as color consistency, scratches, and impurities within the circular label area to determine whether there are printing defects.

[0138] like Figures 8 to 10 , Figure 8 For qualified label images, Figure 9 Image of a missing label. Figure 10 Image with misaligned labels; Figure 9 Three labels were missing from the middle. Figure 10 The labels are misaligned, and some label areas contain foreign particles and scratches. In specific implementation, use... Figure 9 and Figure 10 Images provided as examples.

[0139] 1. For Figure 9 The image with missing labels was detected using the method of this invention. The number of qualified labels obtained was 25, which is lower than the set number of 28, and it was determined to be a missing label.

[0140] 2. For Figure 10 The misaligned and overlapping labels appear as adhered contours in the edge extraction image. Using traditional detection methods yields the following results: Figure 11 As shown. The results obtained by using the method of this invention are as follows. Figure 12 As shown.

[0141] from Figure 11 and Figure 12 The comparison shows that conventional methods cannot effectively distinguish adhered contours, leading to missed detections and a lower number of labels than actually present in the image. The method of this invention effectively addresses this scenario, detecting all labels and then analyzing the results.

[0142] (1) Quantity statistics: Count all fitted circles with radii within the preset range, and obtain 28 labels, which meet the quantity requirements. There are no extra or missing labels, and the quantity is recorded as qualified.

[0143] (2) Label size: Traverse the radius of all notes. The average radius is 109.44, the maximum radius is 110.28, and the minimum radius is 108.25. The unit is pixels. If the radius of each label is within the preset range, the label size is considered qualified.

[0144] (3) Position and Spacing Detection: In the position and spacing judgment, the theoretical value of the label position is combined with the preset value. Figure 10 The second-to-last label in the third row from the top is offset 70 pixels to the left in the x-direction and 22 pixels upward in the y-direction, which exceeds the tolerance range and is considered a layout deviation, thus it is marked as a layout failure.

[0145] (4) Printing quality inspection: Figure 13 An example of inspection within a single label is shown, revealing the presence of foreign particles and scratches. After inspecting all label areas, it can be determined that the label image contains printing defects.

[0146] Example 2

[0147] like Figure 14 As shown, the difference between this embodiment and Embodiment 1 is that this embodiment provides a visual inspection system for printing defects and quantity of circular self-adhesive labels. This system corresponds one-to-one with the visual inspection method for printing defects and quantity of circular self-adhesive labels in Embodiment 1. The system includes:

[0148] The acquisition unit is used to acquire the image of the label to be detected;

[0149] The edge extraction unit is used to perform multi-scale Gaussian filtering on the image of the label to be detected to obtain the Gaussian-filtered image; and to extract the edge image from the Gaussian-filtered image based on adaptive threshold Canny edge detection.

[0150] The independent contour filtering unit is used to divide the edge image into contiguous edges to obtain the edge image after edge division; and to perform connectivity analysis on the edge image after edge division to obtain independent contours and edge point sets.

[0151] The fitting unit is used to traverse each contour point set in the edge point set, and fit each independent contour based on the RANSAC algorithm and the least squares method to obtain the fitting result of the label; the fitting result includes the center coordinates and radius.

[0152] The circle elimination unit is used to eliminate invalid circles and duplicate detection circles based on the fitting results of the labels, the circle quality evaluation, and geometric constraints, so as to obtain the circle detection results.

[0153] The judgment unit is used to determine whether the label image meets the printing requirements based on the circle detection result and in combination with preset label quantity, size range and printing position information.

[0154] The execution process of each unit can be carried out according to the visual inspection method for printing defects and quantity of circular self-adhesive labels in Example 1, and will not be described in detail in this example.

[0155] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0156] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0157] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0158] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0159] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A visual inspection method for printing defects and quantity of round self-adhesive labels, characterized in that, The method includes: Obtain the image of the label to be detected; The image of the label to be detected is subjected to multi-scale Gaussian filtering to obtain a Gaussian-filtered image; edge extraction is performed on the Gaussian-filtered image based on adaptive threshold Canny edge detection to obtain an edge image; The edge image is subjected to adhesion edge segmentation to obtain edge image after edge segmentation; and the edge image after edge segmentation is subjected to connectivity analysis to obtain independent contours and edge point sets. Traverse each contour point set in the edge point set, and fit each independent contour based on the RANSAC algorithm and the least squares method to obtain the fitting result of the label; the fitting result includes the center coordinates and radius; Based on the fitting results of the labels, and using circle quality evaluation combined with geometric constraints, invalid circles and duplicate detection circles are eliminated to obtain the circle detection results; Based on the circle detection results, combined with preset label quantity, size range, and printing position information, it is determined whether the label image meets the printing requirements.

2. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 1, characterized in that, The method also includes: The image of the label to be detected is preprocessed to obtain a preprocessed image; The preprocessing includes: performing grayscale transformation on the image of the label to be detected to obtain a grayscale image; and performing bilateral filtering on the grayscale image to smooth noise and preserve edges to obtain a preprocessed image.

3. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 1, characterized in that, Edge extraction is performed on the Gaussian-filtered image based on adaptive threshold Canny edge detection to obtain an edge image, including: Based on local image contrast, the high and low thresholds of Canny edge detection are automatically adjusted; the high threshold is equal to the product of scale and standard deviation, and the low threshold is equal to the product of a preset multiple of scale and standard deviation, where the standard deviation is the standard deviation of the image after Gaussian filtering calculated based on OpenCV. Based on the high and low thresholds, edge extraction is performed on the Gaussian filtered image using Canny edge detection to obtain the edge image corresponding to the current scale. Obtain edge images at a preset scale by following the above steps, and perform multi-scale edge fusion on all edge images to obtain a multi-scale edge fused image; The multi-scale edge fusion image is post-processed to obtain the final edge image; the post-processing includes performing morphological closing operations on the multi-scale edge fusion image, connecting broken edges and filling small holes.

4. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 1, characterized in that, The edge image is subjected to contiguous edge segmentation to obtain a segmented edge image; and the segmented edge image is subjected to connectivity analysis to obtain independent contours and edge point sets, including: The skeleton of the edge image is extracted based on the Zhang-Suen thinning algorithm to obtain a skeleton map; For non-zero pixels in the skeleton image, branch points in the 8-neighborhood are detected. For pixel positions where the number of branch points is greater than a first set threshold, the sticky edges are segmented at the corresponding positions in the edge image to obtain the edge image after edge segmentation. Connectivity analysis is performed on the edge image after edge segmentation to obtain the area of ​​the connected region; contours with connected region areas smaller than a second set threshold are removed to obtain independent contours; and the pixels of the independent contours are stored to obtain an edge point set.

5. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 1, characterized in that, The specific process of fitting each independent contour based on the RANSAC algorithm and least squares method is as follows: From a certain contour point set of the edge point set, three points are randomly selected to initialize a circle model. The RANSAC algorithm is used to iteratively calculate and find the candidate circle model with the most support points, i.e., the inner point set with the most inner points. Using the set of inner points as a clean dataset, circle fitting is performed based on the least squares method to obtain the sub-pixel center coordinates and radius of each label, which are then used as the fitting result for the current label.

6. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 1, characterized in that, Based on the label fitting results, and using circle quality evaluation combined with geometric constraints, invalid and duplicate detection circles are eliminated to obtain the circle detection results, including: Based on the fitting results of the labels, the average contrast of the circular edges is calculated; when the average contrast is less than a third set threshold, the circle is determined to be an invalid circle and is discarded. Based on the fitting results of the labels, the integrity score of the circle is calculated; when the integrity score is less than the fourth set threshold, the circle is determined to be an invalid circle and is removed. Using a double loop comparison, the outer loop traverses all circles, while the inner loop compares the current circle with other circles, calculating the center distance and radius difference. Based on the center distance and radius difference, two circles that are both close in position and similar in size are considered to be duplicate detection circles, and one of the duplicate detection circles is retained.

7. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 6, characterized in that, The expression for the average contrast ratio is: ; ; ; ; In the formula, The average contrast is N; N is the number of edge points. is the contrast of the normal direction of the i-th edge point; g is the gradient vector at the edge point; n is the unit normal vector at the edge point; and These are the coordinates of the edge point and the current center of the circle, respectively. This represents a vector pointing from the center of the circle to the edge points. The Euclidean length of a vector is its modulus. and These are the gradient components in the x and y directions, i.e., the horizontal rate of change and the vertical rate of change, respectively. This is the transpose symbol.

8. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 6, characterized in that, The completeness score expression is: ; ; In the formula, S is the integrity score of the circle; M is the number of edge points that meet the radius tolerance condition; , , They are circular The x and y coordinates of the center of the circle and the radius of the circle; For edge point set The Middle The coordinates of the edge points; Let be the Euclidean distance from the edge point to the center of the circle; For indicator functions, when The value is 1 if the condition is true, and 0 otherwise. This is the tolerance threshold.

9. The visual inspection method for printing defects and quantity of circular self-adhesive labels according to claim 6, characterized in that, One of the duplicate detection circles is retained using any of the following methods: The circles with higher integrity scores are retained, and the circles with lower integrity scores are deleted. Based on the completeness score and the average contrast, a comprehensive score is calculated using a weighted scoring approach; circles with higher comprehensive scores are retained, and circles with lower comprehensive scores are deleted. Merge two or more edge sets corresponding to the same circle that is identified as a duplicate detection, and refit the circle using the merged edge set to obtain the fitting result. This fitting result is then used as the final circle to be retained.

10. A visual inspection system for printing defects and quantity of round self-adhesive labels, characterized in that, The system includes: The acquisition unit is used to acquire the image of the label to be detected; An edge extraction unit is used to perform multi-scale Gaussian filtering on the image to be detected to obtain a Gaussian-filtered image; and to perform edge extraction on the Gaussian-filtered image based on adaptive threshold Canny edge detection to obtain an edge image. An independent contour filtering unit is used to perform adhesion edge segmentation on the edge image to obtain an edge image after edge segmentation; and to perform connectivity analysis on the edge image after edge segmentation to obtain independent contours and edge point sets. The fitting unit is used to traverse each contour point set in the edge point set, fit each independent contour based on the RANSAC algorithm and the least squares method, and obtain the fitting result of the label; the fitting result includes the center coordinates and radius. The circle elimination unit is used to eliminate invalid circles and duplicate detection circles based on the fitting results of the labels, the circle quality evaluation, and geometric constraints, so as to obtain the circle detection results. The judgment unit is used to determine whether the label image meets the printing requirements based on the circle detection result and in combination with preset label quantity, size range and printing position information.