Design of a Machine Vision-Based Quality Inspection System for Cigarette Carton Packaging
2026-04-06 05:11:50··#1
1. Introduction Machine vision systems refer to systems that use machine vision products, such as CCD, CMOS, and phototubes, to convert captured targets into image signals, which are then transmitted to a dedicated image processing system. Based on pixel distribution and information such as brightness and color, these signals are converted into digital signals. The image system performs various calculations on these signals to extract the target's features and then controls the equipment on-site based on the judgment results. A typical industrial machine vision application system includes the following components: light source, lens, CCD camera, image processing unit (or image acquisition card), image processing software, monitor, communication/input/output unit, etc. With China's accession to the WTO, market competition has become increasingly fierce. To improve product competitiveness and better expand the market, cigarette companies have not only increased their efforts in technological upgrades to improve cigarette quality but also intensified their efforts in transforming the packaging form and quality of cigarette products to better consolidate and expand their market share in the fierce market competition. The inspection of cigarette product packaging quality is an important means of ensuring quality in the marketing process. Traditionally, the quality of cigarette carton packaging is entirely inspected by the human eye. However, prolonged work can cause visual fatigue, making it difficult to avoid product mis-inspection and omissions. The machine vision-based inspection system replaces human eyes in product quality inspection, reducing the impact of human factors on product quality and meeting the needs of enterprises in improving cigarette packaging quality through technological upgrades. 2. System Design Scheme The system uses a linear light source to generate a concentrated, uniformly distributed light band. Multiple cameras photograph each surface of the carton to ensure comprehensive inspection. An external trigger mode allows images from each surface to enter the image acquisition unit via separate channels. The processing unit performs complex surface inspection calculations on the images from each channel. If a surface quality defect is found in any channel, a control signal is sent to the lower-level machine, causing the execution unit to reject the defective carton when it passes through. The system display shows the images from each channel and their inspection results in real time, along with defect analysis results. The system's image acquisition unit includes an image acquisition card, a D/A converter card, a light source, and a CCD camera. An industrial control computer serves as the image processing unit, and a PLC control system controls the execution unit. 3. Image Acquisition Image acquisition is essentially the conversion of the visualized image and intrinsic features of the object under test into data that can be processed by a computer. It directly affects the stability and reliability of the system. Generally, images of the object under test are acquired using a light source, optical system, camera, image acquisition card, and image processing unit. The light source is a crucial factor affecting the input of a machine vision system, as it directly influences the quality of the input data and at least 30% of the application effect. The transparent paper of the outer packaging of the box has a strong reflective and refractive effect on light; therefore, the system's lighting system uses a combination of various types of LED strip light sources, employing reflective illumination. To extend the lifespan of the light source and maintain its high brightness and stability, the camera uses a strobe light, with the strobe speed synchronized with the camera's scanning speed. In machine vision, CCD cameras are widely used due to their small size, reliable performance, and high resolution. Based on the CCD device used, they can be divided into two main categories: linear array and area array. Linear array cameras can only acquire one line of image information at a time; the object being photographed must move in a straight line in front of the camera to obtain a complete image. Area array cameras, on the other hand, can acquire the entire image information at once. In a carton packaging quality inspection system, images of five sides of the carton packaging need to be acquired simultaneously. The design employs four area-array CCD cameras for simultaneous image capture. The image acquisition card is a crucial device controlling the cameras, completing image acquisition and digitization, and coordinating the entire system. It typically includes the following modules: 1. A/D conversion module; 2. Timing and acquisition control module; 3. Image processing module; 4. PCI bus interface and control module; 5. Camera control module; 6. Digital input/output module. The system design uses an external trigger mode to photograph the carton. The image acquisition card communicates with external devices (sensors, light source strobe controllers, PLCs, etc.) via TTL signals to respond to strobe signals, capture images, and provide rejection signals. 4. Image Analysis and Processing Currently, cigarette carton packaging mainly suffers from defects such as damage, warped edges, reverse packaging, misaligned packaging, and seals (offset, overlapping corners, missing seals). The image processing unit utilizes algorithms such as image positioning, edge detection, and speckle analysis to analyze images from each channel to determine if quality defects exist in the product packaging. 4.1 Locator Locator registration is essential for defect detection between an image and a standard template. The accuracy of the locator directly impacts the success of the entire vision system. Traditional object localization techniques determine the X and Y coordinates of an object by finding the gray-level correlation between a statistical template (reference image) and the object (product image). This system uses geometric feature matching. By setting a region of interest and learning the geometric features of objects within that region, it searches for similar-shaped objects within the image. This improves the ability to locate objects without relying on specific pixel gray levels, and it can still accurately locate objects even when conditions such as changes in object angle, size, and brightness are altered. Features in application: • Locates and locates crates based on their outlines or edges in the image; • All searches are template-based after template settings are established; • Weighted processing is applied to similar templates, automatically deblurring (ambiguity); • Tolerates shadows, low contrast, unclear edges, or background noise; • The locator returns the X and Y coordinates of the found crate features. 4.2 Edge Detection An edge is the part of an image where the local brightness change is most significant, mainly existing between objects, between objects and background, and between regions (including different colors). Edges to be found in an image are marked as grayscale value changes within the range of total darkness to total brightness or from total brightness to total darkness. The edge tool removes constant or slowly changing background from the image, retaining the edges as image features, and calculates the amplitude and angle of the edges. The amplitude of an edge refers to the amount of grayscale value change when crossing the edge; the angle of an edge refers to the angle between the edge and the vertical direction. The image below shows two triangles. The direction of the arrow indicates the edge angle, and the size of the arrow indicates the edge amplitude. Each triangle has the same edge angle, but due to the different grayscale values of the background, the amplitude of the left triangle is greater than that of the right triangle. Most edge amplitude images generated from real images contain false or noisy edge pixels, caused by video noise, reflections, or other image defects. These false pixels can be eliminated by setting a threshold in the edge amplitude image. Setting a threshold often eliminates true edges along with false edges, because true edges are often composed of sets of neighboring pixels. By setting an edge hysteresis threshold in the edge image, false edges can be eliminated while true edges are preserved. The edge hysteresis threshold eliminates some pixels whose grayscale is a certain amplitude lower than those pixels that are not adjacent to other edge pixels, and a certain amplitude higher than the edge amplitude image. This method preserves continuous edge pixels that form true edges, while eliminating edge pixels formed by noise or other image defects. In the system design, defects such as carton edges and transparent paper wrinkles are detected by setting the edge hysteresis threshold and amplitude range in the edge tool. 4.3 Blob Analysis Blob analysis can provide the vision system with the number, location, shape, and orientation of blobs in an image, as well as the topological structure between related blobs. It is a basic method for analyzing closed target shapes. Blob analysis starts with the grayscale image of the scene. Before analysis, the image is segmented into a set of pixels that constitute blobs and local background using bilinear interpolation. Typically, target pixels are assigned a value of 1, and background pixels are assigned a value of 0. Two methods were set for segmentation: fixed threshold segmentation (Hard Threshold) and dynamic threshold segmentation (Soft Threshold). After the image was segmented into target pixels and background pixels, connectivity analysis was performed to find one or more "blobs" with similar gray levels in the image. These "blobs" were then analyzed for connectivity using a four-neighbor or eight-neighbor approach, aggregating target pixels into a connection body of target pixels or blobs, thus forming a Blob unit. By performing graphic feature analysis on Blob units, the simple gray-level information of the pattern can be quickly converted into the shape information of the pattern, including the centroid, area, and perimeter of the shape. Using Blob analysis and filtering through a multi-level classifier, the detection requirements for defects such as damaged transparent paper, reverse wrapping, and printing defects on the box skin of carton can be met to a certain extent. 5. Overall System Development The processing method used in the carton outer packaging quality inspection system is a PC-based inspection and processing system. The development process comprehensively considered the connection and communication control between the system and the camera, acquisition card, external PLC, and PC peripherals, providing a user-friendly human-machine interface and a reliable historical data storage database. When a quality defect is detected, the system indicates the defect category and provides a rejection signal to the execution unit. The execution unit is a key component of the system; its function is to respond to rejection commands from the host computer and accurately reject unqualified cartons. During peak production line operation, the speed can reach 8 cartons/second. To ensure system stability and speed, the electrical control system uses a Siemens S7-200 PLC, and the execution mechanism employs high-speed solenoid valve groups and a jetting chamber to enable rapid response to rejection signals. 6. Conclusion This paper discusses various related technologies in the design of a carton packaging quality inspection system based on machine vision. It introduces the basic concepts of machine vision and machine vision systems. Through the introduction of system development, it lists and elaborates on algorithms commonly used in surface defect detection, such as localization, edge detection, and blob analysis. The emergence and application of machine vision has greatly liberated human productivity and improved the level of production automation, with extremely broad application prospects. With the comprehensive implementation of the tobacco industry's quality improvement and cost reduction project, it will be increasingly applied to the detection and monitoring of tobacco production quality, making a greater contribution to enhancing the market competitiveness of tobacco enterprises.