Packaging box sealing quality inspection method based on machine vision
By calculating the similarity and gradient values of pixel points in the sealing area, the gradient values are corrected to obtain the updated gradient values, which solves the inaccuracy caused by grayscale complexity in sealing quality detection, and improves the accuracy of the detection results.
Patent Information
- Application Number
- CN202411095917.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-12
AI Technical Summary
When existing seal quality detection method based on Laplace operators has defects such as bubbles and scratches on packaging boxes with poor seal quality, it leads to complex grayscale distribution, resulting in inaccurate seal quality index, which in turn affects the Accuracy of the test results.
By obtaining the gradient values and similarities of each pixel point in the sealing area, calculating the reduction factor, correcting the gradient value, obtaining the update gradient value, and then evaluating the sealing quality index, and excluding the influence of the grayscale change pixel points belonging to the sealing area itself , improve detection accuracy.
Improve the accuracy of sealing quality inspection, ensure accurate evaluation of the quality of the sealing area, and reduce errors due to grayscale complexity.
Smart Images

Figure CN118628489B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically, to a method for detecting the quality of packaging box sealing based on machine vision. Background Art
[0002] Sealing quality inspection based on machine vision has gradually become an important inspection method in the packaging industry in recent years. With the improvement of automation level and the increase in product quality requirements, traditional manual inspection methods can no longer meet the needs of high efficiency and high precision. Machine vision technology can obtain the sealing area of the packaging box in real time through high-speed cameras and image processing algorithms, and automatically identify and analyze the integrity, flatness, bubbles and foreign matter of the seal. This method plays an increasingly important role in improving product quality and production efficiency.
[0003] The patent document with the authorization announcement number CN110120069B currently discloses a triangular mesh filtering method and terminal device based on the Laplace operator. The method updates the vertices by dividing the neighborhood of each vertex into two parts, then calculating the Laplace operator of each half window of the domain, and updating the vertices according to the calculated Laplace operator.
[0004] When the Laplace operator in the above method is used to detect the quality of the sealed area, the grayscale complexity of the sealed area is mainly used as the sealing quality index. However, for packaging boxes with poor sealing quality, bubbles, scratches and other defects will appear in the sealed area. These defects will make the grayscale distribution of the sealed area complicated. Therefore, the obtained sealing quality index is inaccurate, resulting in inaccurate quality detection results for the sealed area. Summary of the invention
[0005] In order to solve the problem that defects such as bubbles and scratches on a packaging box with poor sealing quality make the grayscale distribution of the sealing area complicated, resulting in inaccurate sealing quality index and thus inaccurate quality detection results of the sealing area, the present invention proposes a packaging box sealing quality detection method based on machine vision, which includes the following steps:
[0006] Collect the packaging box image, and obtain the sealing area according to the packaging box image; obtain the gradient value of each pixel in the sealing area; obtain the similarity between each pixel in the sealing area and each pixel in its eight neighborhoods, wherein the similarity represents the approximation between the gradient value and the gradient direction between the pixels; perform regional growth on the pixels in the sealing area according to the similarity between each pixel in the sealing area and each pixel in its eight neighborhoods, and obtain multiple connected domains in the sealing area;
[0007] Get the reduction factor of each pixel in the sealed area , where Represents the reduction factor of the i-th pixel in the sealed area; Represents the number of pixels in the connected domain where the i-th pixel in the sealed area is located; Represents the total number of pixels in the sealed area; Represents the maximum value of the similarity between the i-th pixel in the sealed area and all the pixels in its eight neighborhoods;
[0008] Obtain an updated gradient value for each pixel in the seaming area, wherein the updated gradient value is 1 minus the product of the reduction factor of each pixel in the seaming area and the gradient value of each pixel; obtain a seaming quality index based on the updated gradient value of each pixel in the seaming area to evaluate the seaming quality.
[0009] The innovation of the present invention lies in obtaining the reduction factor of each pixel point in the seamed area, that is, the possibility that each pixel point belongs to the grayscale change pixel point of the seamed area itself, correcting the gradient value of each pixel point according to the reduction factor of each pixel point in the seamed area, obtaining the updated gradient value of each pixel point in the seamed area, reducing the gradient value of the grayscale change pixel point belonging to the seamed area itself, obtaining the seaming quality index to evaluate the quality of the seamed area, so that the quality detection result of the seamed area is more accurate.
[0010] Preferably, the step of obtaining the gradient value of each pixel in the sealing area includes:
[0011] Convolution is performed on each pixel in the sealed area according to the Laplace operator, and the obtained convolution value is used as the gradient value of each pixel in the sealed area.
[0012] The gradient value of each pixel in the sealed area is obtained to facilitate the subsequent adjustment of the gradient value of each pixel so that the gradient value of the grayscale change pixel belonging to the sealed area itself becomes smaller.
[0013] Preferably, the obtaining of the similarity between each pixel point in the sealed area and each pixel point in its eight neighborhoods includes:
[0014] Obtain the coordinates of the target pixel points of each pixel point in the sealing area;
[0015] ;
[0016] In the formula, Represents the similarity between the i-th pixel in the sealed area and the j-th pixel in its eight neighborhoods; Represents the gradient value of the i-th pixel in the sealed area; Represents the gradient value of the jth pixel in the eight-neighborhood of the i-th pixel in the sealed area; ( ) represents the coordinates of the target pixel point of the i-th pixel point in the sealing area; ( ) represents the coordinates of the target pixel point of the jth pixel in the eight-neighborhood of the i-th pixel in the sealed area; || represents the absolute value symbol.
[0017] If the similarity between the pixels is higher, it means that the two pixels are more likely to belong to the grayscale change pixels of the sealed area itself, and the reduction factor is larger.
[0018] Preferably, the step of obtaining the coordinates of target pixels of each pixel in the sealing area includes:
[0019] Get the grayscale difference between the i-th pixel in the sealed area and each pixel in its eight neighborhoods, record the pixel in the eight neighborhoods corresponding to the maximum grayscale difference as the target pixel of the i-th pixel, set the i-th pixel in the sealed area as the origin, and get the coordinates of the target pixel of the i-th pixel.
[0020] Preferably, the step of obtaining a plurality of connected domains of the sealing area includes:
[0021] Based on the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods, a region growing algorithm is used to perform region growing on the pixels in the sealed area to obtain several connected domains in the sealed area.
[0022] Preferably, the updated gradient value of each pixel in the sealing area is obtained by a calculation formula:
[0023] ;
[0024] In the formula, Represents the updated gradient value of the i-th pixel in the sealed area; Represents the gradient value of the i-th pixel in the sealed area; Represents the reduction factor of the i-th pixel in the sealed area.
[0025] The gradient value of the grayscale change pixel points belonging to the seaming area itself is reduced, so that the seaming quality index obtained later according to the updated gradient value is more accurate.
[0026] Preferably, obtaining the sealing quality index to evaluate the sealing quality includes:
[0027] A quality threshold T2 is preset, and the average of the updated gradient values of all pixels in the sealing area is used as the sealing quality index. If the sealing quality index is less than the quality threshold, it is considered that the quality of the sealing area meets the standard, otherwise, the quality of the sealing area does not meet the standard.
[0028] The sealing quality index obtained according to the updated gradient value of each pixel is more accurate.
[0029] Preferably, obtaining the sealing area according to the packaging box image includes:
[0030] A camera is placed on the packaging box sealing production line. After the packaging box is sealed, the packaging box image is collected and semantic segmentation is performed on the packaging box image to obtain the sealing area.
[0031] The present invention has the following beneficial effects: the purpose of the present invention is to obtain the reduction factor of each pixel point in the seamed area, that is, the possibility that each pixel point belongs to the grayscale change pixel point of the seamed area itself, and to correct the gradient value of each pixel point according to the reduction factor to obtain the updated gradient value of each pixel point in the seamed area. This operation is to reduce the gradient value of the grayscale change pixel point belonging to the seamed area itself, and finally obtain the seaming quality index according to the updated gradient value of each pixel point in the seamed area to evaluate the quality of the seamed area, so that the quality detection result of the seamed area is more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0033] Figure 1 is a flowchart of the steps of a packaging box sealing quality detection method based on machine vision according to an embodiment of the present invention;
[0034] Figure 2 Represents the convolution kernel of the Laplacian operator. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0036] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0037] See also Figure 1 , which shows a flowchart of a method for detecting the quality of sealing of a packaging box based on machine vision according to an embodiment of the present invention, the method comprising the following steps:
[0038] S001. Collect the packaging box image, and obtain the sealing area according to the packaging box image.
[0039] It should be noted that after the production line completes the sealing of the packaging box, it is necessary to perform a sealing quality analysis on the sealed area. The quality analysis of the sealed area is mainly based on the complexity of the grayscale changes in the sealed area. Therefore, it is necessary to segment the sealed area in the captured packaging box image and perform a separate analysis to more accurately perform quality inspection of the sealed area.
[0040] In an embodiment of the present invention, a camera is arranged on a packaging box sealing production line. After the packaging box is sealed, an image of the packaging box is collected, semantic segmentation is performed on the packaging box image, and the sealing area is obtained. In order to facilitate subsequent analysis, the sealing area is grayed.
[0041] S002. Obtain the gradient value of each pixel in the sealed area; obtain the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods according to the approximation between the gradient value and the gradient direction between the pixels.
[0042] It should be noted that, for packaging boxes with poor sealing quality, bubbles, scratches and other defects will appear in the sealing area, and these defects will make the grayscale distribution of the sealing area complicated. Therefore, when using the Laplace operator to perform quality inspection on the sealing area, the grayscale complexity of the sealing area can be used as the sealing quality index. However, since there are certain grayscale changes in the sealing area, the obtained sealing quality index is inaccurate, resulting in inaccurate quality inspection results for the sealing area. Therefore, the present invention needs to exclude the grayscale change pixels belonging to the sealing area itself, that is, the normal grayscale change pixels, and then obtain the grayscale complexity of the sealing area to evaluate the quality of the sealing; the gradient value of the known pixel point can reflect the grayscale complexity at the pixel point, so it is necessary to first obtain the gradient of each pixel point in the sealing area.
[0043] In the embodiment of the present invention, convolution is performed on each pixel point in the sealed area according to the Laplace operator, and the obtained convolution value is used as the gradient value of each pixel point in the sealed area. It should be noted that the convolution kernel of the Laplace operator is as follows: Figure 2 shown.
[0044] It should be noted that the purpose of the present invention is to exclude pixels with normal grayscale changes. It is known that when defects such as bubbles and scratches appear in the seamed area, the grayscale complexity of the seamed area becomes larger, and the gradient changes between the pixels in these defective areas are irregular, while the gradients between the pixels with normal grayscale changes are similar, that is, the gradient values and gradient directions are similar. Therefore, the similarity between each pixel in the seamed area and each pixel in its eight neighborhoods can be obtained based on the approximation between the gradient values and gradient directions between the pixels.
[0045] In an embodiment of the present invention, the grayscale difference between the i-th pixel point in the seamed area and each pixel point in its eight neighborhoods is obtained, the pixel point in the eight neighborhoods corresponding to the maximum grayscale difference is recorded as the target pixel point of the i-th pixel point, the i-th pixel point in the seamed area is set as the origin, and the coordinates of the target pixel point of the i-th pixel point are obtained.
[0046] Get the similarity between the i-th pixel in the sealed area and the j-th pixel in its eight neighborhoods:
[0047] ;
[0048] In the formula, Represents the similarity between the i-th pixel in the sealed area and the j-th pixel in its eight neighborhoods; Represents the gradient value of the i-th pixel in the sealed area; Represents the gradient value of the jth pixel in the eight-neighborhood of the i-th pixel in the sealed area; ( ) represents the coordinates of the target pixel point of the i-th pixel point in the sealing area; ( ) represents the coordinates of the target pixel of the jth pixel in the eight-neighborhood of the i-th pixel in the sealed area; || represents the absolute value symbol; Represents the similarity of the gradient value between the i-th pixel in the sealed area and the j-th pixel in its eight neighborhoods. The larger the value, the greater the similarity between the i-th pixel and the j-th pixel in its eight neighborhoods. It represents the similarity between the coordinates of the target pixel of the i-th pixel in the sealed area and the target pixel of the j-th pixel in its eight neighborhoods, that is, the similarity between the gradient directions of the i-th pixel in the sealed area and the j-th pixel in its eight neighborhoods. The larger the value, the greater the similarity between the two pixels.
[0049] Similarly, the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods is obtained.
[0050] S003. According to the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods, perform region growing on the pixels in the sealed area to obtain several connected domains in the sealed area; according to the number of pixels in each connected domain in the sealed area and the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods, obtain the reduction factor of each pixel in the sealed area.
[0051] It should be noted that the similarity between pixels indicates the consistency of gradient changes between pixels. Since the grayscale changes of pixels in the defective area of the welded area are more complex, the similarity between pixels in the defective area is relatively small, while the gradient changes between pixels with normal grayscale changes are relatively consistent. Therefore, if the similarity between pixels is greater, they are more likely to belong to the same normal grayscale change pixels. There may also be a few pixels in the defective area that are highly similar to their neighboring pixels. Therefore, based on the similarity between pixels, regional growth is performed on the pixels in the welded area to exclude the few pixels in the defective area that are highly similar to their neighboring pixels.
[0052] In an embodiment of the present invention, region growing is performed on pixel points in the sealed area according to a region growing algorithm to obtain several connected domains of the sealed area; wherein, region growing is based on the similarity between each pixel point and each pixel point in its eight neighborhoods, and a similarity threshold is preset, and growth is performed when the similarity between a pixel point and the pixel points in its eight neighborhoods is greater than the similarity threshold. In an embodiment of the present invention, a similarity threshold T1=0.75 is preset, and in other embodiments, the implementer may determine it according to the specific implementation situation.
[0053] It should be noted that, when the maximum value of the similarity between any pixel point in the seamed area and all the pixels in its eight neighborhoods is larger, and the area of the connected domain where the pixel point is located is larger, it means that the pixel point is more likely to be a normal grayscale change pixel point, and the reduction factor of the pixel point is larger; if the maximum value of the similarity between any pixel point in the seamed area and all the pixels in its eight neighborhoods is larger, but the area of the connected domain where the pixel point is located is smaller, it means that the pixel point is one of the few pixels in the defect area that has a high similarity with the neighboring pixels, and the reduction factor of the pixel point is smaller.
[0054] In this embodiment of the present invention, the reduction factor of each pixel in the sealed area is obtained:
[0055]
[0056] In the formula, Represents the reduction factor of the i-th pixel in the sealed area; Represents the number of pixels in the connected domain where the i-th pixel in the sealed area is located; Represents the total number of pixels in the sealed area; Represents the maximum value of the similarity between the i-th pixel in the sealed area and all the pixels in its eight neighborhoods.
[0057] S004. According to the reduction factor of each pixel in the seaming area, the gradient value of each pixel is corrected to obtain the updated gradient value of each pixel in the seaming area; according to the updated gradient value of each pixel in the seaming area, the seaming quality index is obtained to evaluate the seaming quality.
[0058] It should be noted that it is known that the pixel with a larger reduction factor is more likely to be a normal grayscale change pixel. Therefore, the gradient value of each pixel is reduced according to the reduction factor, and the updated gradient value of each pixel in the seamed area is obtained. The gradient value of the pixel that is more likely to be a normal grayscale change is adjusted to a smaller value, so as to reduce or even eliminate the influence of the gradient value of the normal grayscale change pixel in the seamed area on the seaming quality. Finally, the grayscale complexity of the seamed area is reflected according to the average of the updated gradient values of all pixels in the seamed area, and the seaming quality is evaluated.
[0059] In the embodiment of the present invention, the updated gradient value of each pixel in the sealed area is obtained:
[0060]
[0061] In the formula, Represents the updated gradient value of the i-th pixel in the sealed area; Represents the gradient value of the i-th pixel in the sealed area; Represents the reduction factor of the i-th pixel in the sealed area.
[0062] A quality threshold T2 is preset, and the average of the updated gradient values of all pixels in the seaming area is taken as the seaming quality index. If the seaming quality index is less than the quality threshold, it is considered that the quality of the seaming area meets the standard. Otherwise, the quality of the seaming area does not meet the standard. In an embodiment of the present invention, the preset quality threshold T2=32. In other embodiments, the implementer may preset the value of the quality threshold T2 according to the specific implementation situation.
[0063] The purpose of the present invention is to obtain the reduction factor of each pixel point in the seamed area, that is, the possibility that each pixel point belongs to the grayscale change pixel point of the seamed area itself, correct the gradient value of each pixel point according to the reduction factor, and obtain the updated gradient value of each pixel point in the seamed area. This operation is to reduce the gradient value of the grayscale change pixel point belonging to the seamed area itself, and finally obtain the seaming quality index according to the updated gradient value of each pixel point in the seamed area to evaluate the quality of the seamed area, so that the quality detection result of the seamed area is more accurate.
[0064] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A packaging box sealing quality detection method based on machine vision, characterized in that: include: S1, collecting a packaging box image, and obtaining a sealing area according to the packaging box image; S2, obtaining the gradient value of each pixel in the sealing area; Obtaining the similarity between each pixel point in the sealed area and each pixel point in its eight neighborhoods, wherein the similarity represents the approximation between the gradient value and the gradient direction between the pixel points, including: obtaining the coordinates of the target pixel point of each pixel point in the sealed area; ; In the formula, Represents the similarity between the i-th pixel in the sealed area and the j-th pixel in its eight neighborhoods; Represents the gradient value of the i-th pixel in the sealed area; Represents the gradient value of the jth pixel in the eight-neighborhood of the i-th pixel in the sealed area; ( ) represents the coordinates of the target pixel point of the i-th pixel point in the sealing area; ( ) represents the coordinates of the target pixel of the jth pixel in the eight-neighborhood of the i-th pixel in the sealed area; || represents the absolute value symbol; The step of obtaining the coordinates of the target pixel points of each pixel point in the sealing area includes: Obtain the grayscale difference between the i-th pixel in the sealed area and each pixel in its eight neighborhoods, record the pixel in the eight neighborhoods corresponding to the maximum grayscale difference as the target pixel of the i-th pixel, set the i-th pixel in the sealed area as the origin, and obtain the coordinates of the target pixel of the i-th pixel; S3, performing region growing on the pixels in the sealed area according to the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods, to obtain multiple connected domains in the sealed area; Get the reduction factor of each pixel in the sealed area , where Represents the reduction factor of the i-th pixel in the sealed area; Represents the number of pixels in the connected domain where the i-th pixel in the sealed area is located; Represents the total number of pixels in the sealed area; Represents the maximum value of the similarity between the i-th pixel in the sealed area and all the pixels in its eight neighborhoods; S4, obtaining an updated gradient value for each pixel in the seamed area, wherein the updated gradient value is 1 minus the product of the reduction factor of the pixel in the seamed area and the gradient value of the pixel; obtaining a seaming quality index to evaluate the seaming quality according to the updated gradient value of each pixel in the seamed area, including: presetting a quality threshold T2, taking the average of the updated gradient values of all pixels in the seamed area as the seaming quality index, if the seaming quality index is less than the quality threshold, it is considered that the quality of the seamed area meets the standard, otherwise, the quality of the seamed area does not meet the standard.
2. The packaging box sealing quality detection method based on machine vision according to claim 1 is characterized in that: The step of obtaining the gradient value of each pixel in the sealing area includes: Convolution is performed on each pixel in the sealed area according to the Laplace operator, and the obtained convolution value is used as the gradient value of each pixel in the sealed area.
3. The packaging box sealing quality detection method based on machine vision according to claim 1 is characterized in that: The step of obtaining a plurality of connected domains of the sealing area includes: Based on the similarity between each pixel in the sealed area and each pixel in its eight neighborhoods, a region growing algorithm is used to perform region growing on the pixels in the sealed area to obtain several connected domains in the sealed area.
4. The packaging box sealing quality detection method based on machine vision according to claim 1 is characterized in that: The step of obtaining the sealing area according to the packaging box image includes: A camera is placed on the packaging box sealing production line. After the packaging box is sealed, the packaging box image is collected and semantic segmentation is performed on the packaging box image to obtain the sealing area.
