A cigarette visual inspection method and system
Patent Information
- Application Number
- CN202610860418.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-15
- Publication Date
- 2026-10-27
AI Technical Summary
其一,在轮廓提取上,多依赖单一灰度阈值分割,难以有效处理烟纸与深色烟丝在灰度上的交叠问题,常导致轮廓断裂或误判,且形态学处理参数固定,无法自适应不同批次产品的灰度差异
[0011]本发明的有益效果:本专利通过多项技术创新,取得了显著的有益效果。首先,采用双阈值分割与形态学处理相结合的轮廓提取方法,能精准锚定烟纸与烟丝的边界,有效克服灰度交叠干扰,生成高保真、完整的截面轮廓,为后续分析奠定坚实基础。其次,构建“语义分割+密度量化+异常检测”三阶分析体系,利用深度学习模型精确理解烟丝、烟纸、空白及破损区域的语义,不仅能从宏观上量化填充度与均匀性,更能将外部破损与内部烟丝缺失进行逻辑关联,实现对复合型缺陷的精准识别。再次,开创“横向-纵向-标准”三维对比判定模式,通过多通道数据互验、历史数据追溯与动态标准校准,构建起具有自我纠错能力的智能决策大脑,大幅降低了误判与漏判。此外,引入时空连续性校验的细微缺陷检测机制,有效捕捉微小针孔等“隐形”问题,将质量管控延伸至微观层面。最后,建立动态自学习的闭环标准迭代体系,使系统能根据新数据、新规格自动调整参数,实现跨品牌柔性化生产,并持续保持高性能,有效降低了企业的长期运维成本,为烟草行业智能制造提供了有力支撑。
Smart Images

