Seasoning packet packaging integrity detection method and system based on machine vision
Through the combination of multispectral image acquisition and edge and texture feature analysis, the CatBoost model is constructed, which solves the problem of unstable packaging detection effect in the existing technology, realizes high accuracy detection of packaging integrity and subtle defects, and improves the packaging pipeline quality control.
Patent Information
- Application Number
- CN202411570322.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2024-12-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, single spectral image and fixed threshold algorithm are mostly used to detect the packaging area. The lack of in-depth analysis of subtle defects on the packaging surface, making it difficult to deal with complex packaging situations, resulting in unstable detection effect and reducing the detection accuracy of packaging integrity. .
Using multispectral image acquisition and filtering, combined with edge detection algorithm and phase correlation method, a packaged edge line image and texture feature map is generated, and the CatBoost model is constructed. Based on the comprehensive feature vector, the integrity probability is predicted, the integrity deviation and probability are analyzed, and the integrity deviation and probability are analyzed. Exclusion of complete seasoning package.
Through the multi-dimensional detection method, the overall integrity of the packaging surface and the ability to identify subtle defects are improved, the accuracy and stability of the detection are improved, and the quality control level of the packaging assembly line is enhanced.
Smart Images

Figure CN119068270A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of visual inspection, and in particular to a method and system for inspecting the packaging integrity of a seasoning packet based on machine vision. Background Art
[0002] With the rapid development of the food industry and the increasing demand for packaging automation, the application of machine vision in packaging quality inspection has gradually attracted attention, especially in the field of packaging integrity inspection. Machine vision technology is widely used in automated production lines. Traditional packaging inspection methods mostly rely on manual observation or simple mechanical detection equipment, but these methods are limited by human errors, inconsistencies and low detection accuracy, and are difficult to adapt to the needs of modern assembly line high-speed production. With the development of image processing technology and machine learning algorithms, machine vision inspection technology has gradually become an effective alternative. However, the existing technology mostly uses a single spectral image and a fixed threshold algorithm for packaging area detection, lacks in-depth analysis of subtle defects on the packaging surface, and is difficult to cope with complex packaging situations. At the same time, traditional inspection schemes still have deficiencies in texture feature extraction and accurate identification of packaging contours, and are easily affected by image quality fluctuations, resulting in unstable detection results, thereby reducing the accuracy of packaging integrity detection. Summary of the invention
[0003] In view of the problems existing in the above-mentioned existing seasoning packet packaging integrity detection method and system based on machine vision, the present invention is proposed.
[0004] Therefore, the problem to be solved by the present invention is that the prior art mostly uses a single spectral image and a fixed threshold algorithm to perform packaging area detection, lacks in-depth analysis of subtle defects on the packaging surface, and is difficult to cope with complex packaging situations. At the same time, traditional detection schemes still have deficiencies in texture feature extraction and accurate identification of packaging contours, and are easily affected by fluctuations in image quality, resulting in unstable detection results, thereby reducing the accuracy of detection of packaging integrity.
[0005] In order to solve the above technical problems, the present invention provides the following technical solutions: a method for detecting the integrity of a seasoning package based on machine vision, comprising: Collect machine vision image data and perform filtering processing; Use edge detection algorithm to calculate gradient amplitude and gradient direction, perform double threshold determination, and generate package edge line image; Use phase correlation method to align the target image with the reference image, calculate LBP value to generate vertical vector, and analyze integrity deviation; Construct a CatBoost model to predict the completeness probability based on the comprehensive feature vector; Based on the integrity deviation and integrity probability analysis, the comprehensive integrity is determined, incomplete seasoning packages are eliminated, and data reports on incomplete seasoning packages are generated.
[0006] As a preferred solution of the seasoning package integrity detection method based on machine vision of the present invention, the collecting of machine vision image data and filtering processing include: The packaging line based on seasoning packets uses a multispectral camera to collect image data based on machine vision; The collected image data includes RGB images and IR images, and image data including multiple spectral layers are generated based on the continuously collected image data; The RGB and IR data are fused to generate a multi-dimensional image matrix, and the fusion values between each layer are calculated by weighted average; Convert the multispectral image into a grayscale image, perform histogram equalization, and enhance the local contrast of the image; Perform Gaussian filtering on the image to denoise the image data.
[0007] As a preferred solution of the seasoning package integrity detection method based on machine vision of the present invention, the edge detection algorithm is used to calculate the gradient amplitude and gradient direction, perform double threshold determination, and generate a package edge line image, including: Using the Canny edge detection algorithm, the Sobel operator is used to calculate the horizontal and vertical gradients of the image data, expressed as: ; ; in and Represent the gradient of the image in the horizontal and vertical directions respectively, and Respectively represent the convolution kernel of the Sobel operator in the horizontal and vertical directions, Represents the pixel value of the image at coordinate (xi, yj) after Gaussian filtering; Calculate the gradient magnitude G and gradient direction θ, expressed as: ; ; Where G represents the gradient amplitude, θ represents the gradient direction, and arc represents the arctan inverse tangent function; According to each pixel point (x, y), the corresponding gradient magnitude G and gradient direction θ are calculated, and the adjacent pixel points in the gradient direction are calculated using bilinear interpolation; For each pixel point (x, y), if its gradient magnitude G(x, y) is greater than the gradient magnitude G of the adjacent pixel, the pixel value is retained; if its gradient magnitude G(x, y) is less than or equal to the gradient magnitude G of the adjacent pixel, the pixel is set to 0; Based on historical data, double threshold processing is performed on the gradient amplitude. Based on the calculation of the gradient amplitude G, an array of the gradient amplitudes of all pixels is constructed, and the upper percentile value 90 is selected as the high threshold, and the lower percentile value 10 is selected as the low threshold; If the gradient amplitude G is greater than the high threshold, it is marked as a strong edge. If the gradient amplitude is less than or equal to the high threshold and greater than the low threshold, it is marked as a weak edge. If the gradient amplitude G is less than or equal to the low threshold, it is marked as background. Based on the weak edge pixel, check whether the 8 pixels around it contain a strong edge pixel. If any adjacent pixel is a strong edge, retain the weak edge point as the final edge pixel; Based on strong edges and connected weak edges, complete encapsulated edge lines are formed to generate the final generated image.
[0008] As a preferred solution of the seasoning package integrity detection method based on machine vision of the present invention, the method of aligning the target image with the reference image using the phase correlation method, calculating the LBP value to generate the orthogonal vector, and analyzing the integrity deviation includes: Select a reference image containing a standard package and perform image registration on the target image based on the package outline detected by edge detection; Using the phase correlation method, the target image and the reference image are fast Fourier transformed to obtain the frequency domain representation of the target image and the reference image. and ; Fourier transform of the target image Multiply it with the conjugate Fourier transform of the reference image and normalize it to calculate the phase correlation result, which is expressed as: ; in and are the Fourier transforms of the target image and the reference image, respectively. for The conjugate of represents the phase correlation result; Phase correlation results Perform inverse Fourier transform to obtain a peak position image, use the position coordinates of the maximum peak as the translation amount of the target image relative to the reference image, and perform translation compensation on the target image to achieve alignment with the reference image; Image cropping is performed based on the package outline width of the seasoning package production standard; Calculate the local binary pattern for each pixel and get the center pixel for the pixel (x, y) Gray value, select a neighborhood with a radius of 1, calculate the gray difference of each adjacent pixel, and convert it into a binary value; Based on the binary bits corresponding to the binarization operation results, the pixel positions are numbered from 0 to 7, and the binary weight is determined according to each position number k: ; Use binary weights to assign position weights to each neighborhood pixel, and combine these binary values into LBP values, expressed as: ; in Represents the LBP value of the pixel (x, y), Represents the binarization result at position number k; Record the LBP value of each pixel to form a texture feature map of the entire packaging area; Traverse each pixel point of the texture feature map, read the LBP value of the point, use the LBP value as the index, add 1 to the frequency of the corresponding position, repeat the above operation until all pixels in the complete encapsulation area are traversed, complete the statistics of the frequency of occurrence of each LBP value, and form the vertical vector H, which is normalized and expressed as: ; in represents the normalized frequency of the i-th LBP value in the encapsulation area, and They represent the frequencies of occurrence of the i-th and j-th LBP values in the encapsulation area respectively; The normalized vertical vector is compared with the standard texture sample, and the Euclidean distance D between the normalized vertical vector of the encapsulated area and the standard sample is calculated, which is expressed as: ; Where D represents the Euclidean distance between the package area and the normalized rectangular vector of the standard sample, represents the normalized frequency of the i-th LBP value in the encapsulation area, represents the normalized frequency of the i-th LBP value in the standard sample; The sum of the average value and the standard deviation of the historical Euclidean distance is used as the comparison threshold. If the calculated Euclidean distance is greater than or equal to the comparison threshold, it is judged that the texture feature of the packaging area has a large deviation from the integrity of the standard sample.
[0009] As a preferred solution of the seasoning package integrity detection method based on machine vision of the present invention, wherein: the CatBoost model is constructed to predict the integrity probability based on the comprehensive feature vector, including: The normalized vertical vector is defined as a texture feature vector, and the shape feature vector is formed according to the perimeter, area, and compactness of the standard packaging area of the seasoning package. The texture feature vector and the shape feature vector are combined into a comprehensive feature vector F; Construct a CatBoost model, including an input layer, a decision tree layer, and an output layer. The input layer inputs a comprehensive feature vector F; the decision tree layer is an integrated layer composed of multiple decision trees, each tree learns and adjusts the classification boundary, and the output layer outputs an incomplete probability value; Use the training set and validation set to train the model, select Logloss as the loss function, and gradually build decision trees. Each tree learns the residual of the previous tree, and gradually optimizes the model parameters. Enable early stopping on the validation set. When the loss no longer decreases significantly within several rounds, stop training to avoid overfitting. Based on the new input comprehensive feature vector, the CatBoost model predicts the completeness probability.
[0010] As a preferred solution of the seasoning package integrity detection method based on machine vision of the present invention, wherein: the comprehensive integrity based on integrity deviation and integrity probability analysis includes: Based on the completeness probability and Euclidean distance D predicted by the CatBoost model, comprehensive completeness detection is performed, which is expressed as: ; Where V represents comprehensive completeness, and p represents the completeness probability predicted by the CatBoost model; An integrity score threshold is set according to the packaging integrity requirements of the seasoning package. If V is greater than or equal to the integrity score threshold, the package is judged to be complete. If V is less than the integrity score threshold, the package is judged to be incomplete and the corresponding seasoning package is marked as incomplete.
[0011] As a preferred solution of the seasoning package integrity detection method based on machine vision of the present invention, the step of removing incomplete seasoning packages and generating a data report of incomplete seasoning packages includes: The rejecting device is driven based on the control signal of the packaging assembly line to reject the seasoning package marked as incomplete from the assembly line; Statistics are collected based on the number of rejected seasoning packets, and the alarm threshold is dynamically set according to the production yield requirements. If the number of rejected seasoning packets is greater than or equal to the alarm threshold, an audible and visual alarm is issued, and the sample ID, detection time, and integrity score data of the rejected seasoning packets are counted, and a report is generated through a chart tool.
[0012] Another object of the present invention is to provide a system for detecting the integrity of a seasoning package based on machine vision, which comprises: The data processing module uses a machine vision device to collect the image of the seasoning package and performs filtering on the collected image data; The contour extraction module uses an edge detection algorithm to perform edge detection on the preprocessed image and generate an edge line image of the encapsulation area; Texture feature analysis module uses phase correlation method to align the target image with the reference image, calculates the LBP value of each pixel, and generates a vertical vector for comparison with the standard sample; The integrity detection module uses the trained CatBoost model to perform integrity prediction; The alarm module removes incomplete seasoning packages from the production line and issues an alarm; The data recording module records the relevant data of each incomplete seasoning package, counts and generates corresponding reports.
[0013] A computer device comprises: a memory and a processor; the memory stores a computer program, and the processor implements the steps of the above-mentioned seasoning package packaging integrity detection method based on machine vision when executing the computer program.
[0014] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned seasoning package packaging integrity detection method based on machine vision.
[0015] The beneficial effects of the present invention are as follows: by combining the edge detection algorithm with the dual threshold mechanism, the defects in the packaging area are made more obvious, and the generated packaging edge line image not only shows the overall outline of the packaging area, but also highlights the tiny packaging defects, which is helpful for the accurate identification of packaging integrity detection. The target image and the reference image are registered by the phase correlation method, the translation amount is quickly calculated and the alignment processing is performed, and the local texture features of the surface of the packaging area can be captured by calculating the LBP value of each pixel, which is convenient for identifying the slight changes in the texture consistency of the packaging surface, and the ability to identify subtle defects is improved. By combining the precise alignment of the phase correlation method, the texture feature analysis of the LBP value and the quantitative comparison of the Euclidean distance, a multi-dimensional detection method is formed. The detection scheme can not only effectively determine the overall integrity of the packaging surface, but also accurately detect subtle packaging defects, providing a comprehensive detection means for packaging quality control and improving the quality control level of the packaging assembly line. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0017] Figure 1 The figure is a flow chart of the seasoning package packaging integrity detection method based on machine vision.
[0018] Figure 2 This is a structural diagram of the seasoning package integrity detection system based on machine vision. DETAILED DESCRIPTION
[0019] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.
[0020] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0021] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor is it a separate or selective embodiment that is mutually exclusive with other embodiments.
[0022] Example 1, reference Figure 1 , which is the first embodiment of the present invention, and provides a seasoning packet packaging integrity detection method based on machine vision. The seasoning packet packaging integrity detection method based on machine vision includes: S1, collect machine vision image data and perform filtering processing; Preferably, collecting machine vision image data and performing filtering processing includes: The packaging line based on seasoning packets uses a multispectral camera to collect image data based on machine vision; The collected image data includes RGB images and IR images, and image data including multiple spectral layers are generated based on the continuously collected image data; The RGB and IR data are fused to generate a multi-dimensional image matrix, and the fusion values between each layer are calculated by weighted average; Convert the multispectral image into a grayscale image, perform histogram equalization, and enhance the local contrast of the image; Perform Gaussian filtering on the image to denoise the image data.
[0023] By combining RGB (visible light) and IR (infrared light) data, we can capture multi-level information about the packaging area of the seasoning package, and identify subtle defects that are difficult to observe under a single spectrum. The multispectral image is converted into a grayscale image and histogram equalization is performed to improve the local contrast of the image and make the low-contrast area more prominent. Gaussian filtering denoising can smooth the image, remove background noise and irregular lighting effects, and retain the key structural information of the image. Denoising reduces false detections caused by noise, improves the stability and reliability of the detection process, and makes the detection of packaging defects more accurate.
[0024] S2, using edge detection algorithm, calculates gradient amplitude and gradient direction, performs double threshold determination, and generates a package edge line image; Preferably, an edge detection algorithm is used to calculate the gradient amplitude and gradient direction, and a double threshold determination is performed to generate a package edge line image, including: Using the Canny edge detection algorithm, the Sobel operator is used to calculate the horizontal and vertical gradients of the image data, expressed as: ; ; in and Represent the gradient of the image in the horizontal and vertical directions respectively, and Respectively represent the convolution kernel of the Sobel operator in the horizontal and vertical directions, Represents the pixel value of the image at coordinate (xi, yj) after Gaussian filtering; Calculate the gradient magnitude G and gradient direction θ, expressed as: ; ; Where G represents the gradient amplitude, θ represents the gradient direction, and arc represents the arctan inverse tangent function; According to each pixel point (x, y), the corresponding gradient magnitude G and gradient direction θ are calculated, and the adjacent pixel points in the gradient direction are calculated using bilinear interpolation; For each pixel point (x, y), if its gradient magnitude G(x, y) is greater than the gradient magnitude G of the adjacent pixel, the pixel value is retained; if its gradient magnitude G(x, y) is less than or equal to the gradient magnitude G of the adjacent pixel, the pixel is set to 0; By screening the local maximum in the gradient direction, the weak edges caused by noise can be effectively removed, making the edge lines clearer and reducing misjudgment; Based on historical data, double threshold processing is performed on the gradient amplitude. Based on the calculation of the gradient amplitude G, an array of the gradient amplitudes of all pixels is constructed, and the upper percentile value 90 is selected as the high threshold, and the lower percentile value 10 is selected as the low threshold; If the gradient amplitude G is greater than the high threshold, it is marked as a strong edge. If the gradient amplitude is less than or equal to the high threshold and greater than the low threshold, it is marked as a weak edge. If the gradient amplitude G is less than or equal to the low threshold, it is marked as background. Based on the weak edge pixel, check whether the 8 pixels around it contain a strong edge pixel. If any adjacent pixel is a strong edge, retain the weak edge point as the final edge pixel; Based on strong edges and connected weak edges, a complete encapsulated edge line is formed to generate the final generated image; The weak edge connection effectively enhances the continuity of the edge structure, allowing the package edge to form a completely closed edge line, which is more suitable for detecting the sealing integrity.
[0025] By using the Canny edge detection algorithm, combined with the gradient information calculated by the Sobel operator, the change area of the package edge can be quickly located, and the package edge and background can be accurately separated. The edge detection method can identify subtle changes in the package area, so that package defects (such as edge damage or wrinkles) are presented more clearly, improving the accuracy of defect recognition. The high and low double thresholds are set using the statistical information of historical data, and the edges above the high threshold are marked as strong edges to ensure that clear package edge lines are detected; low-threshold weak edge processing can retain some potential defective edges. The dual threshold mechanism improves the overall clarity and accuracy of the edge image, avoids excessive edge noise interference, and makes the package edge more coherent and stable. The local maximum screening based on the gradient direction effectively removes the noise edge and weak edge, retaining only the clear edge contour, significantly reducing the false detection, helping to suppress random noise in the image, ensuring the stability of package detection, and making the detection more reliable. By detecting the connectivity of weak edge pixels, it is ensured that the weak edge pixels around each strong edge pixel are also retained to form a coherent package edge. When processing package images through the Canny edge detection algorithm, the defects in the package area are made more obvious through the combination of strong edges and weak edges. The generated package edge line image not only shows the overall outline of the package area, but also highlights tiny package defects, which helps to accurately identify package integrity detection and improve the quality control level of the package assembly line detection system.
[0026] S3, align the target image with the reference image using the phase correlation method, calculate the LBP value to generate the vertical vector, and analyze the integrity deviation; Preferably, the target image is aligned with the reference image using a phase correlation method, the LBP value is calculated to generate a vertical vector, and the integrity deviation is analyzed, including: Select a reference image containing a standard package and perform image registration on the target image based on the package outline detected by edge detection; Using the phase correlation method, the target image and the reference image are fast Fourier transformed to obtain the frequency domain representation of the target image and the reference image. and ; Fourier transform of the target image Multiply it with the conjugate Fourier transform of the reference image and normalize it to calculate the phase correlation result, which is expressed as: ; in and are the Fourier transforms of the target image and the reference image, respectively. for The conjugate of represents the phase correlation result; Phase correlation results Perform inverse Fourier transform to obtain a peak position image, use the position coordinates of the maximum peak as the translation amount of the target image relative to the reference image, and perform translation compensation on the target image to achieve alignment with the reference image; Image cropping is performed based on the package outline width of the seasoning package production standard; Calculate the local binary pattern for each pixel and get the center pixel for the pixel (x, y) Gray value, select a neighborhood with a radius of 1, calculate the gray difference of each adjacent pixel, and convert it into a binary value; For each pixel in the neighborhood , get its gray value And calculate the difference with the center pixel ; Perform binarization operation, if the difference If it is greater than or equal to 0, it is represented as 1, otherwise it is 0. The binary operation is represented as a function ; Based on the binary bits corresponding to the binarization operation results, the pixel positions are numbered from 0 to 7, and the binary weight is determined according to each position number k: ; Use binary weights to assign position weights to each neighborhood pixel, and combine these binary values into LBP values, expressed as: ; in Represents the LBP value of the pixel (x, y), Represents the binarization result at position number k; Record the LBP value of each pixel to form a texture feature map of the entire packaging area; Traverse each pixel point of the texture feature map, read the LBP value of the point, use the LBP value as the index, add 1 to the frequency of the corresponding position, repeat the above operation until all pixels in the complete encapsulation area are traversed, and the frequency of each LBP value is counted. (Each LBP value refers to a specific texture pattern obtained by LBP (local binary pattern) encoding. Each LBP value corresponds to a unique binary code, which is converted into a decimal number (such as 154) and is called an LBP value or pattern), and form a vertical vector H, which is normalized and expressed as: ; in represents the normalized frequency of the i-th LBP value in the encapsulation area, and They represent the frequencies of occurrence of the i-th and j-th LBP values in the encapsulation area respectively; The value of each pixel represents the local texture mode of the pixel, expressed as an integer between 0 and 255, and the length of the created vector is also 256; The normalized vertical vector is compared with the standard texture sample, and the Euclidean distance D between the normalized vertical vector of the encapsulated area and the standard sample is calculated, which is expressed as: ; Where D represents the Euclidean distance between the package area and the normalized rectangular vector of the standard sample, represents the normalized frequency of the i-th LBP value in the encapsulation area, represents the normalized frequency of the i-th LBP value in the standard sample; The sum of the average value and the standard deviation of the historical Euclidean distance is used as the comparison threshold. If the calculated Euclidean distance is greater than or equal to the comparison threshold, it is judged that the texture feature of the packaging area has a large deviation from the integrity of the standard sample.
[0027] By using the phase correlation method to register the target image and the reference image, the translation amount is quickly calculated and aligned, so that the packaging area maintains a consistent position in different images. The phase correlation method is not affected by brightness changes and local noise during the detection process, ensuring that the contour and texture of the packaging area can be stably identified, greatly improving the accuracy of subsequent detection. By calculating the LBP value of each pixel, a texture feature map of the packaging area is constructed. The LBP value can capture the local texture features of the surface of the packaging area, which is particularly suitable for detecting tiny packaging defects (such as wrinkles, damage, and local unevenness), making it easy to identify tiny changes in the consistency of the packaging surface texture, and improving the ability to identify subtle defects. By counting the LBP value of each pixel in the packaging area, the texture feature map of the packaging area is constructed. The LBP value can capture the local texture features of the surface of the packaging area, which is particularly suitable for detecting tiny packaging defects (such as wrinkles, damage, and local unevenness), and can easily identify tiny changes in the consistency of the packaging surface texture, thereby improving the ability to identify subtle defects. The occurrence frequency of the LBP values is calculated and the vertical vector is generated. The texture information of the package area is quantified into a feature vector, which is convenient for comparison with the standard sample. The normalization of the vertical vector allows the texture features of different images to be compared on the same scale, eliminating the impact of brightness or contrast changes, ensuring the stability and robustness of the comparison. The Euclidean distance of the normalized vertical vector between the target area and the standard sample is calculated to effectively quantify the texture difference between the two. The comparison threshold is set by the average value and standard deviation of the historical data to ensure that there is an objective judgment standard in the package detection. The quantification of the Euclidean distance makes the judgment of the package integrity more scientific and intuitive, which helps to timely identify samples with large deviations in package integrity and improve the reliability of detection. The precise alignment of the phase correlation method, the texture feature analysis of the LBP value and the quantitative comparison of the Euclidean distance are combined to form a multi-dimensional detection method. The detection scheme can not only effectively determine the overall integrity of the package surface, but also accurately detect subtle package defects, providing a comprehensive detection method for package quality control and improving the quality control level of the package line.
[0028] S4, construct CatBoost model to predict completeness probability based on comprehensive feature vector; Preferably, a CatBoost model is constructed to predict the completeness probability based on the comprehensive feature vector, including: The normalized vertical vector is defined as a texture feature vector, and the shape feature vector is formed according to the perimeter, area, and compactness of the standard packaging area of the seasoning package. The texture feature vector and the shape feature vector are combined into a comprehensive feature vector F; Construct a CatBoost model, including an input layer, a decision tree layer, and an output layer. The input layer inputs a comprehensive feature vector F; the decision tree layer is an integrated layer composed of multiple decision trees, each tree learns and adjusts the classification boundary (the gradient boosting algorithm is used to construct the decision tree so that each tree learns the residual of the previous layer), and the output layer outputs the incomplete probability value; Use the training set and validation set to train the model, select Logloss as the loss function, and gradually build decision trees. Each tree learns the residual of the previous tree, and gradually optimizes the model parameters. Enable early stopping on the validation set. When the loss no longer decreases significantly within several rounds, stop training to avoid overfitting. Based on the comprehensive feature vector of the new input, the CatBoost model predicts the completeness probability.
[0029] By using the CatBoost model to build an integrated decision tree using the gradient boosting algorithm, the classification boundary between package completeness and incompleteness can be quickly found. Each decision tree learns the residual of the previous tree, thereby continuously optimizing the classification performance during the detection process and improving the classification accuracy of the model. At the same time, the efficient integrated structure of the CatBoost model shows excellent efficiency when processing large amounts of image data, making the package detection faster. The model's rapid response capability enables the packaging line to immediately identify package defects and promptly eliminate problematic samples, improving the detection efficiency and quality control level of the production line.
[0030] S5, based on the integrity deviation and integrity probability analysis, the incomplete seasoning packages are removed and a data report of the incomplete seasoning packages is generated; Preferably, the comprehensive integrity is analyzed based on integrity deviation and integrity probability, including: Based on the completeness probability and Euclidean distance D predicted by the CatBoost model, comprehensive completeness detection is performed, which is expressed as: ; Where V represents comprehensive completeness, and p represents the completeness probability predicted by the CatBoost model; 1-p represents the probability of complete encapsulation. The closer it is to 1, the more complete the model judgment is. It is an inverse score based on texture deviation, so that the smaller the distance D is, the higher the score is, indicating that the texture is more consistent; An integrity score threshold is set according to the packaging integrity requirements of the seasoning package. If V is greater than or equal to the integrity score threshold, the package is judged to be complete. If V is less than the integrity score threshold, the package is judged to be incomplete and the corresponding seasoning package is marked as incomplete.
[0031] By combining the detection results of the integrity probability p predicted by the CatBoost model and the texture deviation distance D, the detection method can take into account both local texture consistency and overall feature judgment. The 1-p scoring mechanism ensures that when the model determines that the package is complete, even if there is a slight deviation in the local texture, the system can still make an accurate judgment based on the overall evaluation. The package inspection method based on comprehensive scoring can effectively integrate multiple inspection dimensions to avoid the waste of time and resources caused by multiple judgments and repeated inspections. Through a unified scoring standard, the system can quickly and accurately judge the package integrity, improve the inspection efficiency of the production line, and ensure the smoothness of the production process.
[0032] Furthermore, incomplete seasoning packages are removed and a data report of incomplete seasoning packages is generated, including: The rejecting device is driven based on the control signal of the packaging assembly line to reject the seasoning package marked as incomplete from the assembly line; Statistics are collected based on the number of rejected seasoning packets, and the alarm threshold is dynamically set according to the production yield requirements. If the number of rejected seasoning packets is greater than or equal to the alarm threshold, an audible and visual alarm is issued, and the sample ID, detection time, and integrity score data of the rejected seasoning packets are counted, and a report is generated through a chart tool.
[0033] By driving the rejection device with control signals, the seasoning packages marked as incomplete can be removed from the assembly line in real time to ensure that the products entering the market meet the quality standards. Based on the alarm threshold of the production yield rate, the system dynamically adjusts the rejection alarm conditions. When the number of incomplete products rejected exceeds the alarm threshold, the sound and light alarm can promptly remind the operator, help quickly troubleshoot production anomalies, prevent potential packaging problems, and help maintain production stability.
[0034] Example 2, reference Figure 2 , which is the second embodiment of the present invention, is different from the previous embodiment and provides a system for detecting the integrity of a seasoning package based on machine vision, comprising: The data processing module uses a machine vision device to collect the image of the seasoning package and performs filtering on the collected image data; The contour extraction module uses an edge detection algorithm to perform edge detection on the preprocessed image and generate an edge line image of the encapsulation area; Texture feature analysis module uses phase correlation method to align the target image with the reference image, calculates the LBP value of each pixel, and generates a vertical vector for comparison with the standard sample; The integrity detection module uses the trained CatBoost model to perform integrity prediction; The alarm module removes incomplete seasoning packages from the production line and issues an alarm; The data recording module records the relevant data of each incomplete seasoning package, counts and generates corresponding reports.
[0035] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0036] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0037] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0038] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit with a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit with a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0039] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A method for detecting the integrity of a seasoning package based on machine vision, characterized in that: include: Collect machine vision image data and perform filtering processing; Use edge detection algorithm to calculate gradient amplitude and gradient direction, perform double threshold determination, and generate package edge line image; Use phase correlation method to align the target image with the reference image, calculate LBP value to generate vertical vector, and analyze integrity deviation; Construct a CatBoost model to predict the completeness probability based on the comprehensive feature vector; Based on the integrity deviation and integrity probability analysis, the comprehensive integrity is determined, incomplete seasoning packages are eliminated, and data reports on incomplete seasoning packages are generated.
2. The method for detecting the integrity of a seasoning package based on machine vision according to claim 1, characterized in that: The collecting of machine vision image data and filtering processing includes: The packaging line based on seasoning packets uses a multispectral camera to collect image data based on machine vision; The collected image data includes RGB images and IR images, and image data including multiple spectral layers are generated based on the continuously collected image data; The RGB and IR data are fused to generate a multi-dimensional image matrix, and the fusion values between each layer are calculated by weighted average; Convert the multispectral image into a grayscale image, perform histogram equalization, and enhance the local contrast of the image; Perform Gaussian filtering on the image to denoise the image data.
3. The method for detecting the integrity of the seasoning package based on machine vision according to claim 2, characterized in that: The method uses an edge detection algorithm to calculate the gradient amplitude and gradient direction, performs a double threshold determination, and generates a package edge line image, including: Using the Canny edge detection algorithm, the Sobel operator is used to calculate the horizontal and vertical gradients of the image data, expressed as: ; ; in and Represent the gradient of the image in the horizontal and vertical directions respectively, and Respectively represent the convolution kernel of the Sobel operator in the horizontal and vertical directions, Represents the pixel value of the image at coordinate (xi, yj) after Gaussian filtering; Calculate the gradient magnitude G and gradient direction θ, expressed as: ; ; Where G represents the gradient amplitude, θ represents the gradient direction, and arc represents the arctan inverse tangent function; According to each pixel point (x, y), the corresponding gradient magnitude G and gradient direction θ are calculated, and the adjacent pixel points in the gradient direction are calculated using bilinear interpolation; For each pixel point (x, y), if its gradient magnitude G(x, y) is greater than the gradient magnitude G of the adjacent pixel, the pixel value is retained; if its gradient magnitude G(x, y) is less than or equal to the gradient magnitude G of the adjacent pixel, the pixel is set to 0; Based on historical data, double threshold processing is performed on the gradient amplitude. Based on the calculation of the gradient amplitude G, an array of the gradient amplitudes of all pixels is constructed, and the upper percentile value 90 is selected as the high threshold, and the lower percentile value 10 is selected as the low threshold; If the gradient amplitude G is greater than the high threshold, it is marked as a strong edge. If the gradient amplitude is less than or equal to the high threshold and greater than the low threshold, it is marked as a weak edge. If the gradient amplitude G is less than or equal to the low threshold, it is marked as background. Based on the weak edge pixel, check whether the 8 pixels around it contain a strong edge pixel. If any adjacent pixel is a strong edge, retain the weak edge point as the final edge pixel; Based on strong edges and connected weak edges, complete encapsulated edge lines are formed to generate the final generated image.
4. The method for detecting the integrity of the seasoning package based on machine vision according to claim 3, characterized in that: The method of using the phase correlation method to align the target image with the reference image, calculating the LBP value to generate the vertical vector, and analyzing the integrity deviation includes: Select a reference image containing a standard package and perform image registration on the target image based on the package outline detected by edge detection; Using the phase correlation method, the target image and the reference image are fast Fourier transformed to obtain the frequency domain representation of the target image and the reference image. and ; Fourier transform of the target image Multiply it with the conjugate Fourier transform of the reference image and normalize it to calculate the phase correlation result, which is expressed as: ; in and are the Fourier transforms of the target image and the reference image, respectively. for The conjugate of represents the phase correlation result; Phase correlation results Perform inverse Fourier transform to obtain a peak position image, use the position coordinates of the maximum peak as the translation amount of the target image relative to the reference image, and perform translation compensation on the target image to achieve alignment with the reference image; Image cropping is performed based on the package outline width of the seasoning package production standard; Calculate the local binary pattern for each pixel and get the center pixel for the pixel (x, y) Gray value, select a neighborhood with a radius of 1, calculate the gray difference of each adjacent pixel, and convert it into a binary value; Based on the binary bits corresponding to the binarization operation results, the pixel positions are numbered from 0 to 7, and the binary weight is determined according to each position number k: ; Use binary weights to assign position weights to each neighborhood pixel, and combine these binary values into LBP values, expressed as: ; in Represents the LBP value of the pixel (x, y), Represents the binarization result at position number k; Record the LBP value of each pixel to form a texture feature map of the entire packaging area; Traverse each pixel point of the texture feature map, read the LBP value of the point, use the LBP value as the index, add 1 to the frequency of the corresponding position, repeat the above operation until all pixels in the complete encapsulation area are traversed, complete the statistics of the frequency of occurrence of each LBP value, and form the vertical vector H, which is normalized and expressed as: ; in represents the normalized frequency of the i-th LBP value in the encapsulation area, and They represent the frequencies of occurrence of the i-th and j-th LBP values in the encapsulation area respectively; The normalized vertical vector is compared with the standard texture sample, and the Euclidean distance D between the normalized vertical vector of the encapsulated area and the standard sample is calculated, which is expressed as: ; Where D represents the Euclidean distance between the package area and the normalized rectangular vector of the standard sample, represents the normalized frequency of the i-th LBP value in the encapsulation area, represents the normalized frequency of the i-th LBP value in the standard sample; The sum of the average value and the standard deviation of the historical Euclidean distance is used as the comparison threshold. If the calculated Euclidean distance is greater than or equal to the comparison threshold, it is judged that the texture feature of the packaging area has a large deviation from the integrity of the standard sample.
5. The method for detecting the integrity of the seasoning package based on machine vision according to claim 4, characterized in that: The CatBoost model is constructed to predict the completeness probability based on the comprehensive feature vector, including: The normalized vertical vector is defined as a texture feature vector, and the shape feature vector is formed according to the perimeter, area, and compactness of the standard packaging area of the seasoning package. The texture feature vector and the shape feature vector are combined into a comprehensive feature vector F; Construct a CatBoost model, including an input layer, a decision tree layer, and an output layer. The input layer inputs a comprehensive feature vector F; the decision tree layer is an integrated layer composed of multiple decision trees, each tree learns and adjusts the classification boundary, and the output layer outputs an incomplete probability value; Use the training set and validation set to train the model, select Logloss as the loss function, and gradually build decision trees. Each tree learns the residual of the previous tree, and gradually optimizes the model parameters. Enable early stopping on the validation set. When the loss no longer decreases significantly within several rounds, stop training to avoid overfitting. Based on the comprehensive feature vector of the new input, the CatBoost model predicts the completeness probability.
6. The method for detecting the integrity of the seasoning package based on machine vision according to claim 5, characterized in that: The comprehensive integrity based on integrity deviation and integrity probability analysis includes: Based on the completeness probability and Euclidean distance D predicted by the CatBoost model, comprehensive completeness detection is performed, which is expressed as: ; Where V represents comprehensive completeness, and p represents the completeness probability predicted by the CatBoost model; An integrity score threshold is set according to the packaging integrity requirements of the seasoning package. If V is greater than or equal to the integrity score threshold, the package is judged to be complete. If V is less than the integrity score threshold, the package is judged to be incomplete and the corresponding seasoning package is marked as incomplete.
7. The method for detecting the integrity of the seasoning package based on machine vision according to claim 6, characterized in that: The step of removing incomplete seasoning packages and generating a data report of the incomplete seasoning packages includes: The rejecting device is driven based on the control signal of the packaging assembly line to reject the seasoning package marked as incomplete from the assembly line; Statistics are collected based on the number of rejected seasoning packets, and the alarm threshold is dynamically set according to the production yield requirements. If the number of rejected seasoning packets is greater than or equal to the alarm threshold, an audible and visual alarm is issued, and the sample ID, detection time, and integrity score data of the rejected seasoning packets are counted, and a report is generated through a chart tool.
8. A system based on the seasoning packet packaging integrity detection method based on machine vision according to any one of claims 1 to 7, characterized in that: include: The data processing module uses a machine vision device to collect the image of the seasoning package and performs filtering on the collected image data; The contour extraction module uses an edge detection algorithm to perform edge detection on the preprocessed image and generate an edge line image of the encapsulation area; Texture feature analysis module uses phase correlation method to align the target image with the reference image, calculates the LBP value of each pixel, and generates a vertical vector for comparison with the standard sample; The integrity detection module uses the trained CatBoost model to perform integrity prediction; The alarm module removes incomplete seasoning packages from the production line and issues an alarm; The data recording module records the relevant data of each incomplete seasoning package, counts and generates corresponding reports.
9. A computer device comprising: Memory and processor; The memory stores a computer program, characterized in that: when the processor executes the computer program, the steps of the seasoning packet packaging integrity detection method based on machine vision described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the seasoning packet packaging integrity detection method based on machine vision described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Composite second-order fractional order signal processing-based edge detection method
CN101930600A
Allogenetic image thick edge detection method based on force field transformation
CN102117410A
Image multi-scale segmentation method integrated with edge information
CN102368331A
High-speed dynamic QR code identification method based on improved SURF composite algorithm
CN110210584A
Model fusion method based on CSI fingerprint positioning
CN116437290A
Cited By
Tablet drop guiding system based on three-dimensional visual feedback
CN119251774A
Digital identification method suitable for colloidal gold detection card detection
CN119295440A
Low-grade highway construction quality intelligent detection method and system
CN119648696A
Oil-immersed transformer equipment oil leakage monitoring method and system based on image recognition
CN119810092A
Oil leakage monitoring method and system for oil-immersed transformer equipment based on image recognition
CN119810092B
