Cigarette carton outer package quality detection and identification system
Through the periscope multi-view layout and the image acquisition module of dynamic light sources, combined with traditional algorithms and deep learning, the problems of low efficiency, insufficient accuracy and blind spots of cigarette cartridge outer packaging detection are solved, and the detection effect is achieved, with high accuracy, strong real-time and good adaptability is achieved, meeting the needs of modern quality control.
Patent Information
- Application Number
- CN202510393197.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-08-08
AI Technical Summary
The existing cigarette cartridge outer packaging inspection technology has problems such as low detection efficiency, insufficient accuracy, many blind spots in detection, and inability to adapt to high-speed transportation and ambient light changes, making it difficult to meet modern quality control needs.
The image acquisition module adopts a periscope multi-view layout, combining dynamic light sources and conveying mechanisms, combined with traditional algorithms and lightweight deep learning, realizes all-round detection; defects are identified through template matching, morphological processing and multi-level threshold judgment, and standardized reports are generated and self-optimized in combination with the data management module.
It has achieved high-precision, strong real-time and good adaptability testing, significantly improved production efficiency and quality control level, reduced missed inspection rates, supported diversified inspection scenarios and met quality control compliance requirements.
Smart Images

Figure CN120446125A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cigarette carton outer packaging quality detection and identification, and in particular to a cigarette carton outer packaging quality detection and identification system. Background Art
[0002] In automated cigarette production lines, carton packaging quality inspection is a critical step in ensuring product appearance consistency and brand image. Traditional inspection methods and existing technical solutions have the following core issues, which seriously restrict inspection efficiency, accuracy, and engineering application:
[0003] 1. Manual quality inspection is inefficient and unreliable
[0004] Manual visual inspection was the primary quality control method in the early days, but its inspection efficiency was extremely low (a single person could process <200 items per day), making it difficult to meet the real-time inspection requirements of high-speed production lines (typically with a production capacity of ≥100,000 items per day). Furthermore, manual inspection is significantly affected by subjective judgment and fatigue, resulting in a high rate of missed detections (especially for minor damage, blurred inspection codes, and other defects). Furthermore, it lacks standardized recording and traceability of inspection data, making it difficult to meet the objectivity and quantification requirements of modern quality control.
[0005] 2. Traditional machine vision systems have detection blind spots and adaptability defects
[0006] Early automated inspection systems mostly used a single camera or a fixed-viewing angle layout, which could only cover part of the carton surface (such as the front and top). They lacked effective detection of complex curved surfaces such as the side and bottom surfaces, or hidden areas (such as tears at seams and indentations on the bottom), resulting in visual blind spots. Even if multi-faceted inspection is achieved through mechanical rotation, there are still problems such as slow inspection speed (needing to pause for positioning) and easy wear of the mechanism, making it unable to adapt to high-speed conveying scenarios above 0.5m / s. In addition, traditional systems rely on fixed light sources and preset thresholds, and lack the ability to adaptively adjust to reflections from cellophane and fluctuations in ambient light intensity (such as differences in lighting at different workstations in a workshop). False detection or missed detection often occurs due to unstable image quality. Therefore, we propose a quality inspection and recognition system for the outer packaging of cigarette cartons. Summary of the Invention
[0007] The purpose of the present invention is to address the problems existing in the background technology and to propose a system for detecting and identifying the quality of the outer packaging of cigarette cartons.
[0008] The technical solution of the present invention is a system for detecting and identifying the quality of outer packaging of cigarette cartons, comprising:
[0009] The image acquisition module adopts a periscope multi-view layout, including multiple industrial cameras, a reflector group and a dynamic light source module. The industrial cameras are distributed on both sides and the top of the inspection station, and the reflector group covers the six inspection surfaces of the cigarette box;
[0010] Dynamic light source module, including a ring LED light source and a photosensor;
[0011] The conveying mechanism is a double-belt conveyor driven by a stepper motor, which cooperates with a photoelectric sensor to trigger image acquisition;
[0012] Image processing module, including:
[0013] Image preprocessing unit, which performs grayscale normalization, denoising and edge enhancement on the collected images;
[0014] The defect analysis unit uses template matching, morphological processing, and a multi-level threshold determination mechanism to identify defects such as burnt sales codes, damaged packaging, and torn packaging.
[0015] Data management module: Parallel to the image processing module, it includes a report generation submodule, a visualization submodule and a data traceability submodule, which are used to automatically generate inspection reports, display test results in real time and encrypt and store data.
[0016] Optionally, in the image acquisition module:
[0017] The reflector assembly is made of optical glass with a refractive index of 1.5 and an anti-reflection coating on the surface. The reflective surface roughness is ≤ Ra0.01 μm. The reflector and the detection surface are at an angle of 45°. The spacing between adjacent cameras is 150 mm ± 5 mm. The installation angle of the industrial camera is 30° ± 2°, and the field of view is 60°. The light intensity adjustment formula of the dynamic light source module is:
[0018] I out =I base +k·(I env -I threshold )
[0019] Among them, I base is the basic brightness, k is the compensation coefficient, I env is the ambient light intensity, I threshold is the threshold, the ambient light intensity I env Collected in real time by light-sensitive sensors.
[0020] Optionally, the image preprocessing unit includes:
[0021] The grayscale normalization subunit uses Gamma correction to perform nonlinear transformation on the image to enhance dark details. The Gamma correction formula is used to perform nonlinear transformation on the image:
[0022]
[0023] Among them, I out(x, y) is the pixel value after correction. The pixel with coordinates (x, y) is the result of Gamma correction. in (x, y) is the pixel value before correction, 255: represents the value range of pixel value, I in is the input pixel value, Gamma = 0.5 is used to enhance dark details;
[0024] The denoising subunit combines a bilateral filter to eliminate high-frequency noise while retaining edge information. The noise is eliminated by the bilateral filtering algorithm. The formula is:
[0025]
[0026] Among them, the spatial kernel weight Color kernel weights The neighborhood size is 5×5, (x, y) is the current pixel coordinate, (i, j) is the pixel coordinate in the area, σ s is the standard deviation of spatial distance, σ c is the standard deviation of color difference;
[0027] The edge enhancement subunit sharpens the image through the Laplacian operator. After edge extraction, a morphological opening operation is performed to eliminate isolated noise points. The image is sharpened through the Laplacian operator. The kernel matrix is:
[0028]
[0029] The superposition factor is 0.8.
[0030] Optionally, the defect analysis unit includes:
[0031] The monitoring code burn detection subunit is implemented through the following steps:
[0032] Region positioning: Based on the preset coordinates, the monitoring and cancellation code area is intercepted, and bilinear interpolation is used to eliminate image distortion. The structural similarity index between the monitoring and cancellation code area coordinates x:120-150, y:80-110 and the standard template is calculated. The formula is:
[0033] SSIM weighted =0.6·SSIM luminance +0.4 SSIM contrast
[0034] Among them, the brightness component is: C1=(0.01·255) 2
[0035] Contrast component: C2=(0.03·255) 2
[0036] Among them, μX , μ Y is the mean brightness, σ X ,σ Y is the brightness standard deviation, σ XY is the brightness covariance, and the decision threshold is set to 0.85;
[0037] Template matching: Calculate the structural similarity index between the intercepted area and the standard template, and set the matching threshold to 0.85. weighted <0.85 triggers an alarm;
[0038] Among them, SSIM weighted : The weighted structural similarity index is used to comprehensively evaluate the degree of burnt damage in the monitoring and sales code area;
[0039] SSIM luminance : Luminance component similarity, reflecting the matching degree of image grayscale distribution;
[0040] SSIM contrast : Contrast component similarity, reflecting the matching degree of local texture of the image;
[0041] Weight coefficients: 0.6 and 0.4 represent the contribution ratios of brightness and contrast components, respectively, and are determined through experimental optimization;
[0042] Dynamic update: A dynamic template library is constructed based on historical detection data. A sliding window mechanism is used to match the monitoring and cancellation code area. When the match fails, manual review is triggered. A sliding window mechanism is used to match the monitoring and cancellation code area. When the match fails, the coordinate offset is corrected through an interpolation algorithm. The offset compensation formula is:
[0043] Δx=α·(x template -x detected ),Δy=β·(y template -y detected ), where Δx,
[0044] Δy is the coordinate compensation amount, α=0.8, β=0.8 is the compensation coefficient, and the coordinate error after correction is ≤±0.5 pixels; x template ,y template is the coordinate of the monitoring code area in the template; detected ,y detected The coordinates of the detected monitoring code area;
[0045] The package damage detection subunit performs multi-level determination:
[0046] Level 1 judgment: Extract abnormal contours through Canny edge detection, screen continuous edges with length greater than 5 mm, and calculate edge curvature;
[0047] Secondary judgment: Use the watershed algorithm to divide the box surface into multiple sub-regions, and count the proportion of white background pixels in each region:
[0048]
[0049] Among them, R white The ratio of white background pixels is used to determine packaging damage defects;
[0050] N white is the number of white background pixels in the detection area;
[0051] N total is the total number of pixels in the detection area;
[0052] Threshold: When R white When the percentage is >5%, it is considered as a packaging damage defect;
[0053] Level 3 judgment: A lightweight CNN model is used to perform semantic segmentation on the suspected area to distinguish between real defects and pattern interference;
[0054] The tear detection subunit extracts the directional gradient histogram features and inputs them into the SVM classifier to identify the tear texture. When the classification confidence is greater than 0.9, it is judged as a defect.
[0055] Optionally, the monitoring code burn detection subunit further includes:
[0056] The template adaptive optimization module uses an incremental learning algorithm to update the template weights, generating a new template and eliminating the old template after every 1,000 detections;
[0057] Regional matching fault tolerance mechanism: allows local area matching deviation of ±5%, and uses thin plate spline interpolation to repair the distortion of the monitoring code area caused by the deformation of the strip box.
[0058] Optionally, the package damage detection subunit further includes:
[0059] Adaptive threshold adjustment subunit: Dynamically adjusts the white background pixel threshold based on the cigarette brand template library and uses the U-Net model to perform pixel-level segmentation of the exposed content area. The segmentation is considered valid when the intersection over union (IoU) ratio is greater than 0.85.
[0060] Reflection suppression module: A linear polarizer is installed in front of the light source, and the reflection noise of the cellophane is separated by frequency domain analysis. The reflection suppression algorithm eliminates the reflection of the cellophane through frequency domain filtering. The formula is:
[0061] G(μ,v)=F(u,v)·H(u,v)
[0062] Among them, G(μ,v) is the result function after frequency domain processing, (μ,v) is the frequency domain coordinate, F(u,v) is the frequency domain function of the image Fourier transform input, and the filter H(u,v) is a Gaussian low-pass filter.
[0063] Optionally, the data management module includes:
[0064] The report generation subunit automatically generates an inspection report containing defect type, location coordinates, and confidence level. The report format is compatible with PDF / Excel and is digitally signed using the RSA-2048 algorithm. The signature formula is:
[0065] S=M d mod n
[0066] Where M is the reported hash value (SHA-256), d is the private key exponent, and n is the modulus;
[0067] The visualization subunit displays the test result heat map, defect distribution statistics and historical data trend map in real time through the human-machine interface. The heat map color mapping formula is:
[0068]
[0069] Among them, Score is the comprehensive score of defects;
[0070] The data tracing subunit uses blockchain technology to encrypt and store detection data. Each record is attached with a timestamp, device ID and hash value. Blockchain technology is used to store data, and each record is encrypted as follows: Block = Hash (PrevHash||Timestamp||Data||Nonce), where Block is the blockchain block, PrevHash is the hash value of the previous block, Timestamp is the timestamp, Data is the detection data, Hash is the SHA-256 algorithm, Nonce is a random number, and the consensus algorithm is PBFT.
[0071] Optionally, the system further includes a self-learning optimization module:
[0072] Defect sample library, which stores historical defect images and manual annotation results, and is classified according to burnt defect codes, damaged packaging, and torn items. The sample capacity is ≥ 100,000 images.
[0073] The model iteration submodule updates the CNN segmentation model through transfer learning every quarter and optimizes the loss function. The loss function is:
[0074]
[0075] in, is the total loss function, λ is the weight coefficient, is the Dice loss, Cross entropy loss, λ=0.6, Update model parameters every quarter;
[0076] In the false detection feedback submodule, after manual review of the false detection samples, the system automatically adjusts the threshold parameters and updates them to the brand template library, and generates a false detection analysis report.
[0077] Optionally, the image processing module adopts a hybrid algorithm architecture:
[0078] Traditional algorithm layer, which implements template matching, morphological processing and edge detection based on OpenCV;
[0079] The deep learning layer deploys a lightweight MobileNetV3 model on the FPGA chip and uses the TensorRT acceleration engine for real-time inference.
[0080] The comprehensive judgment formula of the hybrid architecture is:
[0081] Score=0.7S 传统 +0.3·S 深度学习
[0082] When Score ≥ 0.8, it is judged as a defect, an alarm is triggered and the image is retained.
[0083] Optionally, the deep learning layer includes:
[0084] Data augmentation module, which adds Gaussian noise, random rotation, brightness perturbation and affine transformation to the training images;
[0085] The knowledge distillation module migrates the feature extraction capabilities of the ResNet50 model to MobileNetV3, retaining the accuracy of key feature recognition through KL divergence loss;
[0086] Dynamic pruning module, which prunes redundant neural network layers based on FPGA computing power.
[0087] Compared with the prior art, the present invention has the following beneficial technical effects:
[0088] Six industrial cameras, coupled with a 45° reflector, cover the six inspection surfaces of the strip, eliminating blind spots and ensuring comprehensive capture of appearance defects. Real-time compensation for ambient light intensity, combined with a 625nm ring-shaped LED light source and linear polarizers, suppresses reflections from cellophane and ensures image clarity.
[0089] Using traditional algorithms to quickly locate basic defects, deep learning is used to identify complex features, with single-frame processing in less than 50ms, balancing real-time performance and accuracy. For defects such as burned sales codes, damaged and torn packaging, layered detection using SSIM similarity calculation, watershed segmentation, and HOG+SVM, combined with a dynamic template library and deformation compensation, significantly reduces missed and false detection rates.
[0090] It supports dynamic adaptation to lighting, packaging materials, and brand differences, and is compatible with diverse detection scenarios. It improves model robustness through data enhancement, knowledge distillation, and dynamic pruning; combining false positive feedback with incremental learning enables self-optimization of system performance.
[0091] Generate standardized reports with defect location and confidence levels, protected by RSA-2048 digital signatures to ensure tamper-proof quality control and compliance. Hyperledger Fabric blockchain-based storage of inspection data supports batch and time range queries, ensuring transparency of the inspection process and immutability of data.
[0092] Through the full-link technological innovation of "image acquisition-processing and analysis-data management-self-optimization", this invention realizes the core values of high-precision detection, high real-time performance, strong adaptability, and full-process traceability, providing an intelligent and automated solution for the quality control of cigarette outer packaging, significantly improving production efficiency and quality control level. BRIEF DESCRIPTION OF THE DRAWINGS
[0093] Figure 1 The diagram is a schematic diagram of a system for detecting and identifying the quality of outer packaging of cigarette cartons according to the present invention. DETAILED DESCRIPTION
[0094] The technical solutions of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. It will be apparent that the described embodiments are some, but not all, embodiments of the present invention. The components of the embodiments of the present invention generally described and illustrated in the accompanying drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but rather merely represents selected embodiments of the present invention.
[0095] Example
[0096] like Figure 1 A cigarette box outer packaging quality detection and identification system includes an image acquisition module, a dynamic light source module, a conveying mechanism, an image processing module, and a data management module. Each module is described in detail below.
[0097] In this embodiment, the image acquisition module adopts a periscope multi-viewing layout, including six industrial cameras, a 45° reflector group and a dynamic light source module. The industrial cameras are distributed on both sides and the top of the inspection station, and the reflector group covers the six inspection surfaces of the cigarette box. In the image acquisition module:
[0098] The reflector group is made of optical glass with a refractive index of 1.5, an anti-reflection film is coated on the surface, and the roughness of the reflective surface is ≤Ra0.01μm. The reflector and the detection surface are at an angle of 45°, and the distance between adjacent cameras is 150mm±5mm; the installation inclination angle of the industrial camera is 30°±2°, the field of view angle is 60°, and the Hikvision MV-CA050-10GM model camera (5 million pixels, 30fps) is used.
[0099] In this example, the image processing module adopts a hybrid algorithm architecture:
[0100] The traditional algorithm layer implements template matching (normalized cross-correlation, NCC threshold = 0.8), morphological processing (erosion iterations = 2, dilation kernel size = 5 × 5), and edge detection (Canny high and low threshold ratio = 1:3) based on OpenCV.
[0101] The deep learning layer deploys a lightweight MobileNetV3 model on an FPGA chip (Xilinx Zynq UltraScale+, 600K logic units) and uses the TensorRT acceleration engine (FP16 precision, batch size = 8) to achieve real-time inference (single frame < 50ms).
[0102] The comprehensive judgment formula of the hybrid architecture is:
[0103] Score=0.7S 传统 +0.3·S 深度学习
[0104] When Score ≥ 0.8, it is determined to be a defect, an alarm is triggered, and the image is saved (the saving format is PNG, the compression level = 9).
[0105] Furthermore, the deep learning layer includes:
[0106] Data augmentation module, which adds Gaussian noise (σ=0.05), random rotation (±5°), brightness perturbation (±10%), and affine transformation (±5 pixel translation) to the training images to improve the robustness of the model;
[0107] The knowledge distillation module migrates the feature extraction capabilities of the ResNet50 model to MobileNetV3, retaining the key feature recognition accuracy through KL divergence loss (temperature parameter T = 2);
[0108] Dynamic pruning module, which prunes redundant neural network layers (removes channels with weights < 1e-4) based on FPGA computing power (real-time remaining logic units > 30%).
[0109] The dynamic light source module includes a ring-shaped LED light source with a wavelength of 625nm and a photosensor, supports adaptive brightness adjustment based on ambient light intensity (50-1000 lux), and the distance between the center of the light source and the detection surface is 200mm±10mm. The light intensity adjustment formula of the dynamic light source module is:
[0110] I out =I base +k·(I env -I threshold )
[0111] Among them, I base is the basic brightness (50 lux), k is the compensation coefficient (0.8-1.2), I env is the ambient light intensity, I threshold is the threshold (200lux), the ambient light intensity I env Data is collected in real time by the OPT3001 photosensor. Through 6 industrial cameras + 45° reflector group: covering the 6 detection surfaces of the strip box (both sides and top), eliminating detection blind spots, and ensuring full surface detection. High-precision reflectors reduce light reflection loss and distortion to ensure image clarity. Camera parameter optimization (5 million pixels, 30fps, 30°±2° installation angle): balance field of view coverage and image resolution to adapt to high-speed transportation scenarios (0.5m / s transmission speed); ring LED light source (625nm wavelength) + linear polarizer: reduce cellophane reflections (reduction of reflection noise energy by ≥90%), combined with frequency domain filtering algorithm to improve image quality.
[0112] In addition, the conveying mechanism is driven by a stepper motor with a double-belt conveyor, which is matched with a photoelectric sensor to trigger image acquisition, with a conveying speed of 0.5m / s±10%;
[0113] It is worth mentioning that the image processing module includes:
[0114] An image preprocessing unit performs grayscale normalization, denoising, and edge enhancement on the collected image. The image preprocessing unit includes:
[0115] The grayscale normalization subunit uses Gamma correction (Gamma = 0.5) to perform nonlinear transformation on the image to enhance dark details. The Gamma correction formula is used to perform nonlinear transformation on the image:
[0116]
[0117] Among them, I out(x, y) is the pixel value after correction. The pixel with coordinates (x, y) is the result of Gamma correction. in (x, y) is the pixel value before correction, 255: represents the value range of pixel value, I in is the input pixel value, and Gamma = 0.5 is used to enhance dark details and improve defect recognition in low-contrast areas.
[0118] The denoising subunit combines a bilateral filter (σ=10, neighborhood size 5×5) to remove high-frequency noise while retaining edge information. The noise is removed by the bilateral filtering algorithm, and the formula is:
[0119]
[0120] Among them, the spatial kernel weight Color kernel weights The neighborhood size is 5×5, (x, y) is the current pixel coordinate, (i, j) is the pixel coordinate in the area, σ s is the standard deviation of spatial distance, σ c is the standard deviation of color difference; while preserving the edge, high-frequency noise is eliminated (σ=10, 5×5 neighborhood) to prevent noise from interfering with subsequent defect detection.
[0121] The edge enhancement subunit sharpens the image using the Laplacian operator (kernel size 3×3) to improve the accuracy of Canny edge detection (threshold 50-150). After edge extraction, a morphological opening operation (3×3 rectangular kernel) is performed to eliminate isolated noise points. The image is sharpened using the Laplacian operator. The kernel matrix is:
[0122]
[0123] The stacking coefficient is 0.8; the image edges are sharpened, the Canny detection accuracy is improved (threshold 50-150), and the morphological opening operation is used to eliminate isolated noise points.
[0124] The defect analysis unit uses template matching, morphological processing, and a multi-level threshold determination mechanism to identify burnt sales codes, damaged packaging, and torn defects. The defect analysis unit includes:
[0125] The monitoring code burn detection subunit is implemented through the following steps:
[0126] Region positioning: Based on the preset coordinates (x:120-150, y:80-110), the monitoring code area is intercepted, and bilinear interpolation is used to eliminate image distortion. The structural similarity index (SSIM) between the monitoring code area coordinates x:120-150, y:80-110 and the standard template is calculated. The formula is:
[0127] SSIMweighted =0.6·SSIM luminance +0.4 SSIM contrast
[0128] Among them, the brightness component is: C1=(0.01·255) 2
[0129] Contrast component: C2=(0.03·255) 2
[0130] Among them, μ X , μ Y is the mean brightness, σ X ,σ Y is the brightness standard deviation, σ XY is the brightness covariance, and the decision threshold is set to 0.85.
[0131] Template matching: Calculate the structural similarity index (SSIM) between the cut region and the standard template, and set the matching threshold to 0.85. weighted <0.85 triggers an alarm;
[0132] Among them, SSIM weighted : The weighted structural similarity index is used to comprehensively evaluate the degree of burnt damage in the monitoring and sales code area;
[0133] SSIM luminance : Luminance component similarity, reflecting the matching degree of image grayscale distribution;
[0134] SSIM contrast : Contrast component similarity, reflecting the matching degree of local texture of the image;
[0135] Weight coefficients: 0.6 and 0.4 represent the contribution ratios of brightness and contrast components, respectively, and are determined through experimental optimization;
[0136] Dynamic update: A dynamic template library is constructed based on historical detection data. A sliding window mechanism (step length 5 pixels) is used to match the monitoring and cancellation code area. If the match fails, manual review is triggered. A sliding window mechanism (step length 5 pixels) is used to match the monitoring and cancellation code area. If the match fails, the coordinate offset is corrected through an interpolation algorithm. The offset compensation formula is:
[0137] Δx=α·(x template -x detected ),Δy=β·(y template -y detected ) where Δx, Δy
[0138] is the coordinate compensation amount, α=0.8, β=0.8 is the compensation coefficient, and the coordinate error after correction is ≤±0.5 pixels; template ,y template is the coordinate of the monitoring code area in the template; detected ,y detected The detected monitoring code area coordinates; the monitoring code burning detection subunit also includes:
[0139] The template adaptive optimization module uses an incremental learning algorithm (online gradient descent method, learning rate η = 0.01) to update the template weight, generating a new template and eliminating the old template after every 1000 detections;
[0140] Regional matching fault-tolerant mechanism: allows a local area matching degree deviation of ±5%, and uses thin plate spline interpolation (TPS) to repair the distortion of the monitoring code area caused by the deformation of the strip box. The deformation compensation accuracy reaches ±0.1mm. Through the dynamic template library (sliding window step size 5 pixels) and deformation compensation (TPS interpolation, accuracy ±0.1mm), it adapts to the strip box position offset (coordinate compensation error ≤±0.5 pixels) and improves the recognition accuracy of burnt defects.
[0141] The package damage detection subunit performs multi-level determination:
[0142] Level 1 judgment: extract abnormal contours through Canny edge detection, screen continuous edges with length greater than 5 mm, and calculate edge curvature (threshold greater than 0.3);
[0143] Secondary judgment: Use the watershed algorithm (marking threshold = 0.5, merging threshold = 0.2) to segment the box surface into multiple sub-regions, and count the proportion of white background pixels (RGB ≥ 200) in each region:
[0144]
[0145] Among them, R white The ratio of white background pixels is used to determine packaging damage defects;
[0146] N white is the number of white background pixels in the detection area (pixels with RGB values ≥ 200);
[0147] N total is the total number of pixels in the detection area;
[0148] Threshold: When R white When the percentage is >5%, it is considered as a packaging damage defect;
[0149] Level 3 judgment: A lightweight CNN model (MobileNetV3, input size 224×224, output segmentation mask) is used to perform semantic segmentation on the suspected area to distinguish between real defects and pattern interference;
[0150] The tear detection subunit extracts the Histogram of Oriented Gradients (HOG) features (cell size 8×8, block size 2×2, gradient direction is divided into 9 bins), and inputs them into the SVM classifier (kernel function K(x i ,x j ) is the kernel function value, x i ,x j is the input sample data point, γ is the hyperparameter of the kernel function, ||x i -x j || is the sample x i and x j The distance between them, ||·|| is the distance calculation symbol, C=1.0, γ=0.01) identifies torn textures, and classifies them as defects when the classification confidence is greater than 0.9. The three-level judgment (edge detection → watershed segmentation → semantic segmentation) filters interference layer by layer. When the proportion of white background pixels is greater than 5%, deep learning secondary verification is triggered, which significantly reduces false detections caused by pattern interference.
[0151] Adaptive threshold adjustment subunit: Dynamically adjusts the white background pixel threshold (3%-7%) based on the cigarette brand template library, and uses a U-Net model (encoder depth of 4 layers, decoder using transposed convolution) to perform pixel-level segmentation of the exposed content area. The segmentation is considered valid when the intersection over union (IoU) ratio is greater than 0.85;
[0152] Reflection suppression module: A linear polarizer (extinction ratio > 1000:1) is installed in front of the light source. Frequency domain analysis (Fourier transform to extract high-frequency components, cutoff frequency = 0.5 Nyquist) is combined to separate the cellophane reflection noise. The reflection suppression algorithm eliminates the cellophane reflection through frequency domain filtering. The formula is:
[0153] G(μ,v)=F(u,v)·H(u,v)
[0154] Here, G(μ,v) is the result function after frequency domain processing, (μ,v) is the frequency domain coordinate, F(u,v) is the frequency domain function of the Fourier transform input of the image, and the filter H(u,v) is a Gaussian low-pass filter (cutoff frequency D0 = 0.5Nyquist, where D0 represents the Nyquist frequency and 0.5 is a fixed coefficient; Nyquist usually represents the sampling frequency). The energy of reflected noise is reduced by ≥ 90%. Lightweight MobileNetV3 + FPGA acceleration (single frame < 50ms): While ensuring real-time performance, it balances model accuracy and computing power through knowledge distillation (removing features from ResNet50) and dynamic pruning (removing low-weight channels).
[0155] In this embodiment, the data management module is parallel to the image processing module and includes a report generation submodule, a visualization submodule, and a data tracing submodule, which are used to automatically generate inspection reports, display test results in real time, and encrypt and store data. The data management module includes:
[0156] The report generation subunit automatically generates an inspection report containing the defect type, location coordinates (accuracy ±0.1mm) and confidence level. The report format is compatible with PDF / Excel and the report is digitally signed S using the RSA-2048 algorithm. The signature formula is:
[0157] S=M d mod n
[0158] Where M is the reported hash value (SHA-256), d is the private key exponent, and n is the modulus (2048 bits).
[0159] The visualization subunit displays the test result heat map (color mapping is JET, resolution 0.1mm / pixel), defect distribution statistics (classified by type / location), and historical data trend chart (sliding window = 100 items) in real time through the human-machine interface (HMI). The heat map color mapping formula is:
[0160]
[0161] Among them, Score is the comprehensive score of defects;
[0162] The data traceability subunit uses blockchain technology (Hyperledger Fabric framework, PBFT consensus algorithm) to encrypt and store detection data. Each record is attached with a timestamp, device ID and hash value (SHA-256). Blockchain technology (Hyperledger Fabric framework) is used to store data. Each record is encrypted as follows: Block = Hash (PrevHash||Timestamp||Data||Nonce), where Block is the blockchain block, PrevHash is the hash value of the previous block, Timestamp is the timestamp, Data is the detection data, Hash is the SHA-256 algorithm, Nonce is a random number, and the consensus algorithm is PBFT. It supports queries by batch number or time range.
[0163] Quality control compliance requirements are met by automatically generating reports (PDF / Excel format) containing defect type, location (accuracy ±0.1mm), and confidence level, all protected by RSA-2048 digital signatures. The human-machine interface (HMI) displays real-time defect heat maps (0.1mm / pixel resolution), distribution statistics, and historical trends. Combined with blockchain storage (Hyperledger Fabric framework, PBFT consensus algorithm), this data is traceable throughout the entire process (supporting batch / time range queries). This data is tamper-proof and auditable.
[0164] Example 2
[0165] This embodiment is based on embodiment 1. Figure 1 , also includes self-learning optimization module:
[0166] The defect sample library stores historical defect images (resolution of 5 megapixels, compression format of JPEG-LS) and manual annotation results (annotation tool is LabelImg), classified by burnt sales code, damaged packaging, and torn packaging, with a sample capacity of ≥100,000 images; it also stores ≥100,000 annotated defect images (JPEG-LS compression, 5 megapixels), classified by defect type, providing sufficient data for model iteration and covering the differences in packaging of multiple brands and forms.
[0167] The model iteration submodule updates the CNN segmentation model every quarter through transfer learning (pre-trained ResNet50 model, freezing the first 3 layers, fine-tuning the learning rate to 1e-4), and optimizes the loss function (Dice Loss + Cross Entropy, weight ratio = 6:4). The loss function is:
[0168]
[0169] in, is the total loss function, λ is the weight coefficient, is the Dice loss, Cross entropy loss, λ=0.6, Update model parameters every quarter;
[0170] In the false detection feedback submodule, after manually reviewing the false detection samples, the system automatically adjusts the threshold parameters (step size = 0.1%) and updates them to the brand template library, while generating a false detection analysis report (including false detection type, frequency, and optimization suggestions). By building a defect sample library to store historical defect images and manual annotation results, the model is provided with rich learning data, enabling it to cover a wider range of defect types and packaging forms, and improve its adaptability to complex scenarios. The model is regularly updated using transfer learning technology, and the template weights are dynamically adjusted in combination with the incremental learning algorithm, so that the system can follow product design iterations or changes in defect characteristics, continuously optimize detection accuracy, and avoid performance degradation due to long-term use.
[0171] Furthermore, after manual review of false positives, the system automatically adjusts detection thresholds and updates the brand template library, implementing a closed-loop "detection-feedback-optimization" process. This reduces manual intervention while gradually correcting detection biases and improving long-term reliability. Data augmentation technology enhances the model's robustness to image noise, deformation, and illumination changes. A dynamic pruning mechanism optimizes the model structure based on hardware computing power, enabling the system to maintain stable operation in complex production line environments and adapt to the inspection needs of different brands and specifications.
[0172] This embodiment introduces self-learning and adaptive mechanisms to give the system the ability to "self-evolve", upgrading it from a simple defect detection tool to an intelligent system that can independently optimize and continuously improve, significantly enhancing its long-term use value and environmental adaptability.
[0173] The above specific embodiments are merely several optional embodiments of the present invention. Based on the technical solutions of the present invention and the relevant inspirations of the above embodiments, those skilled in the art may make various alternative improvements and combinations to the above specific embodiments.
Claims
1. A system for detecting and identifying the quality of outer packaging of cigarette cartons, characterized in that: include: The image acquisition module adopts a periscope multi-view layout, including multiple industrial cameras, a reflector group and a dynamic light source module. The industrial cameras are distributed on both sides and the top of the inspection station, and the reflector group covers the six inspection surfaces of the cigarette box; Dynamic light source module, including a ring LED light source and a photosensor; The conveying mechanism is a double-belt conveyor driven by a stepper motor, which cooperates with a photoelectric sensor to trigger image acquisition; Image processing module, including: Image preprocessing unit, which performs grayscale normalization, denoising and edge enhancement on the collected images; The defect analysis unit uses template matching, morphological processing, and a multi-level threshold determination mechanism to identify defects such as burnt sales codes, damaged packaging, and torn packaging. Data management module: Parallel to the image processing module, it includes a report generation submodule, a visualization submodule and a data traceability submodule, which are used to automatically generate inspection reports, display test results in real time and encrypt and store data.
2. A cigarette carton outer packaging quality detection and identification system according to claim 1, characterized in that: In the image acquisition module: The reflector assembly is made of optical glass with a refractive index of 1.5 and an anti-reflection coating on the surface. The reflective surface roughness is ≤ Ra0.01 μm. The reflector and the detection surface are at an angle of 45°. The spacing between adjacent cameras is 150 mm ± 5 mm. The installation angle of the industrial camera is 30° ± 2°, and the field of view is 60°. The light intensity adjustment formula of the dynamic light source module is: I out =I base +k·(I env -I threshold ) Among them, I base is the basic brightness, k is the compensation coefficient, I env is the ambient light intensity, I threshold is the threshold, the ambient light intensity I env The data is collected in real time by the light-sensitive sensor.
3. A cigarette carton outer packaging quality detection and identification system according to claim 1, characterized in that: The image preprocessing unit includes: The grayscale normalization subunit uses Gamma correction to perform nonlinear transformation on the image to enhance dark details. The Gamma correction formula is used to perform nonlinear transformation on the image: Among them, I out (x, y) is the pixel value after correction. The pixel with coordinates (x, y) is the result of Gamma correction. in (x, y) is the pixel value before correction, 255: represents the range of pixel values, I in is the input pixel value, Gamma = 0.5 is used to enhance dark details; The denoising subunit combines a bilateral filter to eliminate high-frequency noise while retaining edge information. The noise is eliminated by the bilateral filtering algorithm. The formula is: Among them, the spatial kernel weight Color kernel weights The neighborhood size is 5×5, (x, y) is the current pixel coordinate, (i, j) is the pixel coordinate in the area, σ s is the standard deviation of spatial distance, σ c is the standard deviation of color difference; The edge enhancement subunit sharpens the image through the Laplacian operator. After edge extraction, a morphological opening operation is performed to eliminate isolated noise points. The image is sharpened through the Laplacian operator. The kernel matrix is: The superposition factor is 0.
8.
4. A cigarette carton outer packaging quality detection and identification system according to claim 1, characterized in that: The defect analysis unit includes: The monitoring code burn detection subunit is implemented through the following steps: Region positioning: Based on the preset coordinates, the monitoring and cancellation code area is intercepted, and bilinear interpolation is used to eliminate image distortion. The structural similarity index between the monitoring and cancellation code area coordinates x:120-150, y:80-110 and the standard template is calculated. The formula is: SSIM weighted =0.6·SSIM luminance +0.4·SSIM contrast Among them, the brightness component is: C1=(0.01·255) 2 Contrast component: C2=(0.03·255) 2 Among them, μ X , μ Y is the mean brightness, σ X ,σ Y is the brightness standard deviation, σ XY is the brightness covariance, and the decision threshold is set to 0.85; Template matching: Calculate the structural similarity index between the intercepted area and the standard template, and set the matching threshold to 0.
85. weighted <0.85 triggers an alarm; Among them, SSIM weighted : The weighted structural similarity index is used to comprehensively evaluate the degree of burnt damage in the monitoring and sales code area; SSIM luminance : Luminance component similarity, reflecting the matching degree of image grayscale distribution; SSIM contrast : Contrast component similarity, reflecting the matching degree of local texture of the image; Weight coefficients: 0.6 and 0.4 represent the contribution ratios of brightness and contrast components, respectively, and are determined through experimental optimization; Dynamic update: A dynamic template library is constructed based on historical detection data. A sliding window mechanism is used to match the monitoring and cancellation code area. When the match fails, manual review is triggered. A sliding window mechanism is used to match the monitoring and cancellation code area. When the match fails, the coordinate offset is corrected through an interpolation algorithm. The offset compensation formula is: Δx=α·(x template -x detected ),Δy=β·(y template -y detected ), among which,Δx, Δy is the coordinate compensation amount, α=0.8, β=0.8 is the compensation coefficient, and the coordinate error after correction is ≤±0.5 pixels; x template ,y template is the coordinate of the monitoring code area in the template; detected ,y detected The coordinates of the detected monitoring code area; The package damage detection subunit performs multi-level determination: Level 1 judgment: Extract abnormal contours through Canny edge detection, screen continuous edges with length greater than 5 mm, and calculate edge curvature; Secondary judgment: Use the watershed algorithm to divide the box surface into multiple sub-regions, and count the proportion of white background pixels in each region: Among them, R white The ratio of white background pixels is used to determine packaging damage defects; N white is the number of white background pixels in the detection area; N total is the total number of pixels in the detection area; Threshold: When R white When the percentage is >5%, it is considered as a packaging damage defect; Level 3 judgment: A lightweight CNN model is used to perform semantic segmentation on the suspected area to distinguish between real defects and pattern interference; The tear detection subunit extracts the directional gradient histogram features and inputs them into the SVM classifier to identify the tear texture. When the classification confidence is greater than 0.9, it is judged as a defect.
5. A cigarette carton outer packaging quality detection and identification system according to claim 4, characterized in that: The monitoring code burning detection subunit also includes: The template adaptive optimization module uses an incremental learning algorithm to update the template weights, generating a new template and eliminating the old template after every 1,000 detections; Regional matching fault tolerance mechanism: allows local area matching deviation of ±5%, and uses thin plate spline interpolation to repair the distortion of the monitoring code area caused by the deformation of the strip box.
6. A cigarette carton outer packaging quality detection and identification system according to claim 4, characterized in that: The package damage detection subunit further includes: Adaptive threshold adjustment subunit: Dynamically adjusts the white background pixel threshold based on the cigarette brand template library and uses the U-Net model to perform pixel-level segmentation of the exposed content area. The segmentation is considered valid when the intersection over union (IoU) ratio is greater than 0.
85. Reflection suppression module: A linear polarizer is installed in front of the light source, and the reflection noise of the cellophane is separated by frequency domain analysis. The reflection suppression algorithm eliminates the reflection of the cellophane through frequency domain filtering. The formula is: G(μ,v)=F(u,v)·H(u,v) Among them, G(μ,v) is the result function after frequency domain processing, (μ,v) is the frequency domain coordinate, F(u,v) is the frequency domain function of the image Fourier transform input, and the filter H(u,v) is a Gaussian low-pass filter.
7. A cigarette carton outer packaging quality detection and identification system according to claim 1, characterized in that: The data management module includes: The report generation subunit automatically generates an inspection report containing defect type, location coordinates, and confidence level. The report format is compatible with PDF / Excel and is digitally signed using the RSA-2048 algorithm. The signature formula is: S=M d mod n Where M is the reported hash value (SHA-256), d is the private key exponent, and n is the modulus; The visualization subunit displays the test result heat map, defect distribution statistics and historical data trend map in real time through the human-machine interface. The heat map color mapping formula is: Among them, Score is the comprehensive score of defects; The data tracing subunit uses blockchain technology to encrypt and store detection data. Each record is attached with a timestamp, device ID and hash value. Blockchain technology is used to store data, and each record is encrypted as follows: Block = Hash (PrevHash||Timestamp||Data||Nonce), where Block is the blockchain block, PrevHash is the hash value of the previous block, Timestamp is the timestamp, Data is the detection data, Hash is the SHA-256 algorithm, Nonce is a random number, and the consensus algorithm is PBFT.
8. The cigarette carton outer packaging quality detection and identification system according to claim 1, characterized in that: The system also includes a self-learning optimization module: Defect sample library, which stores historical defect images and manual annotation results, and is classified according to burnt defect codes, damaged packaging, and torn items. The sample capacity is ≥ 100,000 images. The model iteration submodule updates the CNN segmentation model through transfer learning every quarter and optimizes the loss function. The loss function is: in, is the total loss function, λ is the weight coefficient, is the Dice loss, Cross entropy loss, λ=0.6, Update model parameters every quarter; In the false detection feedback submodule, after manual review of the false detection samples, the system automatically adjusts the threshold parameters and updates them to the brand template library, and generates a false detection analysis report.
9. A cigarette carton outer packaging quality detection and identification system according to claim 1, characterized in that: The image processing module adopts a hybrid algorithm architecture: Traditional algorithm layer, which implements template matching, morphological processing and edge detection based on OpenCV; The deep learning layer deploys a lightweight MobileNetV3 model on the FPGA chip and uses the TensorRT acceleration engine for real-time inference. The comprehensive judgment formula of the hybrid architecture is: Score=0.7S 传统 +0.3·S 深度学习 When Score ≥ 0.8, it is judged as a defect, an alarm is triggered and the image is retained.
10. A cigarette carton outer packaging quality detection and identification system according to claim 9, characterized in that: The deep learning layer includes: Data augmentation module, which adds Gaussian noise, random rotation, brightness perturbation and affine transformation to the training images; The knowledge distillation module migrates the feature extraction capabilities of the ResNet50 model to MobileNetV3, retaining the accuracy of key feature recognition through KL divergence loss; Dynamic pruning module, which prunes redundant neural network layers based on FPGA computing power.
Citation Information
Cited By
Wafer box real-time identification method and system based on lightweight neural network
CN121121224A