Figure CN122989529A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to visual inspection systems, and more particularly to a method and system for visual inspection of cigarettes. Background Technology
[0002] On cigarette production lines, the detection of tobacco filling degree and cigarette paper integrity is crucial for ensuring quality. Currently, the industry widely adopts automated inspection technology based on traditional machine vision, but this has significant limitations. First, in contour extraction, it relies heavily on single grayscale threshold segmentation, which struggles to effectively handle the overlap between cigarette paper and dark tobacco in grayscale, often leading to contour breaks or misjudgments. Furthermore, the fixed morphological processing parameters cannot adapt to the grayscale differences between different batches of products. Second, in tobacco analysis, filling degree is often judged by simply calculating the percentage of tobacco pixels, completely ignoring the uniformity of tobacco spatial distribution and failing to correlate damage to the outer packaging with missing tobacco inside, resulting in a single evaluation dimension. Third, in terms of judgment logic, existing technologies are mostly isolated static analyses, lacking horizontal comparison of multi-channel data and vertical correlation of historical data. This makes it difficult to distinguish between genuine product defects and equipment interference, and the detection standards are mostly fixed parameters, unable to adapt to normal fluctuations in the production process, leading to poor system adaptability and both false positives and false negatives. Fourth, existing methods are almost powerless against minute defects such as tiny pinholes or localized sparseness, leaving blind spots in quality control. Therefore, the market urgently needs a detection solution that can achieve accuracy, comprehensiveness, intelligence, and adaptability. Summary of the Invention
[0003] In view of the shortcomings of the existing technology, the purpose of this invention is to provide a visual detection method and system for cigarettes, so as to overcome the above-mentioned defects in the existing technology.
[0004] To achieve the above objectives, the present invention provides the following technical solution: A method for visually detecting cigarettes, the method comprising the following steps: The data acquisition and preprocessing steps involve the cigarette falling synchronously in multiple channels. The high-speed cameras in each channel are activated by an infrared triggering device to capture high-definition image sequences of the cigarette cross-section. The images are then preprocessed by grayscale conversion and Gaussian filtering. The contour extraction and preliminary judgment steps involve applying a dual grayscale threshold segmentation algorithm to the grayscale image to extract the edges of the cigarette paper and the boundaries of the tobacco shreds, and merging them to generate a preliminary contour mask; eliminating edge burrs and filling gaps through morphological dilation and erosion operations to generate a complete closed cross-sectional contour curve; calculating the perimeter, area, and roundness features of the contour; if the perimeter deviation exceeds the limit, the roundness is lower than the threshold, or there is an obvious gap, it is marked as a contour anomaly. The semantic segmentation and tobacco analysis steps involve inputting the pre-processed image into a pre-trained semantic segmentation model to obtain pixel-level masks for tobacco paper, tobacco shreds, blank areas, and damaged areas. Based on the tobacco shred mask, the percentage and distribution uniformity of tobacco shred pixels are calculated. If the percentage is too low, the uniformity is too high, or there are large continuous blank areas, it is determined that the tobacco shreds are not full. If the damaged part of the contour abnormal area overlaps with the blank area and the area increases significantly, it is determined to be a combination of damaged and incomplete tobacco shreds. The minor defect detection steps involve constructing a standard cigarette cross-section pixel grayscale distribution template, comparing the current image pixels with the template, and filtering out abnormal pixels with significant grayscale deviations. The spatial continuity of the abnormal points is analyzed. If they form an effective area within the cigarette paper outline, they are judged as minor damage. If they are blank pixels and clustered at the center of the cross-section, they are judged as slight tobacco incompleteness. The multi-dimensional judgment process involves: horizontal comparison, calculating the average value of parameters for each channel at the same time point to determine isolated anomalies; vertical comparison, comparing historical batch data to identify suspicious samples and equipment failures; and standard comparison, combining initial and dynamic standards for dual verification to comprehensively determine product qualification.
[0005] Preferably, grayscale histogram analysis is performed on the grayscale image to identify the grayscale peaks corresponding to the dark cigarette paper region and the light-colored tobacco shred region. The high threshold is set to a preset multiple of the grayscale value corresponding to the right inflection point of the grayscale peak in the cigarette paper region, so as to effectively capture the clearest edge of the cigarette paper outline. The low threshold is set to a preset multiple of the grayscale value corresponding to the left inflection point of the grayscale peak in the tobacco shred region, so as to completely cover the transition boundary area between the tobacco shred and the cigarette paper. The grayscale image is segmented using the adaptively determined high and low thresholds, and combined with subsequent morphological processing, a complete cigarette cross-sectional contour mask is generated.
[0006] Preferably, a spatiotemporal continuity verification mechanism is introduced in the minor defect detection step: After identifying the set of abnormal pixels, not only is its spatial continuity analyzed, but it is also compared with the state of the pixel in the preceding and following frames in the time series. Only when an abnormal pixel exhibits the same or similar abnormal features in multiple consecutive frames of images, and it forms a connected region with neighboring abnormal pixels in space, is it finally confirmed as a valid defect signal.
[0007] Preferably, in the horizontal comparison of the multi-dimensional determination step, a channel correlation confidence algorithm is introduced to quantify the reliability of the anomaly determination: The confidence level of the correlation between channels is defined as a composite function, whose independent variables include the physical distance between the two channels, the current environmental sensor reading, and the similarity of specific feature parameters in the detection results of the two channels. When a channel is determined to be unqualified, the system calculates its confidence level with all other channels. If the average confidence level is lower than a preset threshold, it is determined to be an isolated anomaly and confirmed as a product defect. If the average confidence level is high, it is determined to be regional interference, triggering an equipment maintenance alarm instead of rejecting the product.
[0008] Preferably, the longitudinal comparison in the multi-dimensional determination step includes continuous monitoring logic for the performance of a single channel: The system continuously tracks and records the defect rate of each channel. When the defect rate of a certain channel is significantly higher than the average level of other channels, the system determines that the acquisition equipment of that channel may be faulty, and then triggers the equipment self-test program and suspends the automatic rejection function of that channel, while issuing an alarm to the maintenance personnel.
[0009] Preferably, the standard iteration steps include an anomaly pattern tracing and feedback submodule: When the system discovers through longitudinal comparison that the incidence of a certain type of non-conforming product has risen sharply in a short period of time, the module will automatically initiate source tracing analysis, retrieve the production process parameters for the relevant time period and perform correlation analysis with the incidence of the defect; once it is confirmed that the defect is strongly correlated with the deviation of a specific process parameter, the system will automatically generate an analysis report containing a problem description, related parameters, and suggested adjustment range, and push it to the central control system of the production line.
[0010] The cigarette visual inspection system, the hardware architecture of which includes: Multi-channel synchronous imaging array: It consists of multiple independent detection stations arranged linearly. Each station is equipped with a high-speed industrial camera and a coaxial light source module of a specific wavelength. Precision optical lens group ensures that the depth of field and field of view of all channels are consistent. High-precision triggering and conveying module: It adopts a vibrating conveyor belt driven by a servo motor, in conjunction with photoelectric sensors, to ensure that the cigarettes fall into the detection area at a constant speed and posture, and the programmable logic controller sends precise synchronous trigger pulses; Edge intelligent computing unit: Deploy embedded AI computing devices near each inspection station, equipped with deeply optimized semantic segmentation and contour analysis algorithms to achieve millisecond-level local reasoning and preliminary judgment; Central Data Management and Analysis Server: This server runs a database to store all historical data and deploys a federated learning framework to coordinate model updates across edge nodes. It also provides a visual web interface for operators to monitor, review, and manage standard iterations.
[0011] The beneficial effects of this invention: This patent achieves significant beneficial effects through multiple technological innovations. First, the contour extraction method combining dual-threshold segmentation and morphological processing can accurately anchor the boundary between the tobacco paper and the tobacco shreds, effectively overcoming grayscale overlap interference and generating a high-fidelity, complete cross-sectional contour, laying a solid foundation for subsequent analysis. Second, a three-tiered analysis system of "semantic segmentation + density quantification + anomaly detection" is constructed. A deep learning model is used to accurately understand the semantics of the tobacco shreds, tobacco paper, blank areas, and damaged areas. This not only quantifies the filling degree and uniformity macroscopically but also logically correlates external damage with internal tobacco shred loss, achieving accurate identification of complex defects. Third, a three-dimensional comparison and judgment mode of "horizontal-vertical-standard" is pioneered. Through multi-channel data mutual verification, historical data tracing, and dynamic standard calibration, an intelligent decision-making brain with self-correcting capabilities is constructed, significantly reducing misjudgments and omissions. Furthermore, a subtle defect detection mechanism with spatiotemporal continuity verification is introduced, effectively capturing "invisible" problems such as tiny pinholes, extending quality control to the microscopic level. Finally, a dynamic self-learning closed-loop standard iteration system was established, enabling the system to automatically adjust parameters based on new data and specifications, achieve flexible cross-brand production, and maintain high performance. This effectively reduces the long-term operation and maintenance costs for enterprises and provides strong support for intelligent manufacturing in the tobacco industry. Attached Figure Description
[0012] Figure 1 This is an overall flowchart of the present invention; Figure 2 This is a flowchart of the contour extraction and preliminary judgment process of the present invention. Detailed Implementation
[0013] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] It should be noted that when a component is described as "fixed to" another component, it can be directly on the other component or may have a component in between. When a component is considered "connected to" another component, it can be directly connected to the other component or may have a component in between. When a component is considered "set on" another component, it can be directly set on the other component or may have a component in between. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.
[0015] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0016] The embodiments of the present invention will be further described in detail below with reference to the accompanying drawings: The cigarette visual inspection system proposed in this patent is a complex mechatronics system integrating optical imaging, mechanical control, artificial intelligence algorithms, and data management. Its core design concept lies in converting the instantaneous cross-section of a cigarette during free fall on the production line into a high-quality digital image using multi-channel synchronous imaging technology. Then, a series of hierarchical and logically rigorous algorithm models are used to conduct a comprehensive quality inspection from multiple dimensions, including geometric shape, material composition, and spatiotemporal correlation. Finally, an accurate pass / fail determination is made through adaptive dynamic standards.
[0017] The system's workflow begins with the conveying and triggering of cigarettes. Driven by a vibrating conveyor belt, cigarettes enter the detection area in an orderly queue at a constant speed. When a cigarette detaches from the conveyor belt and falls freely under gravity, passing through a detection light curtain composed of infrared beams, the infrared sensor instantly detects its passage and emits an extremely short electrical pulse signal. This signal serves as the synchronization reference for the entire system and is simultaneously sent to the industrial cameras in all parallel detection channels, ensuring that each camera exposes at the same millisecond-level time point, thereby capturing the most stable cross-sectional image of the cigarette during its descent. This synchronization mechanism is a prerequisite for subsequent multi-channel lateral comparisons, guaranteeing absolute consistency of all comparison data in the temporal dimension.
[0018] Data acquisition and preprocessing are fundamental to the entire detection process, and their quality directly determines the success or failure of all subsequent advanced analyses. In this stage, the simultaneous multi-channel dropping of cigarettes and high-speed imaging are the primary challenges. To achieve this, the system employs a specially designed vibration feeding mechanism. This mechanism is not a simple conveyor belt, but a system combining an electromagnetic vibratory feeder precisely controlled by a servo motor with an inclined chute. The servo motor can perform micron-level reciprocating motion at extremely high frequencies. This high-frequency micro-vibration effectively organizes the randomly piled cigarettes into a single, uniformly spaced column, giving them an initial velocity downwards along the chute. The chute's tilt angle and vibration frequency are precisely coupled and calculated to ensure that the cigarettes enter the detection area vertically and without rotation when leaving the end of the chute. This attitude control is crucial because any tilt will cause elliptical distortion in the cross-sectional image captured by the camera, posing significant difficulties for subsequent contour extraction.
[0019] The moment the cigarette enters the detection area, an infrared trigger activates a high-speed industrial camera. These cameras use global shutter CMOS sensors instead of rolling shutters to completely eliminate the rolling shutter effect that may occur with high-speed moving objects. Combined with a coaxial light source of a specific wavelength, the light penetrates the cigarette's cross-section evenly, creating a sharp brightness contrast between the dark ink of the cigarette paper and the light-colored tobacco shreds on the photosensitive element. The initial image acquired by the camera is in color and contains rich spectral information. However, to simplify the computational complexity of subsequent algorithms and improve processing speed, the color image first needs to be converted to grayscale. This process is not a simple averaging, but rather a weighted average of the brightness values of each color channel based on the characteristics of human vision or the spectral response curve of a specific light source, generating a grayscale image that accurately reflects the light and dark levels of the object. Next, to suppress the high-frequency random noise inevitably introduced during imaging, the system uses a Gaussian filtering algorithm to smooth the grayscale image. The core idea of Gaussian filtering is to scan the image using a convolution kernel composed of a two-dimensional Gaussian function, which has the highest weight at the center point and decreases in a bell-shaped curve towards the edges. During convolution, the new value of each pixel is determined by the values of itself and multiple neighboring pixels, with pixels farther from the center contributing less. This approach effectively smooths noise while preserving the edge contour information of objects in the image, avoiding edge blurring and laying a good foundation for the subsequent double-threshold segmentation.
[0020] The goal of the contour extraction and preliminary judgment stage is to accurately delineate the physical boundaries of the cigarette cross-section from the preprocessed grayscale image and to conduct a preliminary health assessment. This patent abandons the traditional single-threshold segmentation method and innovatively employs a dual-grayscale threshold segmentation algorithm. To understand this technology, it is first necessary to clarify its advantages in complex image backgrounds. The unique characteristic of a cigarette cross-section image lies in its composition of two main materials: dark, dense cigarette paper and light, loosely structured tobacco shreds. On the grayscale histogram, these two materials exhibit two separate peaks. If only a medium-level threshold is set, tobacco shreds in the middle grayscale value may be incorrectly classified as background, or the dark edges of the cigarette paper may be broken due to adhesion to some dark tobacco shreds.
[0021] Dual-threshold segmentation is designed to resolve this contradiction. The algorithm sets two thresholds: a higher threshold and a lower threshold. The higher threshold setting strategy relies heavily on intelligent analysis of the image's grayscale histogram. The system automatically identifies the dominant peak representing the tobacco paper region in the histogram and locates its right inflection point. An inflection point is the point where, after a certain point, the number of pixels decreases sharply with increasing grayscale value. Setting the higher threshold to a certain multiple of the grayscale value at this inflection point ensures that only the darkest and solidest parts of the tobacco paper are selected, thus outlining the clearest and most continuous contour of the tobacco paper. Simultaneously, the lower threshold focuses on the boundary between the tobacco and the tobacco paper. The system identifies the dominant grayscale peak representing the tobacco region and locates its left inflection point, setting the lower threshold to a certain multiple of the grayscale value at this inflection point. This allows transitional areas with grayscale values between the tobacco body and the tobacco paper to be included in the selection, effectively compensating for contour loss caused by excessively dark or densely packed tobacco. By merging the results of these two threshold segmentations, the system obtains a preliminary mask that includes both the complete edge of the cigarette paper and the boundary information of the tobacco shreds.
[0022] However, even so, the edges of the initial mask may still contain small burrs, breaks due to noise, or tiny indentations. To generate a smooth, complete closed contour curve, morphological image processing techniques must be introduced. Morphological processing is a mathematical method based on set theory and topology. It uses a probe called a structuring element to slide across the image to detect and modify the shape of the target. In this step, the system first performs a morphological dilation operation. Dilation can be understood as using a circular structuring element to probe foreground pixels in the image. If there is a foreground pixel within the area covered by the structuring element, the center position of the structuring element is marked as the new foreground. This process expands the object's boundary outward, filling in small gaps in the contour line and connecting broken edges. Next, the system performs a morphological erosion operation. Erosion is the inverse operation of dilation; it preserves the center position of the structuring element as foreground only when the structuring element completely covers the foreground. This process contracts the object's boundary inward, eliminating small burrs and isolated noise points on the contour edges. By performing expansion and corrosion operations as a combined step, commonly known as the closing operation, it can perfectly close gaps and smooth boundaries without significantly changing the overall shape and area of the object, ultimately generating a measurable, high-quality cigarette cross-sectional profile curve.
[0023] With this precise contour curve, the system can calculate a series of key geometric parameters. Perimeter is the total length of the contour curve, area is the size of the internal region enclosed by the contour, and roundness is a dimensionless index that measures how close an object's shape is to an ideal circle. The calculation logic is that for a perfect circle, the ratio of the square of its circumference to its area is a constant. The closer the roundness is to one, the more round the cross-section. When the system calculates that the perimeter of a cigarette cross-section deviates significantly from a preset standard value, or the roundness is below an empirical threshold, or obvious gaps and irregular protrusions are visually observable, the sample is marked as having an abnormal contour. This is not a final judgment, but an important risk indicator, meaning that the cigarette has a physical defect and needs to proceed to the next step of the joint analysis process to determine whether the condition of the internal tobacco has also been affected.
[0024] If contour extraction focuses on the external shape of a cigarette, then semantic segmentation and tobacco analysis delve into its internal composition. This patent employs a specially designed deep learning model, based on an improved U-Net++ network. U-Net++ is an enhancement of the classic U-Net architecture, with its core innovation being the introduction of dense skip connections in the decoder. In traditional U-Net, the feature maps of each layer of the encoder are directly connected to a symmetrical layer of the decoder. U-Net++, however, allows each layer of the decoder to receive information from all shallow layers of the encoder. The technical significance of this dense connection lies in creating a multi-scale feature fusion environment. While feature maps from shallow layers have high resolution, they possess weaker semantic information, preserving details such as the fine texture and graininess of the tobacco; whereas feature maps from deeper layers, although lower in resolution, possess strong semantic information, understanding what constitutes tobacco, cigarette paper, and background. Through dense connections, the model can utilize both high-level abstract semantic information and low-level detailed information at every stage of image resolution recovery. This enables the model to achieve far greater accuracy and robustness than traditional models when segmenting targets with complex textures and varied shapes, such as tobacco shreds.
[0025] To further enhance the model's ability to capture key information, this patent embeds channel attention and spatial attention modules at each level of the encoder. The channel attention module enables the model to automatically evaluate the importance of each channel in the feature map. In convolutional neural networks, different convolutional kernels extract different features; some channels may be sensitive to the filamentous texture of tobacco, some to the smooth surface of cigarette paper, and some to background noise. The channel attention mechanism learns a weight coefficient for each channel, strengthening the responses of channels that contribute significantly to correct classification through fully connected layers and activation functions, while suppressing the responses of irrelevant or redundant channels. This makes the model's feature extraction process more intelligent and focused. The spatial attention module focuses on the spatial location on the feature map. It analyzes each spatial location on the feature map, learning a spatial weight map, enabling the model to automatically allocate more computational resources and attention to key areas such as cross-sectional edges and internal structures when processing images, while ignoring irrelevant blank background areas. The synergistic effect of these two attention mechanisms greatly improves the model's ability to locate and segment targets in complex backgrounds.
[0026] Model training relies heavily on high-quality labeled data and a scientifically sound loss function. This patent employs a weighted combination of Dice Loss and cross-entropy loss. At the data level, cigarette cross-section images exhibit a natural class imbalance: the number of pixels representing tobacco shreds, which dominate the image, far exceeds the number of pixels representing damaged or blank areas. Using a traditional cross-entropy loss function, the model tends to simply predict all pixels as tobacco shreds, achieving high accuracy but ignoring those small, insignificant defects. The Dice Loss function was designed to address this class imbalance in segmentation tasks. Its calculation logic is based on the ratio of the intersection to the union of the predicted segmentation region and the ground truth labeled region, essentially a metric for measuring the similarity between two sets. By introducing Dice Loss, the model is strongly motivated during training to diligently find and correctly segment those few but crucial defect regions. By combining Dice Loss with cross-entropy loss in a weighted manner, the model can not only grasp the overall class distribution, but also accurately optimize the recognition performance of a few classes. This ensures that even in complex situations such as extremely uneven tobacco filling, the model can still output high-precision pixel-level segmentation results.
[0027] Based on the pixel-level mask output by the model, the system can perform in-depth analysis of the tobacco's state. First, it calculates the tobacco pixel ratio, which is the ratio of the total number of pixels in the tobacco region to the total number of pixels in the entire cross-section. This is a macroscopic indicator of the filling amount. Second, it calculates the tobacco distribution uniformity by dividing the tobacco region into a grid, calculating the local density within each grid, and then determining its standard deviation. The larger the standard deviation, the more uneven the tobacco distribution. When the ratio is too low, the uniformity is too high, or large continuous blank areas appear in the tobacco region, the system determines that the tobacco is not fully filled. Furthermore, the system logically overlays the mask of the damaged area marked in the contour extraction stage with the mask of the blank area in this stage. If the boundary of the damaged area coincides with the boundary of the blank area, and calculations show that the area of the blank area has significantly increased due to the damage, this indicates that the cigarette is not only externally damaged, but its internal filling has also been lost or exposed. In this case, the system will not simply give two independent conclusions, but will generate a higher-level composite judgment: damage plus insufficient tobacco filling. This composite assessment is crucial for evaluating the overall value and safety of cigarettes, as it indicates the severity and relevance of the defects.
[0028] Although semantic segmentation models are already very powerful, for some extremely small defects, such as micrometer-sized pinholes or a very small amount of missing tobacco shreds, a single semantic segmentation may be smoothed out due to its small pixel ratio or treated as noise during training. To address this, this patent designs a fine defect detection step as a supplement and enhancement to the aforementioned macroscopic analysis.
[0029] The core idea of this step is template comparison and anomaly detection. The system pre-builds or learns online a pixel grayscale distribution template of a standard cigarette cross-section. This template is not a simple average image, but rather the result of statistical modeling of the grayscale value distribution of each pixel at different locations in a large number of qualified product cross-section images. It records what the pixel grayscale value should be at different locations such as the center, edge, and corner of the cross-section under ideal conditions, and the allowable range of fluctuation. When a new image to be detected enters this step, the system compares its grayscale value pixel by pixel with the expected value at the corresponding location in the template. If the deviation of a pixel's grayscale value from the expected value exceeds a set tolerance, it will be marked as an abnormal pixel.
[0030] However, pixels with mere grayscale deviations are not necessarily defects, as dust, fluff, or momentary light flicker can all cause similar phenomena. Therefore, this patent introduces a spatiotemporal continuity verification mechanism, which is the core technology of this section. Spatiotemporal continuity verification comprises two dimensions. First, the spatial dimension: the system analyzes all marked anomalous pixels to see if they form a connected region in spatial distribution. Isolated, scattered anomalous points are highly likely to be noise, while connected, shaped anomalous regions are more likely to be genuine physical defects. Second, the temporal dimension: the system retrieves the state of the anomalous pixel in the previous and subsequent frames. Since the cigarette falls at high speed, its position changes between consecutive frames, requiring coordinate mapping. The system analyzes whether the anomalous features at that location persist after coordinate transformation in consecutive frames, exhibiting similar forms and intensities. Only when an anomalous point appears continuously in time and forms a valid connected region in space is it ultimately confirmed as a valid defect signal. This mechanism acts like a strict judge, requiring evidence to withstand scrutiny at different times and from different angles, thereby minimizing the false alarm rate while also keenly capturing those fleeting minor flaws.
[0031] After analyzing the outline, tobacco shreds, and minor defects, the system enters the comprehensive decision-making stage, namely, multi-dimensional judgment. This patent creatively proposes a three-dimensional judgment mode that compares horizontally, vertically, and with standards, forming the core of the system's intelligence.
[0032] Horizontal comparison, or multi-channel comparison at the same time, is based on the statistical principle of population consistency. Cigarettes from the same production batch and at the same point in time should be homogeneous across all channels. Therefore, the system calculates the average of various detection indicators across all channels at the same moment. If a particular indicator in a channel, such as the percentage of tobacco shreds, deviates significantly from the overall average, and its own analysis also shows anomalies, then this deviation is highly likely a genuine individual defect. Conversely, if all channels show slight, unidirectional deviations, it's unlikely that all cigarettes have the same problem simultaneously; it's more likely a systemic interference, such as an overall decrease in the brightness of a certain light source. In this case, the system will prioritize issuing an alarm to prompt equipment inspection, rather than rejecting all products.
[0033] Longitudinal comparison, or historical data comparison, is based on the stability analysis of time series data. The system continuously records and stores the detection data for each batch and each channel. When a new sample arrives, the system compares its parameters with the average of several recent samples. If a sample's parameters deviate significantly from the recent sample average, but have not yet reached the disqualification standard, the system will not immediately make a judgment, but will mark it as a suspicious sample and conduct secondary identification or manual review. More importantly, longitudinal comparison also serves as a function of equipment health monitoring. The system continuously tracks the failure rate of each channel. If, over a period of time, the failure rate of a certain channel is consistently significantly higher than that of other channels, this violates the statistical principle of random distribution, strongly suggesting that the imaging equipment in that channel may be malfunctioning, such as lens contamination, inaccurate focusing, or light source aging. In this case, the system will automatically trigger the equipment self-test program, suspend the automatic rejection function of that channel to prevent batch misjudgments, and issue an alarm to maintenance personnel.
[0034] Standard comparison involves comparing sample parameters with two sets of standards. One set is the initial standard, a set of hard indicators derived from offline calibration of a large number of qualified samples, representing the minimum acceptable level for product quality. The other set is the dynamic standard, a fluctuating range with statistical confidence intervals generated iteratively based on historical big data during online system operation. The dynamic standard adaptively adjusts to minor fluctuations in the production process. If a sample only slightly exceeds the range of the initial standard, but its indicators remain within the confidence interval of the dynamic standard and pass the horizontal comparison, then it is likely a normal process fluctuation rather than a defect. Multidimensional judgment involves weighted fusion of the results of these three comparisons, using a complex decision logic tree to arrive at the most reliable judgment conclusion.
[0035] Finally, to ensure the system remains up-to-date and never falls behind, this patent incorporates a dynamic standard iteration process. This is a closed-loop, self-evolving system. Through clustering algorithms, the system continuously categorizes massive amounts of samples into three classes: qualified, questionable, and unqualified. A manual review interface provides an indispensable error correction and calibration channel for this automated process. When operators discover misjudgments or omissions, they can input feedback. The system then uses this feedback to trace back to the problematic threshold or model parameters and makes targeted adjustments. Periodically, the system conducts a comprehensive review and iterative update of all algorithm models and judgment thresholds. This self-learning and self-improvement mechanism ensures that the system is not a rigid set of rules, but a dynamic, intelligent entity capable of adapting to new processes, materials, and environments.
[0036] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principle of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for visually detecting cigarettes, characterized in that, The method includes the following steps: The data acquisition and preprocessing steps involve the cigarette falling synchronously in multiple channels. The high-speed cameras in each channel are activated by an infrared triggering device to capture high-definition image sequences of the cigarette cross-section. The images are then preprocessed by grayscale conversion and Gaussian filtering. The contour extraction and preliminary judgment steps involve applying a dual grayscale threshold segmentation algorithm to the grayscale image to extract the edges of the cigarette paper and the boundaries of the tobacco shreds, and merging them to generate a preliminary contour mask; eliminating edge burrs and filling gaps through morphological dilation and erosion operations to generate a complete closed cross-sectional contour curve; calculating the perimeter, area, and roundness features of the contour; if the perimeter deviation exceeds the limit, the roundness is lower than the threshold, or there is an obvious gap, it is marked as a contour anomaly. The semantic segmentation and tobacco analysis steps involve inputting the pre-processed image into a pre-trained semantic segmentation model to obtain pixel-level masks for tobacco paper, tobacco shreds, blank areas, and damaged areas. Based on the tobacco shred mask, the percentage and distribution uniformity of tobacco shred pixels are calculated. If the percentage is too low, the uniformity is too high, or there are large continuous blank areas, it is determined that the tobacco shreds are not full. If the damaged part of the contour abnormal area overlaps with the blank area and the area increases significantly, it is determined to be a combination of damaged and incomplete tobacco shreds. The minor defect detection steps involve constructing a standard cigarette cross-section pixel grayscale distribution template, comparing the current image pixels with the template, and filtering out abnormal pixels with significant grayscale deviations. The spatial continuity of the abnormal points is analyzed. If they form an effective area within the cigarette paper outline, they are judged as minor damage. If they are blank pixels and clustered at the center of the cross-section, they are judged as slight tobacco incompleteness. The multi-dimensional judgment process involves: horizontal comparison, calculating the average value of parameters for each channel at the same time point to determine isolated anomalies; vertical comparison, comparing historical batch data to identify suspicious samples and equipment failures; and standard comparison, combining initial and dynamic standards for dual verification to comprehensively determine product qualification.
2. The cigarette visual inspection method according to claim 1, characterized in that, Grayscale histogram analysis is performed on the grayscale image to identify the grayscale peaks corresponding to the dark cigarette paper region and the light-colored tobacco shred region. A high threshold is set as a preset multiple of the grayscale value corresponding to the right inflection point of the grayscale peak in the cigarette paper region to effectively capture the clearest edge of the cigarette paper outline. A low threshold is set as a preset multiple of the grayscale value corresponding to the left inflection point of the grayscale peak in the tobacco shred region to completely cover the transition boundary between the tobacco shred and the cigarette paper. The grayscale image is segmented using these adaptively determined high and low thresholds, and combined with subsequent morphological processing, a complete cigarette cross-sectional contour mask is generated.
3. The cigarette visual inspection method according to claim 1, characterized in that, In the aforementioned minor defect detection step, a spatiotemporal continuity verification mechanism is introduced: After identifying the set of abnormal pixels, not only is its spatial continuity analyzed, but it is also compared with the state of the pixel in the preceding and following frames in the time series. Only when an abnormal pixel exhibits the same or similar abnormal features in multiple consecutive frames of images, and it forms a connected region with neighboring abnormal pixels in space, is it finally confirmed as a valid defect signal.
4. The cigarette visual inspection method according to claim 1, characterized in that, In the horizontal comparison of the multi-dimensional judgment steps, a channel correlation confidence algorithm is introduced to quantify the reliability of anomaly judgment: The confidence level of the correlation between channels is defined as a composite function, whose independent variables include the physical distance between the two channels, the current environmental sensor reading, and the similarity of specific feature parameters in the detection results of the two channels. When a channel is determined to be unqualified, the system calculates its confidence level with all other channels. If the average confidence level is lower than a preset threshold, it is determined to be an isolated anomaly and confirmed as a product defect. If the average confidence level is high, it is determined to be regional interference, triggering an equipment maintenance alarm instead of rejecting the product.
5. The method for visual inspection of cigarettes according to claim 1, characterized in that, The longitudinal comparison in the multi-dimensional judgment step includes continuous monitoring logic for the performance of a single channel: The system continuously tracks and records the defect rate of each channel. When the defect rate of a certain channel is significantly higher than the average level of other channels, the system determines that the acquisition equipment of that channel may be faulty, and then triggers the equipment self-test program and suspends the automatic rejection function of that channel, while issuing an alarm to the maintenance personnel.
6. The method for visual inspection of cigarettes according to claim 1, characterized in that, The standard iterative steps include an anomaly pattern tracing and feedback submodule: When the system discovers through longitudinal comparison that the incidence of a certain type of non-conforming product has risen sharply in a short period of time, the module will automatically initiate source tracing analysis, retrieve the production process parameters for the relevant time period and perform correlation analysis with the incidence of the defect; once it is confirmed that the defect is strongly correlated with the deviation of a specific process parameter, the system will automatically generate an analysis report containing a problem description, related parameters, and suggested adjustment range, and push it to the central control system of the production line.
7. A cigarette visual inspection system implementing any one of claims 1-6, characterized in that, The system hardware architecture includes: Multi-channel synchronous imaging array: It consists of multiple independent detection stations arranged linearly. Each station is equipped with a high-speed industrial camera and a coaxial light source module of a specific wavelength. Precision optical lens group ensures that the depth of field and field of view of all channels are consistent. High-precision triggering and conveying module: It adopts a vibrating conveyor belt driven by a servo motor, in conjunction with photoelectric sensors, to ensure that the cigarettes fall into the detection area at a constant speed and posture, and the programmable logic controller sends precise synchronous trigger pulses; Edge intelligent computing unit: Deploy embedded AI computing devices near each inspection station, equipped with deeply optimized semantic segmentation and contour analysis algorithms to achieve millisecond-level local reasoning and preliminary judgment; Central Data Management and Analysis Server: This server runs a database to store all historical data and deploys a federated learning framework to coordinate model updates across edge nodes. It also provides a visual web interface for operators to monitor, review, and manage standard iterations.