Research on Key Technologies for Machine Vision Inspection of Small Cigarette Packaging Quality
2026-04-06 05:30:33··#1
Abstract: To address the need for precise quality inspection of cigarette packs in tobacco enterprises, this paper proposes a series of key inspection technologies based on machine vision. These technologies include a cigarette pack image acquisition device, a fast edge extraction algorithm based on Hough algorithm, a fast online discrimination algorithm based on Gray-Level Co-occurrence Moments (GLGM) parameters, and packaging defect identification based on Support Vector Machines (SVMs). These key technologies are not only suitable for rapid online packaging quality inspection but also accurately identify defect types. Experiments demonstrate that these technologies are practical and reliable, and can be applied to cigarette pack production sites. The quality of finished cigarette packaging is a crucial factor affecting cigarette quality in tobacco enterprises, and packaging quality inspection is a key link in controlling cigarette quality. Cigarette outer packaging quality inspection is divided into pack inspection and carton inspection. Pack inspection refers to the inspection conducted on the cigarette production line after the finished cigarettes are produced, mainly targeting defects such as edge lifting, packaging damage, spots, and unsealing that occur during the production process. Carton inspection refers to the inspection of small packs after they are packaged into cartons, which may result in misaligned teeth, exposed inner packaging, and packaging damage. After small packs of cigarettes are packaged into cartons, they can no longer be inspected. Therefore, precise inspection of small packs is a prerequisite and key to controlling cigarette quality. The characteristics and general requirements of small pack inspection are: (1) Small packs are on the rolling line and run at a relatively high speed; (2) High real-time requirements for inspection; (3) Inspection of five sides of small packs of cigarettes is required; (4) Analysis of small packs of cigarettes with packaging quality problems is required to determine the type of defect and identify the link where the defect occurred. Domestic and foreign scholars have conducted relevant research on small pack inspection and achieved some results. However, these technologies have not yet involved precision inspection and cannot provide the types of packaging defects. With the increasingly fierce competition among tobacco companies, precision small pack inspection has important engineering application value. This paper studies the precision inspection of small packs using machine vision and proposes a series of key technologies. 1 Inspection System Construction The machine vision-based inspection system needs to acquire and process images of five sides of the small packs on the conveyor belt, excluding the bottom, and remove small packs with detected packaging defects. The system construction is shown in Figure 1. [align=center]Figure 1 Simplified diagram of the small package detection system[/align] The system consists of an acquisition unit, a rejection unit, a D/A converter, and a central computer. Small packages of cigarettes pass through the acquisition unit on a conveyor belt. The acquisition unit acquires an image of one small package at a time. The acquired signal is processed by the central computer. When a package with a packaging defect is detected, the computer sends a signal, which, through D/A conversion, triggers an actuator in the rejection unit to reject the package. The image acquisition unit is an important part of the system. Its internal structure is shown in Figure 2. [align=center]Figure 2 Image acquisition unit of the small package detection system[/align] The image acquisition unit consists of an acquisition box, a CCD array, and a light source. The CCD array consists of CCDs 1 to 5, which acquire images from different sides of the small package. CCDs 1 and 2 are area array CCDs, which detect the left and right upright sides of the small package; CCD 3 is a linear array CCD, which detects the top surface; and CCDs 4 and 5 are linear array CCDs, which detect the front and back surfaces. Linear array CCDs perform better when acquiring images during movement. CCDs #3-#5 are linear CCDs, with the start and end times of acquisition controlled by an encoder, enabling the acquisition of images of the front, back, and top of the small package. Because the acquisition box requires an inlet and outlet to accommodate the conveyor belt carrying the small package, CCD #1/3 cannot be installed directly on the side; it needs to be at an angle to the centerline of the small package. This installation method requires area CCD imaging. When the small package reaches a certain position, the depth of field of CCD #1 is sufficient to completely image the left side of the package. Based on theoretical and experimental analysis, when the small package is at 1/4 and 3/4 of its total length from the inlet, both CCDs #3 and #1 can produce clear images. Although the motion imaging effect of area CCDs is inferior to that of linear CCDs, the angle between the central axis of the small package and the centerline of CCD #1/3 results in the speed at which the small package moves away from the conjugate surface of the CCD being a component of its running speed. Therefore, by selecting a lens with an appropriate depth of field and controlling the exposure time, a clear image can be obtained. As can be seen from the acquisition process of the acquisition device, the shooting method and imaging time of each CCD are different to complete the acquisition process of the entire small package. For different types of small packages, the parameters required to complete the acquisition process are the running speed of the small package and various geometric dimensions of the small package. 2 Key technologies of image processing in the detection process 2.1 Detection process The precision detection of small packages requires high real-time performance and accuracy. After packaging, the packaging quality of the small packages is good and the probability of defects is low. Since the imaging characteristics of each small package are relatively stable after the acquisition parameters are determined, the small package detection process can be divided into two processes: real-time detection and precision detection. Real-time detection uses a fast algorithm for verification, and precision detection is performed when packaging defects are found. After acquiring the image, it is necessary to determine the edge of the small package in the image. The image of the small package is determined by the edge, and each region of interest (ROI) in the image is judged. If a suspicious area is found, it enters the precision detection stage for verification, the defect is determined, and the defect is removed by the rejection mechanism. The whole process is shown in Figure 3. [align=center]Figure 3 Flowchart of Small Package Detection Process[/align] The key image processing techniques in small package detection are: edge detection, small package ROI region determination, threshold judgment, and defect pattern recognition. 2.2 Small Package Edge Detection To determine whether there are defects in the small package, the position of the entire small package image must be determined in advance. Since the acquisition parameters are determined, the imaging of a certain small package remains basically unchanged. However, due to factors such as pixel jitter during acquisition and slight differences in acquisition time, each CCD imaging cannot be completely consistent. Therefore, an edge search algorithm must be used to determine the edge of the small package each time. Since possible edges always appear within a certain known rectangle, the fast Hough transform can be used to search for the edge of the small package within this rectangle. The principle of the fast Hough transform is: the pixel coordinates in the rectangular region are (x[sub]i[/sub], y[sub]i[/sub]), and a known point p0 is determined as the edge line, with coordinates (x[sub]0[/sub], y[sub]0[/sub]). If the slope of the line through p0 is k, then the slope ki of the line connecting any point in the rectangle to the known point p0 is: ki = (yi0) / (xi - x0) (1) Map the slope value ki to a set of accumulators B (mi). Since ki is the same and the maximum value on the same line, the accumulator will have a local or global maximum value if there is a line in the candidate rectangle. Selecting the global maximum value can determine the edge line in the rectangle, while the local maximum value may be a defect or other interference line segment. 2.3 Determination of ROI region and threshold of small package The image acquired by each CCD is a 24-bit grayscale image, which is each side of the small package of cigarettes. If there is a defect in the packaging quality of the small package, it will inevitably lead to anomalies in the features of the image. The commonly used defect judgment algorithm is to subtract the image twice and judge by comparing it with the standard template. Because the film markings on cigarette packs vary each time, and due to differences in lighting conditions during image acquisition, image subtraction may lead to misjudgments. Considering the flexibility and accuracy of the detection, the Gray-Level Co-occurrence Moment (GLCM) parameter within the Region of Interest (ROI) is used to determine the presence of defects. The energy parameter E, entropy parameter S, contrast parameter C, and inverse difference parameter I from the GLCM parameters are selected as comparison parameters. The principle for determining the ROI region for each surface is: based on the characteristics of the surface being inspected, select the entire surface, or one or several specific rectangular areas within the surface as the ROI region. For example, if the top surface of the pack is small, the entire surface can be selected; for the front surface, the seal and areas with Chinese characters can be selected. Figures 4 and 5 show the measured ROIs of the front and top surfaces of the pack. [align=center] Figure 4: Front ROI of a cigarette pack Figure 5: Top ROI of a cigarette pack[/align] The selection of ROI is to reduce computational complexity and improve real-time performance. In actual inspection, the selection of ROI can be based on the company's specific standards for pack inspection and the probability of defects occurring in certain areas. After determining the ROI, the average levels of the four parameters in the ROI need to be calculated to determine the thresholds. The final determined thresholds are E<sub>m</sub>, S<sub>m</sub>, C<sub>m</sub>, and Im. After obtaining the thresholds, the four parameters of the five detected surfaces are quickly judged using Euclidean distance. In fact, when a defect occurs, a change in one GLCM parameter will inevitably lead to changes in other parameters due to the correlation between parameters. Using 4D Euclidean distance can amplify defect information and make rapid judgments. Let E, S, C, and I be the measured values, then the judgment formula is: In the above formula, F is the discrimination value, and E, S, C, and I are the calculated GLCM parameters. When F exceeds a certain value, the small package is considered to have a defect, and defect pattern recognition is performed and it is removed. Using the GLCM parameter method can reduce misjudgments caused by factors such as lighting, and has low computational complexity, high accuracy, and fast judgment. 3. Defect Pattern Recognition Based on SVMs SVMs, proposed by Vapnik et al. in 1995, is a machine learning algorithm based on Statistical Learning Theory (SLT). SLT is a machine learning method with a solid foundation developed from traditional statistics. It is currently the best theory for statistical estimation and prediction learning with small samples. It systematically studies the conditions under which the empirical minimization principle holds, the relationship between empirical risk and expected risk under finite samples, and how to use these theories to find new learning principles and methods. Due to the complex relationship between defects and GLCM parameters, it is impossible to obtain the defect type by changing one or a few parameters. This paper uses an SVM-based method for defect pattern recognition. High-order features of image grayscale reflect the minute details of defects, the exposure characteristics of image imaging, and noise interference. In addition to the four grayscale co-occurrence moment parameters mentioned earlier, the feature vector also selects high-order local feature parameters based on the transform domain. This paper selects DCT filter feature parameters. DCT originates from Chebyshev polynomials, thus it is an orthogonal transformation that overcomes the drawbacks of the Discrete Fourier Transform (DFT) such as high computational cost and complex terms. The coefficient matrix f(m, n) of the DCT transform is: where W is the pixel value of the ROI, taken as the width of the rectangle. I[sub]w[/sub](x, y) are the grayscale values of the pixels within the ROI. The first three terms of the coefficient matrix are used to form a 3×3 template, which is then processed as the feature vector. Adding four GLCM parameters, a total of seven-dimensional feature vectors are constructed for defect identification. Since the real-time requirements for defect detection are not high, and processing occurs during system idle time, it does not affect the overall system real-time performance. Because SVMs can only handle two-class binary problems, existing methods for multi-class pattern recognition can be divided into three types: modifying the discrimination method, modifying the decision function, and combining SVMs. The first two methods are relatively complex and unsuitable for engineering detection; therefore, this paper adopts a hierarchical SVM method for pattern recognition. Hierarchical SVMs identify only two classes at a time, and then further classify the subclasses using SVMs. Therefore, for n defects, n-1 SVM classifiers are needed. This paper identifies six types of small package defects: damaged packaging, missing cap, detached seal, exposed packaging, reversed packaging, and misaligned packaging. Thus, a total of five SVM classifiers are required. Current methods for classifier construction include one-to-one, one-to-remainder, and directed acyclic graphs (DAGs). This paper employs a classification binary tree approach for multi-class SVM identification of defects. Clustering is used to determine the binary tree structure of the SVMs. The specific construction process is as follows: (1) For the known 6 classes of training samples, these samples are in the same feature space. Calculate the class center point of each class sample. The calculation method can adopt the intra-class average connectivity rule; (2) For the distance of each class center point, use Euclidean distance to determine the class sequence T[sub]i[/sub] = (T[sub]1[/sub], T[sub]2[/sub], ..., T[sub]6[/sub]); (3) Construct the SVMs classification binary tree structure according to Ti. Take the negative samples of each training as the positive samples of the next level SVMs. In this way, the number of training samples decreases in turn until SVM[sub]5[/sub] is obtained. (4) According to SVM[sub]1[/sub] to SVM[sub]5[/sub], the multi-classifier of the SVMs binary tree is formed. According to this classification method, the classification order is: seal peeling off, missing cap, exposed white, reversed packaging, misaligned packaging, and damaged packaging. The classification flowchart is shown in Figure 6. [align=center]Figure 6 Multi-classification Defect SVM[sub]5[/sub] Binary Tree Diagram[/align] For each suspected ROI region, discrimination can be performed using the binary tree constructed in Figure 6. Discrimination always starts from the first defect until the defect type is determined. Since SVMs do not reject classes, classification results can always be obtained using SVMs. 4 Experimental Analysis Based on the above analysis, an experimental system for precise detection of small cigarette packaging quality was built. The experimental conditions were completely consistent with the allowable parameters of a tobacco company's packaging line. The experiment simulated training with 30 samples of each type of defect. Small cigarette packs with actual packaging defects were obtained from the production site for testing. The test showed that 100% of defective small packs could be detected; for small packs without defects, there was a 1% false positive. By adjusting the F-value, this false positive rate can be reduced to what the company considers a reasonable requirement, ensuring no missed detections. In terms of packaging defect pattern recognition, the accuracy rates were as follows: 95% for detached seals, 100% for missing caps, 93% for exposed packaging, 90% for reversed packaging, 87% for misaligned packaging, and 70% for damaged packaging. Due to the large scope and small intension of packaging damage defects, their feature vectors are difficult to describe accurately, resulting in a low accuracy rate. 5. Conclusion This study investigated key technologies for precise inspection of small-pack cigarette packaging quality, designed an image acquisition device, proposed a rapid online inspection scheme based on GLCM, and utilized SVMs for pattern recognition of packaging defects. Experimental results show that this key technology has advantages such as good adaptability and ideal classification effect, and can be applied to the precise inspection of small-pack cigarette packaging quality at the cigarette packaging site.