Visual Inspection Method, Equipment and System for Capping Beverage Bottle Caps
By extracting and analyzing edge feature points in the beverage bottle cap image, calculating gradient distribution index and feature keys, screening feature keys and combining edge symmetry to determine the quality discrimination coefficient, the problem of high computational complexity of traditional detection methods is solved, and more efficient and accurate detection is achieved.
Patent Information
- Application Number
- CN202411811017.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2044-12-10
AI Technical Summary
When handling image matching of beverage bottle caps, the traditional cap detection method has high computational complexity, resulting in a large matching time consumption, affecting the accuracy and efficiency of detection.
By collecting standard cover images and cover images to be tested, the edge feature points are extracted, the gradient distribution index and feature keys are calculated, the feature keys are screened, the edge symmetry is combined, the quality discrimination coefficient is determined, and iterative processing is carried out to detect defects.
It improves the accuracy and efficiency of beverage bottle cap quality detection, reduces noise interference, and improves the efficiency of image matching.
Smart Images

Figure CN119741546B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and specifically to a capping vision detection method, device, and system applied to beverage bottle caps. Background Art
[0002] Beverage bottle caps are a common packaging material and are widely used in industries such as food, medicine, and beverages. Therefore, there are some defects in the capping process of beverage bottle caps, such as high caps, skewed caps, no caps, etc. These defects will affect the sealing performance of beverage bottles, not only affecting product quality, but may even cause food and beverages to be contaminated.
[0003] With the development of industrial automation, in the process of detecting the capping of beverage bottle caps, traditional capping detection methods mainly match images through feature point detection; when matching the capping images of beverage bottles, due to too many and dense feature points extracted, not only will unimportant feature points such as noise in the image be misrecognized as valid, resulting in incorrect matching results, but also the computational complexity in the matching process is high, consuming a large amount of matching time, thereby affecting the accuracy of the matching and the accuracy and efficiency of the quality detection of beverage bottle caps. Summary of the Invention
[0004] To solve the above technical problems, a capping vision detection method, device, and system applied to beverage bottle caps are provided to solve existing problems.
[0005] The solution of this application to solve the technical problems is to provide a capping vision detection method, device, and system applied to beverage bottle caps, including the following steps:
[0006] In a first aspect, an embodiment of this application provides a capping vision detection method applied to beverage bottle caps, and this method includes the following steps:
[0007] Collect the standard capping image after capping the beverage bottle, and the to-be-tested capping images in each orientation; respectively extract the feature points located on the edge contour in the standard capping image and the to-be-tested capping images in each orientation to form a standard edge sequence and the to-be-tested edge sequences corresponding to the to-be-tested capping images in each orientation;
[0008] According to the gradient difference situation between any edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation and the edge feature points in its local neighborhood, and its gradient distribution dispersion situation, determine the gradient distribution index of the any edge feature point;
[0009] Analyze the change situation of the bending angle of the any edge feature point on the corresponding edge contour, and combine with the gradient distribution index to determine the feature key degree of the any edge feature point;
[0010] Determine the edge symmetry degree of the to-be-tested capping image in each direction according to the symmetric change degree of the gradients of all edge feature points in the to-be-tested edge sequence;
[0011] Based on the feature criticality, screen the edge feature points in the to-be-tested edge sequence to obtain each feature key point; analyze the distance differences of the feature key points between the to-be-tested capping images in all directions and the standard capping image, and combine the edge symmetry degree to determine the quality discrimination coefficient of the beverage bottle cap; perform iterative processing on the edge feature points in the to-be-tested edge sequence, re-screen the feature key points, and detect the defects of the beverage bottle cap based on the quality discrimination coefficient obtained after each iteration.
[0012] Preferably, the obtaining methods of the standard edge sequence and the to-be-tested edge sequence corresponding to the to-be-tested capping image in each direction are as follows:
[0013] Adopt a feature point detection algorithm to respectively extract the feature points in the standard capping image and the to-be-tested capping image in each direction; perform edge detection on the standard capping image and the to-be-tested capping image in each direction respectively, and record the edge contour with the largest area as the boundary contour; select the feature points located on the boundary contour and record them as edge feature points;
[0014] Taking the edge feature points at the preset positions in the standard capping image and the to-be-tested capping image in each direction as the starting points, successively form the standard edge sequence and the to-be-tested edge sequence corresponding to the to-be-tested capping image in each direction with all the edge feature points in the standard capping image and the to-be-tested capping image in each direction.
[0015] Preferably, the determination of the gradient distribution index of any edge feature point includes:
[0016] Taking the any edge feature point as the center, set a local window with a preset size; calculate the dispersion degree of the gradients of all edge feature points in the local window of the any edge feature point;
[0017] Calculate the difference between the gradient of the any edge feature point and the gradients of each edge feature point in its local window, and record it as the gradient difference. Record the average gradient difference between the any edge feature point and all edge feature points in its local window as the average gradient difference of the any edge feature point;
[0018] Take the product of the dispersion degree and the average gradient difference as the gradient distribution index of the any edge feature point.
[0019] Preferably, the determination of the feature criticality of any edge feature point includes:
[0020] Taking the pixel point at the preset position in the image of the cap to be measured in each orientation as the coordinate origin, a rectangular coordinate system is constructed;
[0021] Perform linear fitting on the position coordinates of multiple edge pixel points on the left side of any one edge feature point on the boundary contour in the image of the cap to be measured in each orientation, and select a coordinate position from the fitting line, denoted as the left coordinate point;
[0022] Perform linear fitting on the position coordinates of multiple edge pixel points on the right side of any one edge feature point on the boundary contour in the image of the cap to be measured in each orientation, and select a coordinate position from the fitting line, denoted as the right coordinate point;
[0023] Denote the direction vectors between the position coordinates of any one edge feature point and the left coordinate point and the right coordinate point as the left vector and the right vector respectively; Take the cosine value of the angle between the left vector and the right vector as the corner point characterization degree of any one edge feature point;
[0024] Take the product of the gradient distribution index and the corner point characterization degree as the feature key degree of any one edge feature point.
[0025] Preferably, the determining the edge symmetry degree of the image of the cap to be measured in each orientation includes:
[0026] Reverse the edge feature points in the to-be-tested edge sequence, denoted as the reversed edge sequence; The differences between the gradients of the edge feature points in the same dimension of the to-be-tested edge sequence and its reversed edge sequence form a relative difference sequence;
[0027] Calculate the sum of all elements in the relative difference sequence; Take the result of the exponential function with the natural constant as the base and the opposite number of the sum as the exponent as the edge symmetry degree of the image of the cap to be measured in each orientation.
[0028] Preferably, the obtaining the characteristic key points includes:
[0029] Denote the edge feature points in the to-be-tested edge sequence corresponding to the image of the cap to be measured in each orientation whose feature key degree is greater than or equal to the preset initial threshold as the characteristic key points.
[0030] Preferably, the determining the quality discrimination coefficient of the beverage cap includes:
[0031] The calculation method of the relative matching degree of the image of the cap to be measured in each orientation is: Among them, PP k is the relative matching degree of the image of the cap to be measured in the kth orientation, ds k is the edge symmetry degree of the image of the cap to be measured in the kth orientation, A k,gis the position coordinate of the g-th feature key point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in the k-th orientation, B g is the position coordinate of the g-th edge feature point in the standard edge sequence corresponding to the standard capping image, d() represents calculating the distance, m k is the number of all feature key points in the to-be-tested edge sequence corresponding to the to-be-tested capping image in the k-th orientation, expδ() is the exponential function with the natural constant as the base;
[0032] Take the mean value of the relative matching degrees of the to-be-tested capping images in all orientations as the quality discrimination coefficient of the beverage bottle cap.
[0033] Preferably, perform iterative processing on the edge feature points in the to-be-tested edge sequence, re-screen the feature key points, and detect the defects of the beverage bottle cap based on the quality discrimination coefficient of each iteration, including:
[0034] If the quality discrimination coefficient is greater than or equal to the preset first threshold, the beverage bottle cap has no defect. Otherwise, iteratively adjust the preset initial threshold, and the adjustment threshold for each iteration is: α u = a0 - u×Δa, where α u is the adjustment threshold for the u-th iteration, a0 is the preset initial threshold, u is the number of iterations, and Δa is the preset step size;
[0035] Based on the adjustment threshold of each iteration, re-screen the feature key points from the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation, and calculate the quality discrimination coefficient of the beverage bottle cap for each iteration;
[0036] The calculation method of the iteration effectiveness for each iteration is: where f u+1 is the iteration effectiveness for the (u + 1)-th iteration, δ u+1 is the quality discrimination coefficient of the beverage bottle cap for the (u + 1)-th iteration, δ u is the quality discrimination coefficient of the beverage bottle cap for the u-th iteration;
[0037] If the iteration effectiveness is less than the preset second threshold, stop the iteration. If the quality discrimination coefficient of the beverage bottle cap in the previous iteration is less than the preset first threshold, the beverage bottle cap has a defect. Otherwise, the beverage bottle cap has no defect.
[0038] In a second aspect, the embodiments of the present application further provide a capping vision detection device applied to a beverage bottle cap. A computer program is stored in the device, and the computer program is executed by a processor to implement the steps of any one of the above-mentioned capping vision detection methods applied to a beverage bottle cap.
[0039] In a third aspect, an embodiment of the present application further provides a capping vision detection system applied to a beverage bottle cap, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of the capping vision detection method applied to the beverage bottle cap described in any one of the above are implemented.
[0040] The present application has at least the following beneficial effects:
[0041] According to the gradient difference between any edge feature point in the edge sequence to be measured corresponding to the image of the capping to be measured in each direction and the edge feature points in its local neighborhood, and the discrete situation of its gradient distribution, the gradient distribution index of the any edge feature point is determined. The beneficial effect is that it considers the gradient change situation of the edge feature points corresponding to different positions in the image of the capping to be measured, so as to reflect the complexity of the gradient distribution of the corresponding edge feature point and the other edge feature points, and further illustrate the uniqueness of the corresponding edge feature point; analyze the change situation of the bending angle of the any edge feature point on the corresponding edge contour, and combine the gradient distribution index to determine the feature criticality of the any edge feature point. The beneficial effect is that it considers the change situation of the bending angle at the corresponding position of the edge feature point on the edge contour where the edge feature point is located, so as to reflect the possibility that the corresponding edge feature point is a corner point, and further illustrate the importance degree of the feature information contained in the corresponding edge feature point; according to the symmetry change degree of the gradients of all edge feature points in the edge sequence to be measured, determine the edge symmetry degree of the image of the capping to be measured in each direction. The beneficial effect is that it considers the symmetry situation of the gradient changes of different edge feature points, reflects the symmetry situation of the bottle cap in the image of the capping to be measured, and illustrates the possibility of the beverage bottle cap being tilted in the image of the capping to be measured; based on the feature criticality, screen the edge feature points in the edge sequence to be measured to obtain each feature key point; analyze the distance difference of the feature key points between the images of the capping to be measured in all directions and the standard capping image, and combine the edge symmetry degree to determine the quality discrimination coefficient of the beverage bottle cap. The beneficial effect is that it considers the matching situation between the images of the capping to be measured in different directions and the standard capping image, so as to reflect whether there are defects in the beverage bottle cap; perform iterative processing on the edge feature points in the edge sequence to be measured, re-screen the feature key points, and based on the quality discrimination coefficient obtained after each iteration, detect the defects of the beverage bottle cap. The beneficial effect is that by continuously screening the feature key points, the interference of unimportant feature points such as noise is reduced, the accuracy of the quality detection of the beverage bottle cap can be improved, and the efficiency of image matching is conducive to being improved. Description of the Drawings
[0042] The following further describes in detail the capping vision detection method applied to the beverage bottle cap of the present application with reference to the drawings.
[0043] Figure 1It is a flowchart of the steps of the capping vision detection method applied to beverage bottle caps provided by the embodiments of the present application;
[0044] Figure 2 It is a flowchart of the steps of the method for obtaining the gradient distribution index of any edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation provided by the embodiments of the present application;
[0045] Figure 3 It is a flowchart of the steps of the method for obtaining the feature key degree of any edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation provided by the embodiments of the present application. Detailed implementation manners
[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the capping vision detection method, device and system applied to beverage bottle caps proposed in the present application will be further described in detail below with reference to the accompanying drawings and implementation examples. It should be understood that the specific implementation examples described herein are only used to explain the present application and are not used to limit the present application.
[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs.
[0048] Please refer to Figure 1 , which shows a flowchart of the steps of the capping vision detection method applied to beverage bottle caps provided by an embodiment of the present application. The method includes the following steps:
[0049] Step 1, collect the standard capping image after capping the beverage bottle, and the to-be-tested capping images in each orientation.
[0050] Through an industrial camera, collect the standard capping image of the beverage bottle during the beverage production process; secondly, place industrial cameras at multiple orientations at the outlet of the capping process of the beverage bottle, collect the capping images of the beverage bottles at different orientations on the conveyor belt, and perform denoising and grayscale processing on the collected images to obtain the standard capping image and the to-be-tested capping images in each orientation;
[0051] Preferably, in this embodiment, 4 industrial cameras are placed around the beverage bottle to collect the capping images in four orientations. Secondly, the median filtering algorithm is used for denoising. Among them, the median filtering algorithm is a well-known technology and will not be elaborated here. As other implementation manners, implementers can use other methods of the existing technology, such as the mean filtering algorithm, etc. This embodiment does not make special restrictions on this.
[0052] So far, the standard capping image and the to-be-tested capping images in each orientation are obtained.
[0053] Step 2: Determine the gradient distribution index of any edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation according to the gradient difference between any edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation and the edge feature points in its local neighborhood, and the discrete situation of its gradient distribution.
[0054] Edges are important features of the shape and contour of an object. By extracting edge information, the appearance at the beverage bottle cap can be identified more accurately. Feature points are areas with obvious changes in the image and are important features of the object, which can effectively describe the shape and structure of the beverage bottle cap.
[0055] Adopt a feature point detection algorithm to extract the feature points in the standard capping image and the to-be-tested capping images in each orientation respectively;
[0056] Preferably, in this embodiment, the SIFT (Scale Invariant Feature Transform) algorithm is used for feature point detection. Among them, the SIFT algorithm is a well-known technology and will not be elaborated here. As other implementation manners, implementers can adopt other methods of the prior art, such as the SURF algorithm, etc. This embodiment does not make special restrictions on this.
[0057] Perform edge detection on the standard capping image and the to-be-tested capping images in each orientation respectively, and record the edge contour with the largest area as the boundary contour; select the feature points located on the boundary contour and record them as edge feature points;
[0058] Taking the edge feature point at the bottom leftmost position in the standard capping image and the to-be-tested capping images in each orientation as the starting point, in the clockwise order, respectively form the standard edge sequence and the to-be-tested edge sequences corresponding to the to-be-tested capping images in each orientation from all the edge feature points in the standard capping image and the to-be-tested capping images in each orientation;
[0059] Preferably, in this embodiment, the canny edge detection algorithm is used for edge detection. Among them, the canny edge detection algorithm is a well-known technology and will not be elaborated here. As other implementation manners, implementers can adopt other methods of the prior art, such as the sobel operator, etc. This embodiment does not make special restrictions on this.
[0060] The step flow chart of the method for obtaining the gradient distribution index of any edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each orientation provided by the embodiment of the present application is as Figure 2 shown.
[0061] Furthermore, the gradient of the edge information on the beverage bottle body usually exhibits a large grayscale gradient change, and with the shape changes of the bottle body and the bottle mouth, the feature points at different positions show inconsistent grayscale gradients. Therefore, by analyzing the local gradient changes of the edge feature points in the edge sequence to be measured, the gradient distribution index is determined, specifically as follows:
[0062] Taking any edge feature point in the edge sequence to be measured corresponding to the capping image to be measured in each azimuth as the center, a local window with a preset size is set;
[0063] Preferably, in this embodiment, the size of the local window is set to 11. As other implementation manners, the implementer can set it according to the actual situation.
[0064] Calculate the degree of dispersion of the gradients of all edge feature points within the local window of the any edge feature point;
[0065] Preferably, in this embodiment, calculate the information entropy of the gradients of all edge feature points within the local window of the any edge feature point. Among them, the calculation of the information entropy is a well-known technology and will not be elaborated here. As other implementation manners, the implementer can use other methods in the prior art to measure the degree of dispersion, such as variance, standard deviation, coefficient of variation, etc. This embodiment does not make special restrictions on this.
[0066] Calculate the difference between the gradient of the any edge feature point and the gradients of each edge feature point within its local window, denoted as the gradient difference, and denote the mean value of the gradient differences between the any edge feature point and all edge feature points within its local window as the average gradient difference of the any edge feature point;
[0067] Preferably, in this embodiment, calculate the absolute value of the difference between the gradient of the any edge feature point and the gradients of each edge feature point within its local window, and denote the mean value of the absolute values between the any edge feature point and all edge feature points within its local window as the average gradient difference of the any edge feature point.
[0068] Take the product of the degree of dispersion and the average gradient difference as the gradient distribution index of the any edge feature point in the edge sequence to be measured corresponding to the capping image to be measured in each azimuth;
[0069] Preferably, in this embodiment, the calculation formula of the gradient distribution index of the any edge feature point in the edge sequence to be measured corresponding to the capping image to be measured in each azimuth is: where, F k,i is the gradient distribution index of the i-th edge feature point in the edge sequence to be measured corresponding to the capping image to be measured in the k-th azimuth, σ k,iis the degree of dispersion of the gradients of all edge feature points within the local window of the $i$-th edge feature point in the sequence of edges to be measured corresponding to the image of the capping to be measured in the $k$-th orientation, that is, the information entropy, $t$ k,i is the gradient of the $i$-th edge feature point in the sequence of edges to be measured corresponding to the image of the capping to be measured in the $k$-th orientation, $t$ k,j the gradient of the $j$-th edge feature point in the sequence of edges to be measured corresponding to the image of the capping to be measured in the $k$-th orientation, $n$ k is the number of all edge feature points in the sequence of edges to be measured corresponding to the image of the capping to be measured in the $k$-th orientation; secondly, is the average gradient difference.
[0070] It should be noted that the greater the degree of dispersion, the more drastic the change in the gradients of the edge feature points within the local window, reflecting that the gradient distribution of the edge feature points within the local window is more dispersed; secondly, the greater the value, the greater the change in the gradient difference between the $i$-th edge feature point and the remaining edge feature points within its local window, and the greater the obtained gradient distribution index, indicating that the gradient distribution of the edge feature points within the local window is more complex, reflecting that the corresponding edge feature point is more different from other edge feature points, indicating that the corresponding edge feature point is more unique.
[0071] Thus, the gradient distribution index of any edge feature point in the sequence of edges to be measured corresponding to the image of the capping to be measured in each orientation is obtained.
[0072] Step 3: Analyze the change in the bending angle of the any edge feature point on the corresponding edge contour, and combine the gradient distribution index to determine the feature key degree of the any edge feature point.
[0073] The flowchart of the steps of the method for obtaining the feature key degree of any edge feature point in the sequence of edges to be measured corresponding to the image of the capping to be measured in each orientation provided by the embodiments of the present application is as Figure 3 shown.
[0074] First, when the angle between the curves formed by the edge pixels on the left and right sides of the edge feature point is larger, it indicates that the angle change at the corresponding edge feature point is more gentle. When the angle between the curves formed by the edge pixels on the left and right sides of the edge feature point is smaller, it indicates that the angle change of the corresponding edge feature point is more drastic. The size of the angle formed by the pixel points on both sides reflects the degree of change in the edge information at the bottle mouth feature point. When the angle between the curves at both ends is larger, it indicates that the angle change at the feature point is more gentle. Therefore, analyze the drastic change in the angle at the boundary contour of each edge feature point in the image of the capping to be measured to determine the corner point characterization degree, specifically:
[0075] Taking the pixel point at the bottom leftmost position in the image of the capping to be measured in each orientation as the coordinate origin, a rectangular coordinate system is constructed;
[0076] Perform a linear fitting on the position coordinates of multiple edge pixel points to the left of any one of the edge feature points on the boundary contour in the cap image to be measured for each orientation, and select a coordinate position from the fitting line, denoted as the left coordinate point;
[0077] Perform a linear fitting on the position coordinates of multiple edge pixel points to the right of any one of the edge feature points on the boundary contour in the cap image to be measured for each orientation, and select a coordinate position from the fitting line, denoted as the right coordinate point;
[0078] Preferably, in this embodiment, perform a linear fitting on the position coordinates of 10 edge pixel points to the left of any one of the edge feature points on the boundary contour in the cap image to be measured for each orientation; perform a linear fitting on the position coordinates of 10 edge pixel points to the right of any one of the edge feature points on the boundary contour in the cap image to be measured for each orientation. As other implementation manners, the implementer can set it according to the actual situation. Secondly, the least squares method is used for linear fitting. Among them, the least squares method is a well-known technology and will not be elaborated here.
[0079] Denote the direction vectors between the position coordinates of any one of the edge feature points and the left coordinate point and the right coordinate point as the left vector and the right vector respectively;
[0080] Take the cosine value of the angle between the left vector and the right vector as the corner point characterization degree of any one of the edge feature points;
[0081] It should be noted that the calculation of the angle between vectors is a well-known technology and will not be elaborated here.
[0082] It should be noted that the smaller the corner point characterization degree, the larger the angle between the left vector and the right vector corresponding to the edge feature point, the smoother the change trend of the angle corresponding to the edge feature point, and the more likely it is that the corresponding edge feature point is a smooth transition point; the larger the corner point characterization degree, the smaller the angle between the left vector and the right vector corresponding to the edge feature point, the more extreme the change trend of the angle corresponding to the edge feature point, the greater the possibility that the corresponding edge feature point is a corner point, and the more important the feature information of the corresponding edge feature point is.
[0083] Furthermore, based on the gradient distribution index and the corner point characterization degree, determine the feature key degree, specifically:
[0084] Take the product of the gradient distribution index and the corner point characterization degree as the feature key degree of any one of the edge feature points;
[0085] It should be noted that the larger the obtained feature key degree, the more important the feature information of the corresponding edge feature point, which is beneficial to improving the matching accuracy and calculation efficiency of the subsequent beverage cap features.
[0086] Thus, the feature criticality of any of the edge feature points is obtained.
[0087] Step 4: Determine the edge symmetry degree of the to-be-tested capping image in each direction according to the symmetric change degree of the gradients of all the edge feature points in the to-be-tested edge sequence.
[0088] In the standard capping image, the two sides of the bottle cap are symmetric about the central axis. Therefore, if the elements in the to-be-tested edge sequence in each direction also have symmetry, it reflects that the matching degree between the corresponding to-be-tested capping image and the standard capping image is higher, and the possibility of defects in the to-be-tested capping image is smaller. Therefore, analyze the symmetry of the elements in the to-be-tested edge sequence to determine the edge symmetry degree, specifically:
[0089] Reverse the edge feature points in the to-be-tested edge sequence corresponding to the to-be-tested capping image in each direction, and denote it as the reversed edge sequence.
[0090] Form a relative difference sequence from the differences between the gradients of the edge feature points in the same dimension of the to-be-tested edge sequence and its reversed edge sequence.
[0091] Preferably, in this embodiment, form a relative difference sequence from the sum of the squares of the differences between the gradients of the edge feature points in the same dimension of the to-be-tested edge sequence and its reversed edge sequence.
[0092] Calculate the cumulative sum of all the elements in the relative difference sequence; use the result of the exponential function with the natural constant as the base and the opposite number of the cumulative sum as the exponent as the edge symmetry degree of the to-be-tested capping image in each direction.
[0093] Preferably, in this embodiment, the calculation formula for the edge symmetry degree of the to-be-tested capping image in each direction is: where ds k is the edge symmetry degree of the to-be-tested capping image in the kth direction, t k,h is the gradient of the hth edge feature point in the to-be-tested edge sequence corresponding to the to-be-tested capping image in the kth direction, ft k,h is the gradient of the hth edge feature point in the reversed edge sequence corresponding to the to-be-tested capping image in the kth direction, n k is the number of all the edge feature points in the to-be-tested edge sequence corresponding to the to-be-tested capping image in the kth direction, and exp() is the exponential function with the natural constant as the base.
[0094] It should be noted that for the convenience of understanding, assume that the to-be-tested edge sequence corresponding to the to-be-tested capping image in a certain direction is [a, b, c, d, e], then the reversed edge sequence is [e, d, c, b, a]. If the gradients of the edge feature points a, b, c, d, e are t a , tb , t c , t d , t e , form a relative difference sequence with the differences of the gradients at the corresponding positions between the edge sequence to be measured and the inverted edge sequence as [(t a -t e ) 2 , (t b -t d ) 2 , (t c -t c ) 2 , (t d -t b ) 2 , (t e -t a ) 2 .
[0095] It should be noted that the larger the sum of accumulations, the greater the gradient difference between the edge feature points in the edge sequence to be measured and its inverted edge sequence, the smaller the obtained edge symmetry degree, indicating that the two sides of the bottle cap in the corresponding bottle cap image to be measured are more asymmetric, and the lower the matching degree with the standard bottle cap image, reflecting a greater possibility of defects in the bottle cap packaging process of the bottle cap image to be measured.
[0096] Thus, the edge symmetry degree of the bottle cap image to be measured in each orientation is obtained.
[0097] Step 5: Based on the feature key degree, screen the edge feature points in the edge sequence to be measured to obtain each feature key point; analyze the distance differences of the feature key points between the bottle cap images to be measured in all orientations and the standard bottle cap image, and combine the edge symmetry degree to determine the quality discrimination coefficient of the beverage bottle cap; perform iterative processing on the edge feature points in the edge sequence to be measured, re-screen the feature key points, and detect the defects of the beverage bottle cap based on the quality discrimination coefficient obtained after each iteration.
[0098] Furthermore, based on the feature key degree, perform iterative screening on the edge feature points, specifically:
[0099] Record the edge feature points with the feature key degree greater than or equal to the preset initial threshold in the edge sequence to be measured corresponding to the bottle cap image to be measured in each orientation as feature key points;
[0100] Preferably, in this embodiment, the value of the preset initial threshold is 0.5. As other implementation manners, the implementer can set it according to the actual situation.
[0101] Furthermore, analyze the distance conditions of the feature key points between the bottle cap images to be measured in each orientation and the standard bottle cap image, and combine the edge symmetry degree to determine the relative matching degree, specifically:
[0102] The calculation method for the relative matching degree of the capping images to be measured in each orientation is as follows: Wherein, PP k is the relative matching degree of the capping image to be measured in the k-th orientation, ds k is the edge symmetry degree of the capping image to be measured in the k-th orientation, A k,g is the position coordinate of the g-th feature key point in the to-be-measured edge sequence corresponding to the capping image to be measured in the k-th orientation, B g is the position coordinate of the g-th edge feature point in the standard edge sequence corresponding to the standard capping image, d() represents the calculation of distance, m k is the number of all feature key points in the to-be-measured edge sequence corresponding to the capping image to be measured in the k-th orientation, and exp() is the exponential function with the natural constant as the base.
[0103] It should be noted that the larger the relative matching degree, the more matching between the corresponding capping image to be measured and the standard capping image, and the lower the possibility of quality defects in the corresponding capping image to be measured.
[0104] Furthermore, based on the relative matching degrees of the capping images to be measured in different orientations, the quality discrimination coefficient of the beverage bottle is determined, specifically:
[0105] The mean value of the relative matching degrees of the capping images to be measured in all orientations is used as the quality discrimination coefficient of the beverage bottle cap;
[0106] If the quality discrimination coefficient is greater than or equal to the preset first threshold, there are no defects in the beverage bottle cap. Otherwise, the preset initial threshold is iteratively adjusted, and the adjustment threshold for each iteration is: α u = a0 - u × Δa, where α u is the adjustment threshold for the u-th iteration, a0 is the preset initial threshold, u is the number of iterations, and Δa is the preset step size. In this embodiment, the preset step size Δa is 0.05. As other implementation manners, the implementer can set it according to the actual situation.
[0107] Based on the adjustment threshold for each iteration, the feature key points are re-screened from the to-be-measured edge sequences corresponding to the capping images to be measured in each orientation, and the quality discrimination coefficient of the beverage bottle cap is calculated for each iteration;
[0108] The calculation method for the iteration effectiveness of each iteration is as follows: Wherein, f u+1 is the iteration effectiveness of the (u + 1)-th iteration, δ u+1 is the quality discrimination coefficient of the beverage bottle cap at the (u + 1)-th iteration, and δ u is the quality discrimination coefficient of the beverage bottle cap at the u-th iteration.
[0109] If the iteration effectiveness is less than a preset second threshold, stop the iteration. If the quality discrimination coefficient of the beverage bottle cap during its previous iteration is less than a preset first threshold, the beverage bottle cap is defective; otherwise, the beverage bottle cap is not defective.
[0110] Preferably, in this embodiment, the preset first threshold is set to 0.8, and the preset second threshold is set to 1. As other implementation manners, the implementer can set them according to actual situations.
[0111] The embodiment of the present application also provides a capping vision detection device applied to a beverage bottle cap. A computer program is stored in the device, and when the computer program is executed by a processor, the steps of any one of the above-mentioned capping vision detection methods applied to the beverage bottle cap are implemented.
[0112] Based on the same inventive concept as the above method, the embodiment of the present application also provides a capping vision detection system applied to a beverage bottle cap, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the steps of any one of the above-mentioned capping vision detection methods applied to the beverage bottle cap are implemented.
[0113] It should be understood that although Figure 1 the steps in the flowchart are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 at least a part of the steps in
[0114] can include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these sub-steps or stages is not necessarily sequential either, but can be executed alternately or in turn with at least a part of other steps or sub-steps or stages of other steps.
[0115] The above-described embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation to the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made. Therefore, any simple modifications, equivalent changes, and decorations made to the above embodiments based on the technical essence of the present application without departing from the technical solution of the present application all fall within the protection scope of the technical solution of the present application.
Claims
1. A visual inspection method for beverage bottle caps, characterized in that: The method comprises the following steps: Collect the standard capping image of the beverage bottle after capping, and the capping image to be tested in each orientation; respectively extract the feature points located on the edge contour of the standard capping image and the capping image to be tested in each orientation to form a standard edge sequence and an edge sequence to be tested corresponding to the capping image to be tested in each orientation; Determine the gradient distribution index of any edge feature point in the edge sequence to be tested corresponding to the capping image to be tested in each orientation and the gradient difference of the edge feature points in its local neighborhood, and the discreteness of its gradient distribution; Analyze the change of the bending angle of any edge feature point on the corresponding edge contour, and determine the feature criticality of any edge feature point in combination with the gradient distribution index; Determining the edge symmetry of the capping image to be tested in each orientation according to the degree of symmetric change of the gradients of all edge feature points in the edge sequence to be tested; Based on the feature criticality, the edge feature points in the edge sequence to be tested are screened to obtain each feature key point; the distance difference between the feature key points between the cover image to be tested and the standard cover image in all directions is analyzed, and the quality discrimination coefficient of the beverage bottle cap is determined in combination with the edge symmetry; the edge feature points in the edge sequence to be tested are iteratively processed, the feature key points are re-screened, and the defects of the beverage bottle cap are detected based on the quality discrimination coefficient obtained after each iteration.
2. The capping visual inspection method for beverage bottle caps according to claim 1, characterized in that: The method for acquiring the standard edge sequence and the edge sequence to be tested corresponding to the capping image to be tested in each orientation is as follows: A feature point detection algorithm is used to extract feature points from the standard capping image and the capping image to be tested at each orientation. Edge detection is performed on the standard capping image and the capping image to be tested at each orientation, and the edge contour with the largest area is recorded as the boundary contour. Select the feature points on the boundary contour and record them as edge feature points; Taking the edge feature points at preset positions in the standard capping image and the capping image to be tested in each orientation as starting points, all edge feature points in the standard capping image and the capping image to be tested in each orientation are sequentially combined into a standard edge sequence and an edge sequence to be tested corresponding to the capping image to be tested in each orientation.
3. The capping visual inspection method for beverage bottle caps according to claim 1, characterized in that: The determining of the gradient distribution index of any edge feature point comprises: Taking any edge feature point as the center, a local window of a preset size is set; calculating the discrete degree of the gradients of all edge feature points within the local window of any edge feature point; Calculate the difference between the gradient of any edge feature point and the gradient of each edge feature point in its local window, record it as the gradient difference, and record the average of the gradient differences between any edge feature point and all edge feature points in its local window as the average gradient difference of any edge feature point; The product of the discrete degree and the average gradient difference is used as the gradient distribution index of any edge feature point.
4. The capping visual inspection method for beverage bottle caps according to claim 2, characterized in that: The determining of the feature criticality of any edge feature point comprises: A rectangular coordinate system is constructed by taking the pixel point at a preset position in the capping image to be tested in each orientation as the coordinate origin; Linearly fit the position coordinates of multiple edge pixel points on the left side of any edge feature point on the boundary contour of the capping image to be tested in each orientation, and select a coordinate position from the fitting line, which is recorded as the left coordinate point; Linearly fit the position coordinates of multiple edge pixel points on the right side of any edge feature point on the boundary contour of the capping image to be tested in each orientation, and select a coordinate position from the fitting line, which is recorded as the right side coordinate point; The position coordinates of any edge feature point and the direction vectors between the left coordinate point and the right coordinate point are recorded as the left vector and the right vector respectively; the cosine value of the angle between the left vector and the right vector is used as the corner point characterization degree of any edge feature point; The product of the gradient distribution index and the corner point characterization degree is used as the feature criticality of any edge feature point.
5. The capping visual inspection method for beverage bottle caps according to claim 1, characterized in that: The step of determining the edge symmetry of the capping image to be tested in each orientation includes: The edge feature points in the edge sequence to be tested are reversed to be recorded as a reversed edge sequence; the difference between the gradients of the edge feature points of the same dimension in the edge sequence to be tested and the reversed edge sequence is used to form a relative difference sequence; The cumulative sum of all elements in the relative difference sequence is calculated; and the result of an exponential function with a natural constant as the base and the opposite number of the cumulative sum as the exponent is used as the edge symmetry of the cover image to be tested in each orientation.
6. The capping visual inspection method for beverage bottle caps according to claim 1, characterized in that: The step of obtaining each feature key point includes: The edge feature points whose feature criticality is greater than or equal to a preset initial threshold in the edge sequence to be tested corresponding to the cover image to be tested in each orientation are recorded as feature key points.
7. The capping visual inspection method for beverage bottle caps according to claim 1, characterized in that: The method of determining the quality discrimination coefficient of the beverage bottle cap comprises: The calculation method of the relative matching degree of the capping image to be tested in each orientation is: Among them, PP k is the relative matching degree of the capping image to be tested at the kth orientation, ds k is the edge symmetry of the capping image to be tested at the kth orientation, A k,g is the position coordinate of the gth feature key point in the edge sequence to be tested corresponding to the capping image to be tested at the kth orientation, B g is the position coordinate of the gth edge feature point in the standard edge sequence corresponding to the standard capping image, d() represents the calculated distance, m k is the number of all feature key points in the edge sequence to be tested corresponding to the capping image to be tested at the k-th orientation, and exp() is an exponential function with a natural constant as the base; The average of the relative matching degrees of the capping images to be tested in all directions is used as the quality discrimination coefficient of the beverage bottle cap.
8. The capping visual inspection method for beverage bottle caps according to claim 6, characterized in that: Iteratively processing the edge feature points in the edge sequence to be tested, re-screening the feature key points, and detecting the defects of the beverage bottle cap based on the quality discrimination coefficient of each iteration, including: If the quality discrimination coefficient is greater than or equal to the preset first threshold, the beverage bottle cap does not have defects. Otherwise, the preset initial threshold is iteratively adjusted, and the adjustment threshold of each iteration is: α u =a0-u×Δa, where α u is the adjustment threshold of the u-th iteration, a0 is the preset initial threshold, u is the number of iterations, and Δa is the preset step size; Based on the adjustment threshold of each iteration, the feature key points are re-screened from the edge sequence to be tested corresponding to the capping image to be tested in each orientation, and the quality discrimination coefficient of the beverage bottle cap in each iteration is calculated; The iterative effectiveness of each iteration is calculated as: Among them, f u+1 is the iteration validity of the u+1th iteration, δ u+1 is the quality discrimination coefficient of the beverage bottle cap at the u+1th iteration, δ u is the quality discrimination coefficient of the beverage bottle cap at the uth iteration; If the iteration validity is less than the preset second threshold, the iteration is stopped. If the quality discrimination coefficient of the beverage bottle cap in the previous iteration is less than the preset first threshold, the beverage bottle cap is defective. Otherwise, the beverage bottle cap is not defective.
9. A visual inspection device for beverage bottle caps, wherein a computer program is stored in the device, characterized in that: When the computer program is executed by a processor, the steps of the cap visual inspection method applied to beverage bottle caps as claimed in any one of claims 1 to 8 are implemented.
10. A capping visual inspection system for beverage bottle caps, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the steps of the cap visual inspection method applied to beverage bottle caps as claimed in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Hardware defect classification and identification method based on artificial intelligence
CN117237747A
Bottled product sealing cover detection method based on deep learning
CN118298247A