Digital twinning pre-verification method and system for tobacco package detection configuration
By automating the adjustment of tobacco packaging testing parameters through digital twin pre-verification methods, the problems of production stoppage and quality risks when changing equipment brands have been solved, thereby improving production efficiency and product quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-03
AI Technical Summary
In the tobacco packaging production process, the testing parameters need to be repeatedly adjusted when the equipment changes grades, which leads to frequent production line shutdowns, increased product quality risks, and higher production costs. Existing technology relies on manual experience, resulting in low efficiency.
By employing a digital twin pre-verification method, through the fusion of four-source data, optical simulation, virtual detection, and parameter optimization, the detection window parameters are automatically adjusted, reducing manual intervention.
It improves the accuracy and reliability of the testing configuration, reduces downtime, lowers production costs, and ensures product quality.
Smart Images

Figure CN121789013A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of tobacco production equipment technology, and in particular to a digital twin pre-verification method and system for tobacco packaging inspection configuration. Background Technology
[0002] In the tobacco packaging production process, the appearance quality inspection of cigarette packs is a crucial step in ensuring product qualification. However, when equipment changes to produce a different brand, the inspection parameters need to be repeatedly adjusted. Since these adjustments are made by staff based on experience, they are subject to subjective errors and uncertainties. To achieve optimal inspection parameters (capable of detecting defects without causing false rejections), the average adjustment time for a single type of inspection per unit is at least 30 minutes. Moreover, adjusting while production is underway increases product quality risks and impacts production.
[0003] For the visual inspection device for cigarette packaging, during the process of changing brands, staff frequently need to repeatedly adjust the inspection window and its parameters. The traditional trial-and-error method leads to frequent production line shutdowns, increased product quality risks, and a significant increase in production costs. Summary of the Invention
[0004] The main objective of this application is to provide a digital twin pre-verification method and system for tobacco packaging inspection configuration, in order to solve the problems in the prior art where the visual inspection device for tobacco packaging appearance frequently requires repeated adjustments of the inspection window and its parameters by staff during the process of changing brands, and the traditional trial-and-error method leads to frequent production line shutdowns, increased product quality risks, and significantly increased production costs.
[0005] To achieve the above objectives, this application provides the following technical solution: A digital twin pre-validation method for tobacco packaging inspection configuration, the digital twin pre-validation method comprising: Step S1: Based on real-time equipment configuration data, tobacco pack material optical parameter library, real defect sample library and tobacco-specific rule library, perform four-source data fusion processing to obtain standardized fused data; Step S2: Input the standardized fused data into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration of the aluminum film specular characteristics, simulate the laser material dispersion effect through the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results. Step S3: The optical simulation results are fused with the dynamic detection window parameters. The ROI region of the optical simulation results is focused by the configuration-driven rendering technology, and the real defect samples are processed by the parallel computing architecture to obtain a dynamic rendering image sequence. Step S4: Input the dynamic rendering image sequence into the virtual detection engine, calculate the detection rate and false alarm rate of the dynamic rendering image based on the double precision evaluation model, and perform full defect coverage test through the parallel sample test engine to obtain a quantitative test report. Step S5: Input the quantitative test report into the risk location engine, match the missed defects with the configuration parameter deviation through the defect association algorithm, and locate the coordinate anomaly through the high-risk defect identification component of the risk location engine to obtain the defect association result; Step S6: Input the defect association results into the parameter optimization model, and use the decision tree algorithm to calculate adjustment suggestions for window brightness, contrast and coordinates to obtain structured optimization suggestions for the tobacco packaging inspection configuration.
[0006] Beneficial effects of steps S1 to S6: Step S1 involves the fusion of four data sources, integrating real-time equipment configuration, material optical parameters, real defect samples, and tobacco-specific rules into standardized fused data, providing a unified and standardized data foundation for subsequent simulations. Step S2 utilizes this data to drive an optical simulation engine, accurately simulating the optical properties of the cigarette pack material based on physical rendering technology, generating high-fidelity optical simulation results, and creating a near-realistic visual environment for virtual inspection. Step S3 combines the simulation results with dynamic detection window parameters, using configuration-driven rendering and parallel computing technologies to efficiently generate a dynamic rendering image sequence containing simulated defects, achieving accurate reproduction of the production line inspection scenario. Step S4 inputs the image sequence into the virtual detection engine. The system utilizes a double-precision evaluation model to quantitatively calculate the detection rate and false alarm rate, and completes a full defect coverage evaluation through parallel testing, producing an objective quantitative test report to accurately reflect the performance of the detection configuration. Step S5 performs intelligent analysis on the test report, using a defect association algorithm to locate the root cause of missed detections, identify parameter deviations in the detection window, and establish a causal relationship between defects and configuration, providing a clear direction for parameter optimization. Step S6 finally uses a decision tree algorithm based on the defect association results to generate structured optimization suggestions for window brightness, contrast, and coordinates, thereby completing a closed loop from detection configuration performance evaluation to automatic parameter tuning, effectively improving the accuracy and reliability of the detection configuration and avoiding reliance on human experience.
[0007] As a further improvement to this application, step S1 involves fusing four-source data based on real-time device configuration data, a library of optical parameters for tobacco packaging materials, a library of real defect samples, and a tobacco-specific rule library to obtain standardized fused data, including: Step S11: Extract the number of detection windows, position coordinates, brightness threshold, and contrast parameters of the real-time device configuration data, and convert them into JSON structure data; Step S12: By querying the optical parameter library of cigarette pack materials, the cigarette pack brand in the JSON structure data is mapped to the corresponding material optical attribute set to obtain a standardized material parameter vector; Step S13: Based on the standardized material parameter vector, the defect samples are labeled with optical properties, and the defect feature vector set of each defect sample is extracted by the SIFT algorithm. Step S14: Based on the tobacco-specific rule base, analyze the misjudgment suppression logic of the trademark splicing seam and the box lid seam, and compile the misjudgment suppression logic into an executable data filtering function; Step S15: Spatiotemporal alignment and feature-level fusion are performed on the JSON structure data, the standardized material parameter vector, the defect feature vector set, and the executable data filtering function, and the standardized fused data is generated through a data consistency verification algorithm.
[0008] Beneficial effects of steps S11 to S15: Step S11 extracts and converts real-time device configuration data into JSON structured data, realizing the structuring and standardization of detection window parameters and establishing a unified interface for multi-source data fusion. Step S12 uses a material optical parameter library to map tobacco package brands into standardized material parameter vectors, giving abstract brands specific optical properties and solving the problem of lack of measured data support for material simulation. Step S13 annotates defect samples with optical characteristics based on material parameters and extracts feature vector sets, transforming real defects into calculable features with both morphological and optical properties, providing a high-fidelity defect model for subsequent simulation. Step S14 generates executable data filtering functions by parsing and compiling tobacco-specific rules, transforming industry experience into automatically executable logic modules, effectively pre-setting a misjudgment suppression mechanism for special structures such as splicing seams. Step S15 finally performs spatiotemporal alignment and feature-level fusion on the structured data produced in the above steps, and eliminates data conflicts through consistency verification, generating highly integrated and internally consistent standardized fusion data, providing an accurate, complete, and directly callable data foundation for the optical simulation engine, ensuring the simulation confidence of the digital twin system from the source.
[0009] As a further improvement to this application, in step S2, the standardized fused data is input into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration of the aluminum film specular characteristics, the laser material dispersion effect is simulated through the micro-surface GGX distribution model and anisotropic parameters to obtain optical simulation results, including: Step S21: Initialize the optical simulation environment of the cigarette pack physical rendering optical simulation engine, configure the position, focal length, and lighting conditions of the virtual camera according to the detection environment parameters defined by the JSON structure data, and obtain a standardized virtual detection scene; Step S22: In the standardized virtual detection scenario, the Monte Carlo path tracing algorithm is applied to the aluminum-coated film area based on the standardized material parameter vector in the standardized fusion data, and the high-light reflection intensity is calculated by substituting the dynamic reflection variance parameter to obtain a high-fidelity reflection image of the aluminum-coated film area. Step S23: Call the micro-surface GGX distribution model to set the anisotropy coefficient to the preset tobacco measured value, and simulate the dispersion effect of the laser material region under several viewpoints through spectral rendering to obtain the anisotropic scattering image of the laser material. Step S24: The high-fidelity reflection image and the anisotropic scattering image of the laser material are fused at the pixel level, and texture mapping is performed according to the geometric model of the cigarette pack to obtain the optical simulation result of the cigarette pack.
[0010] Beneficial effects of steps S21 to S24: Step S21 involves parsing the detection environment parameters in the JSON structure data and initializing the virtual camera and lighting conditions to construct a standardized virtual detection scene, providing a controllable and consistent benchmark environment for optical simulation. Step S22 uses a Monte Carlo path tracing algorithm applied to the aluminum-coated film area based on the standardized material parameter vector, and introduces dynamic reflection variance parameters for calculation to generate a high-fidelity reflection image that accurately simulates its high-reflectivity characteristics. Step S23 calls the micro-surface GGX distribution model for the laser material area and sets the anisotropic coefficient. It then uses spectral rendering technology to simulate the dispersion effect under multiple viewing angles, generating anisotropic scattering images that effectively reproduce its complex optical behavior. Step S24 performs pixel-level fusion of the high-fidelity reflection image of the aluminum-coated film area and the anisotropic scattering image of the laser material, and completes texture mapping based on the cigarette pack geometry model. Finally, it outputs a highly realistic overall optical simulation result, providing a reliable image foundation for subsequent virtual detection.
[0011] As a further improvement to this application, step S3 involves fusing the optical simulation results with dynamic detection window parameters, focusing the ROI region of the optical simulation results using configuration-driven rendering technology, and processing real defect samples through a parallel computing architecture to obtain a dynamically rendered image sequence, including: Step S31: Extract the vertex coordinates, spatial dimensions, and priority information of all detection windows from the JSON structure data to obtain the window definition dataset; Step S32: Register the window definition dataset with the optical simulation results in coordinate space, and map the two-dimensional coordinates of each detection window to the actual pixel area of the optical simulation image through an affine transformation matrix to obtain a window image mapping relationship table; Step S33: Perform super-resolution cropping on the optical simulation image region corresponding to each detection window in the window image mapping table using a bilinear interpolation algorithm to obtain local candidate image regions; Step S34: Apply a configuration-driven rendering strategy to the local candidate image regions according to the priority information of the detection window, improve the rendering accuracy of key regions by adaptive sampling rate, and obtain a multi-resolution ROI image set. Step S35: Register and fuse the multi-resolution ROI image set with the defect feature vector in the real defect sample library, and superimpose the defect texture onto the corresponding ROI image using the alpha blending algorithm to obtain a batch of simulated defect candidate sample images. Step S36: Initialize the parallel computing architecture, divide the simulated defect candidate sample image batch into tasks according to the detection window dimension, schedule several computing nodes to execute the rendering pipeline synchronously through a load balancing algorithm, and generate a dynamic rendering image sequence with spatiotemporal information.
[0012] Beneficial effects of steps S31 to S36: Step S31 generates a window definition dataset by extracting the detection window geometry and priority information from the JSON structure data, laying the data foundation for subsequent local rendering; Step S32 registers this dataset with the optical simulation results in coordinate space, and establishes a precise mapping relationship from window to image pixels through affine transformation, achieving spatial alignment between the virtual detection environment and the physical detection station; Step S33 performs super-resolution cropping on the image region corresponding to each detection window based on the mapping relationship, generating high-resolution local candidate image regions to ensure sufficient pixel information density for subsequent analysis; Step S34 applies a configuration-driven rendering strategy based on window priority, and performs adaptive sampling... Step S35 optimizes the balance between rendering accuracy and computational efficiency through sample and resource allocation optimization, producing a multi-resolution ROI image set that balances the quality of critical areas with the efficiency of non-critical areas. Step S36 registers and fuses this image set with real defect features, and seamlessly overlays the defect texture onto the corresponding area using alpha blending technology to generate a simulated sample batch containing realistic defects, providing rich test cases for virtual detection. Step S37 finally initializes the parallel computing architecture, divides the sample batch into tasks and load balances the scheduling according to the window dimension, and efficiently generates a dynamic rendering image sequence containing spatiotemporal information through a multi-node synchronous rendering pipeline, providing large-scale, high-concurrency data support for performance evaluation.
[0013] As a further improvement to this application, in step S4, the dynamically rendered image sequence is input into the virtual detection engine, the detection rate and false alarm rate of the dynamically rendered image are calculated based on the double-precision evaluation model, and a full defect coverage test is performed through a parallel sample testing engine to obtain a quantitative test report, including: Step S41: Match the image frames of the dynamically rendered image sequence with the corresponding detection window configuration information using a timestamp alignment algorithm to obtain a detection sample set; Step S42: Input the detection sample set into the pre-trained deep learning defect detection model, and extract the surface texture, geometric shape and optical anomaly features of the detection sample set through a multi-scale feature pyramid network to obtain a preliminary defect identification result matrix; Step S43: Filter the preliminary defect identification result matrix using tobacco-specific rules, and eliminate false alarm samples by suppressing misjudgments of splicing seams and verifying fine seams in the box lid, to obtain a defect judgment result set; Step S44: Start the parallel sample testing engine, divide the defect judgment result set into several test subsets according to the defect category, and synchronously execute the defect verification process through a multi-core parallel computing architecture to obtain the original test data including the detection status of each sample. Step S45: Calculate the number of defects detected and the number of false alarms for each detection window in the original test data, and substitute them into the detection rate formula and the false alarm rate formula to obtain the performance index set. Step S46: Integrate the performance index set of all detection windows to obtain a quantitative test report including time dimension, spatial dimension, and defect type dimension.
[0014] Beneficial effects of steps S41 to S46: Step S41 uses a timestamp alignment algorithm to match the dynamically rendered image sequence with the detection window configuration information, generating a detection sample set with spatiotemporal annotations, thus establishing a structured data foundation for subsequent defect identification. Step S42 inputs the detection sample set into a pre-trained deep learning model, utilizing a multi-scale feature pyramid network to simultaneously extract surface texture, geometric morphology, and optical anomaly features, forming a preliminary defect identification result matrix, achieving automated extraction and preliminary classification of defect features. Step S43 applies tobacco-specific rule filtering to the preliminary identification results, using a mechanism to suppress false alarms caused by interference factors such as material reflection through splicing seam misjudgment and a box lid seam verification mechanism, thereby improving the accuracy of the identification. To improve the reliability of defect judgment results, step S44 starts the parallel sample test engine, divides the defect judgment result set by category, and executes the verification process synchronously through a multi-core parallel architecture, which greatly improves the efficiency of full defect coverage testing. Step S45 uses statistical methods to calculate the number of defects detected and the number of false alarms for each detection window based on the original test data generated by verification, and converts them into a set of comparable performance indicators through quantitative formulas to objectively reflect the actual performance of the detection configuration. Step S46 finally integrates the performance indicators of all windows and constructs a structured test report from three dimensions: time, space, and defect type, forming a quantitative basis for comprehensively evaluating the performance of the detection configuration.
[0015] As a further improvement to this application, in step S5, the quantitative test report is input into the risk location engine, and the missed defects are matched with the configuration parameter deviations through the defect association algorithm. The high-risk defect identification component of the risk location engine is used to locate coordinate anomalies, and the defect association results are obtained, including: Step S51: Parse the set of performance indicators in the quantitative test report, extract the sample numbers of all missed defects with a detection rate of zero and their corresponding detection window identifiers, and obtain the initial list of missed defects. Step S52: Retrieve the original rendering data of the samples corresponding to the initial list of missed defects in the dynamic rendering image sequence, and restore the morphological features and gray-level distribution characteristics of the missed defects in the image space through the feature deconvolution algorithm to obtain the feature map of the missed defects. Step S53: Calculate the statistical correlation between the defect feature intensity and window brightness threshold and contrast parameters of the missed defect feature map and the detection window parameters in the standardized fusion data using the Pearson correlation coefficient algorithm to obtain the parameter defect correlation matrix; Step S54: Perform cluster analysis on the parameter defect correlation matrix, identify parameter defect combinations with significant correlations using the DBSCAN density clustering algorithm, and locate the set of high-risk parameter configurations that lead to systematic missed detections. Step S55: Correct and register each high-risk parameter configuration set separately, and obtain a parameter deviation analysis result containing specific deviation types and correction amounts based on a high-risk parameter configuration set; Step S56: Integrate all parameter deviation analysis results and sort them in descending order according to the severity level of defects to obtain structured defect association results.
[0016] Beneficial effects of steps S51 to S56: Step S51 involves parsing the performance index set in the quantification test report, extracting all missed defects with zero detection rate and their corresponding window identifiers, generating an initial list of missed defects, and achieving preliminary screening and problem localization of defect data; Step S52 uses this list to retrieve the original data in the dynamically rendered image sequence, applies the feature deconvolution algorithm to restore the morphology and grayscale distribution characteristics of the missed defects in the image space, constructs a quantifiable defect feature map, and transforms the abstract missed detection phenomenon into concrete visual features; Step S53 uses the Pearson correlation coefficient algorithm to calculate the statistical correlation between defect feature intensity and parameters such as window brightness threshold and contrast, generates a parameter-defect correlation matrix, and establishes a mathematical correlation model between defect performance and configuration parameters; Step S54 performs DBSCAN density clustering analysis on the correlation matrix to identify parameter-defect combinations with significant statistical correlation, automatically locating high-risk parameter configuration sets that lead to systematic missed detections, and achieving automated focus on the root cause of the problem; Step S55 performs root cause analysis for each high-risk parameter set, distinguishing between brightness threshold deviation and coordinate offset types through algorithms such as gradient descent and image registration, and quantifying the specific correction amount, completing the transformation from problem identification to correction scheme; Step S56 integrates all parameter deviation analysis results, sorts and classifies them according to the severity level of the defects, and finally outputs structured defect correlation results, providing a clear list of problems, risk levels and correction directions for parameter optimization, forming a conclusive output of closed-loop diagnosis.
[0017] As a further improvement to this application, in step S6, the defect association results are input into the parameter optimization model, and adjustment suggestions for window brightness, contrast, and coordinates are calculated using a decision tree algorithm to obtain structured optimization suggestions for the tobacco packaging inspection configuration, including: Step S61: Analyze the parameter deviation type, risk level, and suggested correction direction in the parameter deviation analysis results, and construct a parameter optimization objective function indexed by the detection window; Step S62: Train a random forest decision tree model based on historical parameter tuning data, input the parameter bias type and risk level into the pre-trained random forest decision tree model, and generate a set of parameter adjustment rules that satisfy the parameter optimization objective function by minimizing the Gini coefficient, thereby obtaining the initial decision tree model; Step S63: The initial decision tree model is trained using Monte Carlo simulation, and an effective parameter adjustment path that can improve the detection rate and reduce the false alarm rate is selected through reverse optimization. Step S64: The defect association result is matched with the most suitable adjustment rule branch of the effective parameter adjustment path by the feature matching algorithm to obtain the structured optimization suggestion of the tobacco packaging detection configuration.
[0018] Beneficial effects of steps S61 to S64: Step S61 analyzes the parameter deviation type and risk level in the defect association results to construct a parameter optimization objective function indexed by the detection window, clarifying constraints such as brightness threshold minimization, contrast optimization range, and coordinate tolerance, thus establishing a mathematical programming foundation for subsequent optimization. Step S62 trains a random forest decision tree model based on historical parameter tuning data, using parameter deviation and risk level as feature inputs. By minimizing the Gini coefficient, it generates a set of parameter adjustment rules for different defect patterns, forming a data-driven initial decision model. Step S63 uses Monte Carlo simulation to enhance the initial model, and through large-scale parameter combination simulation and reverse optimization, it selects effective parameter adjustment paths that can simultaneously improve the detection rate and reduce the false alarm rate, ensuring the feasibility and superiority of the optimization scheme. Step S64 finally uses a feature matching algorithm to adapt the defect association results to the effective paths, locates the optimal adjustment rule branch, and generates structured optimization suggestions containing specific brightness, contrast, and coordinate correction values, completing the closed-loop output from problem diagnosis to parameter self-optimization, providing a precise and reliable automated parameter tuning scheme for detection configuration.
[0019] To achieve the above objectives, this application also provides the following technical solutions: A digital twin pre-verification system for tobacco packaging inspection configuration, the digital twin pre-verification system being applied to the digital twin pre-verification method described above, the digital twin pre-verification system comprising: The standardized fusion data acquisition module is used to perform four-source data fusion processing based on real-time equipment configuration data, tobacco pack material optical parameter library, real defect sample library and tobacco-specific rule library to obtain standardized fusion data. The cigarette pack optical simulation module is used to input the standardized fused data into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration of the characteristics of the aluminum film specular highlights, the laser material dispersion effect is simulated through the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results. The dynamic rendering image sequence calculation module is used to fuse the optical simulation results with the dynamic detection window parameters, focus the ROI region of the optical simulation results through configuration-driven rendering technology, and process real defect samples through a parallel computing architecture to obtain a dynamic rendering image sequence. The quantitative test report acquisition module is used to input the dynamic rendering image sequence into the virtual detection engine, calculate the detection rate and false alarm rate of the dynamic rendering image based on the double precision evaluation model, and perform full defect coverage test through the parallel sample test engine to obtain a quantitative test report. The defect association module is used to input the quantitative test report into the risk location engine, match the missed defects with the configuration parameter deviation through the defect association algorithm, and locate the coordinate anomaly through the high-risk defect identification component of the risk location engine to obtain the defect association result. The structured optimization suggestion acquisition module is used to input the defect association results into the parameter optimization model, calculate the adjustment suggestions for window brightness, contrast and coordinates through the decision tree algorithm, and obtain the structured optimization suggestions for the tobacco packaging inspection configuration.
[0020] To achieve the above objectives, this application also provides the following technical solutions: An electronic device includes a processor and a memory coupled to the processor, the memory storing program instructions executable by the processor; when the processor executes the program instructions stored in the memory, it implements the digital twin pre-verification method as described above.
[0021] To achieve the above objectives, this application also provides the following technical solutions: A computer-readable storage medium storing program instructions that, when executed by a processor, enable the implementation of the digital twin pre-verification method described above. Attached Figure Description
[0022] Figure 1 This is a schematic flowchart illustrating the steps of an embodiment of a digital twin pre-verification method for tobacco packaging inspection configuration according to this application; Figure 2A schematic diagram of functional modules of a digital twin pre-verification system for tobacco packaging inspection configuration according to an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an embodiment of the electronic device of this application; Figure 4 This is a schematic diagram of the structure of one embodiment of the storage medium of this application. Detailed Implementation
[0023] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0024] The terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this application are only used to explain the relative positional relationships and movements between components in a specific orientation (e.g., as shown in the figures). If the specific orientation changes, the directional indications also change accordingly. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.
[0025] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0026] like Figure 1 As shown, this embodiment provides an example of a digital twin pre-verification method for tobacco packaging inspection configuration. In this embodiment, the digital twin pre-verification method includes the following steps: Step S1: Based on real-time equipment configuration data, tobacco pack material optical parameter library, real defect sample library and tobacco-specific rule library, perform four-source data fusion processing to obtain standardized fused data.
[0027] Further, step S1, which involves fusing four sources of data—real-time device configuration data, tobacco pack material optical parameter library, real defect sample library, and tobacco-specific rule library—to obtain standardized fused data, specifically includes the following steps: Step S11: Extract the number of detection windows, location coordinates, brightness threshold, and contrast parameters from the real-time device configuration data, and convert them into JSON structure data.
[0028] Preferably, the configuration data stream of the production line vision inspection equipment can be read in real time via the device communication protocol OPC UA or MQTT interface. This data stream typically includes the number of inspection windows, vertex coordinates in pixels, a brightness threshold with an 8-bit grayscale value range of 0-255, and contrast parameters in floating-point coefficient form.
[0029] Preferably, a JSON Schema validation algorithm can be used to perform syntax and semantic checks on the incoming raw data to ensure the integrity and legality of the data structure. Subsequently, a data normalization converter is called to uniformly transform the coordinates to a normalized coordinate system with the top left corner of the image as the origin, ranging from [0,1], and the brightness threshold is calibrated to an absolute grayscale value (for example, setting the lower limit of the threshold to 45 and the upper limit to 220), finally outputting JSON structured data that conforms to the internal processing specifications.
[0030] Step S12: By querying the optical parameter library of cigarette pack materials, the cigarette pack brand in the JSON structure data is mapped to the corresponding material optical attribute set to obtain a standardized material parameter vector.
[0031] Preferably, when the JSON structured data contains brand information, a parameterized SQL query is executed (e.g., SELECT reflectance, anisotropy FROM material_library WHERE brand = ?). The query result is a standardized material parameter vector, which contains key parameters: for example, the base reflectance of the aluminized film (measured value 0.87, dimensionless) and the reflectance variance (used for dynamic range calibration, such as 0.05); and the anisotropy coefficient required for the micro-surface GGX distribution model of the laser paper (typical measured value in the tobacco industry is 0.35).
[0032] Step S13: Based on the standardized material parameter vector, the optical characteristics of the defect samples are annotated, and the defect feature vector set of each defect sample is extracted by the SIFT algorithm.
[0033] Preferably, step S13 first annotates the defect region with optical properties based on the standardized material parameter vector obtained in step S12, for example, specifying its reflection property category according to the material. Then, a scale-invariant feature transform algorithm is applied to extract features from the defect image.
[0034] Preferably, the specific calculation process of the SIFT algorithm includes constructing a Gaussian difference pyramid for key point detection; and generating a 128-dimensional feature descriptor using the gradient direction distribution of the pixels in the neighborhood of the key point.
[0035] Ultimately, each defect sample is represented as a set of 128-dimensional SIFT feature vectors, which simultaneously encodes the defect's shape, texture, and interaction with the material, i.e., the defect feature vector set.
[0036] Step S14: Based on the tobacco-specific rule base, analyze the misjudgment suppression logic of the trademark splicing seam and the box lid seam, and compile the misjudgment suppression logic into an executable data filtering function.
[0037] Preferably, a tobacco-specific rule base (usually an XML or YAML configuration file) can be loaded and the rules can be parsed using a rule parsing and compilation engine (which can be based on the ANTLR parser).
[0038] For example, regarding the "trademark seam misjudgment suppression" rule, the engine compiles it into an executable data filtering function. At the code level, this might be represented by a conditional function with the following internal logic: `if (isWithinSpliceRegion(featureCoordinates) && featureIntensity < threshold) { filterOut();}`. This function can be directly applied to the feature data in subsequent processes to achieve rule-based intelligent filtering.
[0039] Step S15 involves performing spatiotemporal alignment and feature-level fusion on the JSON structure data, standardized material parameter vectors, defect feature vector sets, and executable data filtering functions, and generating standardized fused data through a data consistency verification algorithm.
[0040] Preferably, the aforementioned data can first be spatiotemporally aligned using timestamps and spatial transformation matrices to ensure that the JSON structure data, material parameter vectors, and defect feature vector sets are consistent in time and space. Subsequently, feature-level fusion is performed, concatenating feature vectors from different sources into a high-dimensional unified feature vector. Finally, a data consistency verification algorithm is executed; for example, calculating the confidence level of different data sources for the same entity description. If the confidence level is lower than a preset threshold (e.g., 0.95), an alarm is triggered or a preset strategy (e.g., weighted averaging) is used to resolve conflicts. The final standardized fused data is typically output in a specific binary format (e.g., HDF5) to ensure its integrity and the efficiency of subsequent processing.
[0041] Beneficial effects of steps S11 to S15: Step S11 extracts and converts real-time device configuration data into JSON structured data, realizing the structuring and standardization of detection window parameters and establishing a unified interface for multi-source data fusion. Step S12 uses a material optical parameter library to map tobacco package brands into standardized material parameter vectors, giving abstract brands specific optical properties and solving the problem of lack of measured data support for material simulation. Step S13 annotates defect samples with optical characteristics based on material parameters and extracts feature vector sets, transforming real defects into calculable features with both morphological and optical properties, providing a high-fidelity defect model for subsequent simulation. Step S14 generates executable data filtering functions by parsing and compiling tobacco-specific rules, transforming industry experience into automatically executable logic modules, effectively pre-setting a misjudgment suppression mechanism for special structures such as splicing seams. Step S15 finally performs spatiotemporal alignment and feature-level fusion on the structured data produced in the above steps, and eliminates data conflicts through consistency verification, generating highly integrated and internally consistent standardized fusion data, providing an accurate, complete, and directly callable data foundation for the optical simulation engine, ensuring the simulation confidence of the digital twin system from the source.
[0042] Step S2: Input the standardized fused data into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration, the characteristics of the aluminum film specular highlight are simulated by the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results.
[0043] Further, in step S2, the standardized fused data is input into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration, the characteristics of the aluminum film specular highlight are used to simulate the laser material dispersion effect through the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results. The specific steps include the following: Step S21: Initialize the optical simulation environment of the cigarette pack physical rendering optical simulation engine, configure the position, focal length, and lighting conditions of the virtual camera according to the detection environment parameters defined by the JSON structure data, and obtain a standardized virtual detection scene.
[0044] Preferably, step S21 aims to create a virtual scene that matches the geometric and optical properties of the real detection environment. The system reads the detection environment parameters defined in the JSON structure data. These parameters include the spatial pose of the virtual camera relative to the cigarette pack model, defined by a 4x4 view-projection matrix, focal length (e.g., 35mm equivalent focal length), aperture value, and scene lighting parameters (e.g., light source type, intensity, color temperature, and position).
[0045] Preferably, in the simulation phase, the initialization process is based on a scene graph model from computer graphics. The virtual camera model uses a pinhole camera model, and its intrinsic and extrinsic parameters are set by JSON data. The lighting model uses a physically based rendering framework, typically containing one or more regional light sources, whose radiant intensity is calibrated according to the lighting conditions of the real production line (e.g., setting the main light source intensity to 1500 lumens and the color temperature to 6500K). The 3D model of the cigarette pack is placed in this virtual environment through coordinate transformation matrices (including model transformation, view transformation, and projection transformation), ultimately generating a standardized virtual inspection scene containing accurate camera, lighting, and geometric information. This scene serves as the basic coordinate system and lighting environment for all subsequent optical calculations.
[0046] Step S22: In the standardized virtual inspection scenario, the Monte Carlo path tracing algorithm is applied to the aluminum-coated film area based on the standardized material parameter vector in the standardized fusion data, and the high-light reflection intensity is calculated by substituting the dynamic reflection variance parameter to obtain a high-fidelity reflection image of the aluminum-coated film area.
[0047] Preferably, for the rendering of each pixel on the surface of the aluminum-coated film, the Monte Carlo path tracing algorithm is used to solve the problem. The core of the algorithm is the bidirectional reflection distribution function. In this embodiment, the Cook-Torrance BRDF model is used to describe the specular reflection. This model contains three key terms: normal distribution function, geometric function and Fresnel equation.
[0048] The normal distribution function uses the GGX model, whose roughness parameter is dynamically controlled by the reflection variance (e.g., 0.05) in the normalized material parameter vector. The larger the variance, the more diffuse the simulated specular spot. During calculation, a large number of rays are emitted from the camera, with the sampling rate set to 1024 times / pixel. Sampling is performed at the intersection of the rays and the object according to the BRDF model to estimate the radiance of the light reflected to the camera at that point. This allows for accurate simulation of the specular highlights and glossiness caused by micro-surface scattering on the aluminum-coated film surface, generating a physically accurate high-fidelity reflection image.
[0049] Step S23: Call the micro-surface GGX distribution model to set the anisotropy coefficient to the preset tobacco measured value, and simulate the dispersion effect of the laser material region under several viewpoints through spectral rendering to obtain the anisotropic scattering image of the laser material.
[0050] Preferably, step S23 continues to use a physically based rendering framework, but its BRDF model needs to support anisotropy. The normal distribution function adopts an anisotropic GGX distribution model, which requires two roughness parameters (along the tangent direction and the subtangent direction). In this embodiment, the anisotropy coefficient can be set to the measured value of tobacco, 0.35. To achieve the dispersion effect, spectral rendering technology is used instead of standard RGB rendering. This means that the rendering calculation is not performed in the RGB color space, but in a finer-grained wavelength dimension. Specifically, the visible light spectrum (e.g., 380nm to 780nm) is discretized into multiple bands (e.g., one band every 10nm), path tracing lighting calculations are performed independently for each band, and finally the spectral energy of all bands is synthesized into RGB colors, thereby accurately reproducing the rainbow-like dispersion effect produced by light diffraction of the laser material, and finally outputting an anisotropic scattering image of the laser material.
[0051] Step S24: Pixel-level fusion of the high-fidelity reflection image and the anisotropic scattering image of the laser material is performed, and texture mapping is performed based on the geometric model of the cigarette pack to obtain the optical simulation results of the cigarette pack.
[0052] Preferably, step S24 first performs pixel-level image fusion, which is a physically based linear illumination space mixing. Based on the material ID map of the cigarette pack geometric model, which identifies the material texture of each pixel, the high-fidelity reflection image of the corresponding aluminum-coated film area generated in step S22 and the anisotropic scattering image of the corresponding laser material area generated in step S23 are merged in HDR high dynamic range linear space. Then, texture mapping is performed, applying diffuse reflection textures such as trademarks and patterns from the cigarette pack surface to the model surface, and superimposing them with specular reflection and scattering components according to the principle of energy conservation. Finally, to eliminate aliasing, a 4x oversampling anti-aliasing technique is applied, performing multiple samplings (sub-sampling) within a single pixel, and then averaging the sampling results to generate a final optical simulation result with smooth edges and rich details. The beneficial effects of steps S21 to S24 are: Step S21 involves parsing the detection environment parameters in the JSON structure data and initializing the virtual camera and lighting conditions to construct a standardized virtual detection scene, providing a controllable and consistent benchmark environment for optical simulation. Step S22 uses a Monte Carlo path tracing algorithm applied to the aluminum-coated film area based on the standardized material parameter vector, and introduces dynamic reflection variance parameters for calculation to generate a high-fidelity reflection image that accurately simulates its high-reflectivity characteristics. Step S23 calls the micro-surface GGX distribution model for the laser material area and sets the anisotropic coefficient. It then uses spectral rendering technology to simulate the dispersion effect under multiple viewing angles, generating anisotropic scattering images that effectively reproduce its complex optical behavior. Step S24 performs pixel-level fusion of the high-fidelity reflection image of the aluminum-coated film area and the anisotropic scattering image of the laser material, and completes texture mapping based on the cigarette pack geometry model. Finally, it outputs a highly realistic overall optical simulation result, providing a reliable image foundation for subsequent virtual detection.
[0053] Step S3: The optical simulation results are fused with the dynamic detection window parameters. The ROI region of the optical simulation results is focused by the configuration-driven rendering technology, and the real defect samples are processed by the parallel computing architecture to obtain a dynamic rendering image sequence.
[0054] Further, step S3, which involves fusing the optical simulation results with the dynamic detection window parameters, focusing the ROI region of the optical simulation results through configuration-driven rendering technology, and processing real defect samples through a parallel computing architecture to obtain a dynamic rendering image sequence, specifically includes the following steps: Step S31: Extract the vertex coordinates, spatial dimensions, and priority information of all detection windows from the JSON structure data to obtain the window definition dataset.
[0055] Preferably, step S31 aims to locate the inspection_windows array node by parsing the JSON tree structure and traverse each window object within it. Each window object contains key fields: vertices (an array of vertex coordinates, such as [[x1,y1], [x2,y2], [x3,y3], [x4,y4]], in normalized coordinates or pixel coordinates), spatial_size (window width and height information), and priority_level (priority identifier, usually an enumerated value such as HIGH=3, MEDIUM=2, LOW=1).
[0056] Preferably, the extraction algorithm uses the JSONPath query language, for example, using the expression $.inspection_windows[*] to efficiently obtain all window data; then, this data is encapsulated into a structured window definition dataset, which is generally a list or array, with each element being a complete definition of a detection window.
[0057] Step S32: Register the window definition dataset with the optical simulation results in coordinate space. Map the two-dimensional coordinates of each detection window to the actual pixel area of the optical simulation image through an affine transformation matrix to obtain a window image mapping table.
[0058] Preferably, the core of step S32 is to calculate an affine transformation matrix. This affine transformation matrix is typically a 3x3 matrix that describes rotation, scaling, translation, and shearing transformations. Calculating this matrix requires at least three pairs of matching feature points, usually utilizing the vertices of the detection window and known marker points in the image. The transformation matrix H is solved using a direct linear transformation algorithm or the least squares method, such that for a window vertex p, p' = Hp, where p' is the corresponding pixel coordinate in the image. Finally, a window-image mapping table is generated, which stores the mapping relationship between each window ID and its corresponding image pixel region (usually represented as a bounding box, such as [min_x, min_y, max_x, max_y]).
[0059] Step S33: Perform super-resolution cropping on the optical simulation image region corresponding to each detection window in the window image mapping table using a bilinear interpolation algorithm to obtain local candidate image regions.
[0060] Preferably, a bilinear interpolation algorithm can be used for image cropping and scaling. For non-integer pixel coordinates within the bounding box of each detection window, the gray value is calculated by a weighted average of the gray values of the four nearest neighbor pixels. This method maintains good image quality and generates a set of clear local candidate image regions, even when small scaling is required.
[0061] Step S34: Apply a configuration-driven rendering strategy to the local candidate image regions based on the priority information of the detection window, improve the rendering accuracy of key regions by adaptive sampling rate, and obtain a multi-resolution ROI image set.
[0062] Preferably, to implement the configuration-driven rendering strategy, windows with a priority of HIGH are rendered using a high sampling rate (e.g., 1024 samples per pixel) to ensure optimal image quality. Windows with a priority of LOW are rendered using a low sampling rate (e.g., 64 samples per pixel). This is combined with a multi-resolution image pyramid technique (generating images of different scales through Gaussian blur and downsampling) for fast rendering at low resolution. An adaptive resource scheduler manages this process, ultimately outputting a multi-resolution ROI image set containing images at different resolutions, significantly improving overall processing speed while maintaining the quality of key regions.
[0063] Step S35: Register and fuse the multi-resolution ROI image set with the defect feature vectors in the real defect sample library, and superimpose the defect texture onto the corresponding ROI image using the alpha blending algorithm to obtain a batch of simulated defect candidate sample images.
[0064] Preferably, image fusion is performed using an Alpha fusion algorithm to synthesize the defective image (as the foreground) and the ROI image (as the background).
[0065] The formula is: Output = (alpha * Foreground) + ((1 - alpha) * Background).
[0066] Here, alpha is the transparency channel, typically derived from a mask of the defect image, with a value between 0 and 1, used to control the degree to which the defect blends with the background. By ensuring that the defect is in the correct position through registration and alpha blending, a batch of candidate sample images containing simulated defects can be generated, producing a visually realistic effect.
[0067] Step S36: Initialize the parallel computing architecture, divide the simulated defect candidate sample image batch into tasks according to the detection window dimension, schedule several computing nodes to execute the rendering pipeline synchronously through a load balancing algorithm, and generate a dynamic rendering image sequence with spatiotemporal information.
[0068] Preferably, a master-slave parallel computing architecture is initialized (e.g., using MPI or Apache Spark frameworks). The master node hashes and shards batches of simulated defect candidate sample images according to the detection window ID or defect type, dividing the task into multiple subtasks; the compute nodes read the allocated image data from shared storage and independently execute the complete rendering pipeline. A work-stealing load balancing algorithm dynamically adjusts task allocation to ensure even workload distribution across all compute nodes; after each node completes its processing, it outputs image frames with timestamps and metadata such as window ID and defect type. Finally, the master node aggregates these images in chronological order to generate the final dynamically rendered image sequence, such as a video stream or a list of image frames.
[0069] Beneficial effects of steps S31 to S36: Step S31 generates a window definition dataset by extracting the detection window geometry and priority information from the JSON structure data, laying the data foundation for subsequent local rendering; Step S32 registers this dataset with the optical simulation results in coordinate space, and establishes a precise mapping relationship from window to image pixels through affine transformation, achieving spatial alignment between the virtual detection environment and the physical detection station; Step S33 performs super-resolution cropping on the image region corresponding to each detection window based on the mapping relationship, generating high-resolution local candidate image regions to ensure sufficient pixel information density for subsequent analysis; Step S34 applies a configuration-driven rendering strategy based on window priority, and performs adaptive sampling... Step S35 optimizes the balance between rendering accuracy and computational efficiency through sample and resource allocation optimization, producing a multi-resolution ROI image set that balances the quality of critical areas with the efficiency of non-critical areas. Step S36 registers and fuses this image set with real defect features, and seamlessly overlays the defect texture onto the corresponding area using alpha blending technology to generate a simulated sample batch containing realistic defects, providing rich test cases for virtual detection. Step S37 finally initializes the parallel computing architecture, divides the sample batch into tasks and load balances the scheduling according to the window dimension, and efficiently generates a dynamic rendering image sequence containing spatiotemporal information through a multi-node synchronous rendering pipeline, providing large-scale, high-concurrency data support for performance evaluation.
[0070] Step S4: Input the dynamically rendered image sequence into the virtual detection engine, calculate the detection rate and false alarm rate of the dynamically rendered image based on the double-precision evaluation model, and perform full defect coverage testing through the parallel sample testing engine to obtain a quantitative test report.
[0071] Further, in step S4, the dynamically rendered image sequence is input into the virtual detection engine. Based on the double-precision evaluation model, the detection rate and false alarm rate of the dynamically rendered image are calculated. Then, a full defect coverage test is performed through the parallel sample testing engine, and a quantitative test report is obtained. The specific steps include the following: Step S41: Match the image frames of the dynamically rendered image sequence with the corresponding detection window configuration information using a timestamp alignment algorithm to obtain a detection sample set.
[0072] Preferably, step S41 aims to assign accurate contextual information to each frame of the sequence, making it a detection sample that can be independently identified and traced. The system reads the dynamically rendered image sequence (typically a video stream or a list of image frames) and the associated detection window configuration information.
[0073] Specifically, a timestamp alignment algorithm can be used for processing. First, the system extracts a timestamp t_frame accurate to the millisecond level from image metadata (such as EXIF information) or sequence index; simultaneously, it obtains the window configuration snapshot C_config at the corresponding time point from the configuration log; through linear interpolation or dynamic time warping algorithms, it matches the best-fitting configuration C_config for each timestamp t_frame to solve the potential micro-time drift problem; after successful matching, the image frame, timestamp t_frame, and window configuration C_config are bound together to generate a structured detection sample set with spatiotemporal annotations, and each sample can be uniquely identified and traced through timestamp and window ID.
[0074] Step S42: Input the detection sample set into the pre-trained deep learning defect detection model, and extract the surface texture, geometric shape and optical anomaly features of the detection sample set through a multi-scale feature pyramid network to obtain a preliminary defect identification result matrix.
[0075] Preferably, the detection sample set can be input into a pre-trained deep learning defect detection model. This deep learning defect detection model typically employs an architecture based on Faster R-CNN, YOLO, or SSD, and integrates a multi-scale feature pyramid network. The FPN, through its top-down and laterally connected structure, can efficiently extract and fuse features from different levels of the backbone network (e.g., ResNet-50 / 101), thereby simultaneously capturing the sample's surface texture (shallow features), geometric shape (mid-level features), and optical anomalies (deep features). The model classifies each candidate region (e.g., "damaged trademark," "crooked seal," "normal") and performs bounding box regression, outputting a preliminary defect identification result matrix. Each row of this matrix represents an identified defect instance, containing information such as its category confidence and bounding box coordinates.
[0076] Step S43: Filter the preliminary defect identification result matrix using tobacco-specific rules, and eliminate false alarm samples by suppressing misjudgments of splicing seams and verifying fine seams in the box lid, thus obtaining the defect judgment result set.
[0077] Preferably, the preliminary defect identification result matrix can be input into the tobacco-specific rule filtering component. This component can load the executable data filtering function compiled in step S14. For example, the data filtering function for "suppression of splicing seam misjudgment" calculates the structural similarity index (SSIM) between the suspected defect area and the preset splicing seam template. If the SSIM value is higher than the threshold (e.g., 0.8), it is judged as a misjudgment and filtered. For "logic verification of box lid seam", the function uses morphological operations (e.g., opening operation) and geometric relationship judgment (e.g., seam aspect ratio) to confirm whether it conforms to normal process characteristics. By executing the above rules, false alarm samples are effectively eliminated, and a more reliable defect judgment result set optimized by the rules is generated.
[0078] Step S44: Start the parallel sample testing engine, divide the defect judgment result set into several test subsets according to the defect category, and synchronously execute the defect verification process through a multi-core parallel computing architecture to obtain the original test data including the detection status of each sample.
[0079] Preferably, the parallel sample testing engine can be based on distributed computing frameworks such as Spark or Dask. This parallel sample testing engine first hash-partitions the rule-optimized defect judgment result set according to defect category (Class), for example, allocating all "trademark damage" defect samples to one computing partition; then, through a multi-core parallel computing architecture, the defect verification process is executed synchronously on each computing node: the model recognition results are compared with pre-injected ground truth labels in the image sequence. The engine employs a work-stealing load balancing algorithm to dynamically allocate tasks, ensuring balanced load across all CPU cores, and ultimately quickly producing raw test data containing the final detection status (true positive, false positive, true negative, false negative) for each sample.
[0080] Step S45: Calculate the number of defects detected and the number of false alarms for each detection window in the original test data, and substitute them into the detection rate formula and the false alarm rate formula to obtain the performance index set.
[0081] Preferably, step S45 can use a double-precision evaluation model to calculate the detection rate separately. The detection rate formula is: TP / (TP+FN), where TP (true positive) is the number of correctly detected defects, and FN (false negative) is the number of missed defects; the false alarm rate formula is: FP / (FP+TN), where FP (false positive) is the number of false alarms, and TN (true negative) is the number of correctly judged normal samples. The above indicators can also be calculated independently for each detection window, and a 95% confidence interval can be calculated, ultimately forming a set of window-level performance indicators that includes point estimation and interval estimation.
[0082] Step S46: Integrate the performance index set of all detection windows to obtain a quantitative test report including time dimension, spatial dimension, and defect type dimension.
[0083] Preferably, the report can be presented from three dimensions: Time dimension: Shows the trend of performance indicators over time or production batches.
[0084] Spatial dimension: Display the performance distribution at different physical locations (i.e., different detection windows) in the form of heat maps, etc.
[0085] Defect type dimension: Statistical analysis of the detection and false alarm of various defects.
[0086] Finally, all analysis results, indicator data, and trend charts are integrated into a structured document (such as JSON, XML, or PDF format) to generate the final quantitative test report.
[0087] Beneficial effects of steps S41 to S46: Step S41 uses a timestamp alignment algorithm to match the dynamically rendered image sequence with the detection window configuration information, generating a detection sample set with spatiotemporal annotations, thus establishing a structured data foundation for subsequent defect identification. Step S42 inputs the detection sample set into a pre-trained deep learning model, utilizing a multi-scale feature pyramid network to simultaneously extract surface texture, geometric morphology, and optical anomaly features, forming a preliminary defect identification result matrix, achieving automated extraction and preliminary classification of defect features. Step S43 applies tobacco-specific rule filtering to the preliminary identification results, using a mechanism to suppress false alarms caused by interference factors such as material reflection through splicing seam misjudgment and a box lid seam verification mechanism, thereby improving the accuracy of the identification. To improve the reliability of defect judgment results, step S44 starts the parallel sample test engine, divides the defect judgment result set by category, and executes the verification process synchronously through a multi-core parallel architecture, which greatly improves the efficiency of full defect coverage testing. Step S45 uses statistical methods to calculate the number of defects detected and the number of false alarms for each detection window based on the original test data generated by verification, and converts them into a set of comparable performance indicators through quantitative formulas to objectively reflect the actual performance of the detection configuration. Step S46 finally integrates the performance indicators of all windows and constructs a structured test report from three dimensions: time, space, and defect type, forming a quantitative basis for comprehensively evaluating the performance of the detection configuration.
[0088] Step S5: Input the quantitative test report into the risk location engine, match the missed defects with the configuration parameter deviation through the defect association algorithm, and locate the coordinate anomaly through the high-risk defect identification component of the risk location engine to obtain the defect association result.
[0089] Further, in step S5, the quantitative test report is input into the risk location engine. The defect correlation algorithm matches the missed defects with the configuration parameter deviations, and the high-risk defect identification component of the risk location engine locates the coordinate anomalies to obtain the defect correlation results. The specific steps include the following: Step S51: Analyze the set of performance indicators in the quantitative test report, extract the sample numbers of all missed defects with a detection rate of zero and their corresponding detection window identifiers, and obtain the initial list of missed defects.
[0090] Preferably, data filtering queries can be performed using the SELECT statement in SQL, with the filtering condition being a detection rate of 0. This means that for a specific detection window and a specific defect type, if all injected samples of this type of defect under that window are not identified, it is determined to be a systematic missed detection; and the unique sample number of these missed defects (as a traceability identifier) and its corresponding detection window identifier are extracted and organized into a structured list table, i.e., the initial list of missed defects.
[0091] Step S52: Retrieve the original rendering data of the samples corresponding to the initial list of missed defects in the dynamic rendering image sequence, and restore the morphological features and gray-scale distribution characteristics of the missed defects in the image space through the feature deconvolution algorithm to obtain the feature map of the missed defects.
[0092] Preferably, the corresponding original high-resolution image is retrieved from the underlying storage of the dynamically rendered image sequence based on the sample number. Then, analysis is performed using a feature deconvolution algorithm. This algorithm first locates the area where the defect should appear, and then calculates the contribution of each pixel to the model's recognition of the area as "normal" through guided backpropagation. Areas with low contribution are identified as key feature regions causing inaccurate model judgments. Simultaneously, the algorithm extracts the morphological features (e.g., area, perimeter, Hu moment) and grayscale distribution characteristics (e.g., mean, variance, gradient histogram) of this region. All these feature values are combined into a high-dimensional vector, forming a missed defect feature map. This map quantitatively describes the pattern of defect feature combinations that cannot be detected under the current configuration.
[0093] Step S53: Calculate the statistical correlation between the defect feature intensity and the window brightness threshold and contrast parameters in the missed defect feature map and the standardized fusion data using the Pearson correlation coefficient algorithm to obtain the parameter defect correlation matrix.
[0094] Preferably, the Pearson correlation coefficient can be used as a measure of correlation. The correlation between each feature dimension (e.g., defect contrast) in the missed defect feature map and each parameter dimension (e.g., brightness threshold) of the corresponding detection window in the standardized fused data is calculated. The formula for calculating the Pearson correlation coefficient r is: .
[0095] Here, X is the value sequence of a certain defect feature across all missed samples, and Y is a parameter value corresponding to the detection window. If multiple samples correspond to the same window, the parameter value is repeated. After calculation, a matrix M is obtained, where the element M[i][j] represents the correlation coefficient between the i-th defect feature and the j-th detection parameter, with a value range of [-1, 1]. This parameter-defect correlation matrix reveals the sensitivity of different parameters to different defect features.
[0096] Step S54: Perform cluster analysis on the parameter defect correlation matrix, identify parameter defect combinations with significant correlation using the DBSCAN density clustering algorithm, and locate the set of high-risk parameter configurations that lead to systematic missed detections.
[0097] Preferably, DBSCAN density clustering can be performed on the parameter-defect correlation matrix. DBSCAN density clustering is a density-based spatial clustering algorithm suitable for discovering clusters of arbitrary shapes and identifying noise points. In this embodiment, each row of the parameter-defect correlation matrix (representing a detection parameter) can be equivalently represented as a point in a high-dimensional space, where the coordinates of the point are the correlation coefficient between that parameter and all defect features.
[0098] Preferably, the DBSCAN algorithm requires setting two key parameters: the neighborhood radius eps (e.g., set to 0.7, representing a strong correlation threshold) and the minimum number of points min_samples (e.g., set to 3, indicating that a parameter must be strongly correlated with at least 3 defect features to be considered a core point). After the algorithm runs, it can identify densely distributed points in the feature space. The parameters corresponding to these densely distributed points are the set of high-risk parameter configurations that are highly correlated with multiple missed defects.
[0099] Step S55: Correct and register each high-risk parameter configuration set separately, and obtain a parameter deviation analysis result containing specific deviation types and correction amounts based on a high-risk parameter configuration set.
[0100] Preferably, gradient descent can be used for brightness / contrast threshold deviations. Using the confidence level of missed detection defects as the objective function and the threshold parameter as the variable, the gradient (partial derivative) of the objective function with respect to the parameter is calculated iteratively, and the parameter is updated in the opposite direction of the gradient (i.e., the direction of reducing the missed detection rate) until convergence, thus obtaining the suggested threshold adjustment amount.
[0101] Preferably, image registration techniques can be used to address the deviation in the detection window coordinates / coverage, specifically scale-invariant feature transformation feature point matching. Feature points are matched between the template image at the ideal window position and the image at the current deviation window. Then, a random sampling consensus algorithm is used to estimate the affine transformation matrix that aligns most feature points. This matrix implicitly contains the required coordinate translation and rotation corrections.
[0102] Preferably, after performing the above analysis on each high-risk parameter set, a parameter deviation analysis report is generated, which clearly records the deviation type (e.g., "the brightness threshold of window 10 is too high") and the quantified correction suggestions (e.g., "the brightness threshold is recommended to be reduced by 15%).
[0103] Step S56: Integrate all parameter deviation analysis results and sort them in descending order according to the severity level of defects to obtain structured defect association results.
[0104] Preferably, all independent parameter deviation analysis reports are then summarized. First, a risk level scoring model is defined based on the potential severity of the defects (e.g., "missing trademark" is high-risk, "minor scratch" is low-risk), and each analysis result is assigned a risk level (high-risk, medium-risk, low-risk); then, they are sorted in descending order of risk level; finally, a structured defect association result is output, which is usually a JSON or XML file that clearly lists each missed problem, its root parameter cause, risk level, and specific correction suggestions, providing direct and accurate input for the automated parameter optimization in step S6.
[0105] Beneficial effects of steps S51 to S56: Step S51 involves parsing the performance index set in the quantification test report, extracting all missed defects with zero detection rate and their corresponding window identifiers, generating an initial list of missed defects, and achieving preliminary screening and problem localization of defect data; Step S52 uses this list to retrieve the original data in the dynamically rendered image sequence, applies the feature deconvolution algorithm to restore the morphology and grayscale distribution characteristics of the missed defects in the image space, constructs a quantifiable defect feature map, and transforms the abstract missed detection phenomenon into concrete visual features; Step S53 uses the Pearson correlation coefficient algorithm to calculate the statistical correlation between defect feature intensity and parameters such as window brightness threshold and contrast, generates a parameter-defect correlation matrix, and establishes a mathematical correlation model between defect performance and configuration parameters; Step S54 performs DBSCAN density clustering analysis on the correlation matrix to identify parameter-defect combinations with significant statistical correlation, automatically locating high-risk parameter configuration sets that lead to systematic missed detections, and achieving automated focus on the root cause of the problem; Step S55 performs root cause analysis for each high-risk parameter set, distinguishing between brightness threshold deviation and coordinate offset types through algorithms such as gradient descent and image registration, and quantifying the specific correction amount, completing the transformation from problem identification to correction scheme; Step S56 integrates all parameter deviation analysis results, sorts and classifies them according to the severity level of the defects, and finally outputs structured defect correlation results, providing a clear list of problems, risk levels and correction directions for parameter optimization, forming a conclusive output of closed-loop diagnosis.
[0106] Step S6: Input the defect association results into the parameter optimization model, and use the decision tree algorithm to calculate adjustment suggestions for window brightness, contrast and coordinates to obtain structured optimization suggestions for tobacco packaging inspection configuration.
[0107] Further, in step S6, the defect association results are input into the parameter optimization model, and the decision tree algorithm is used to calculate adjustment suggestions for window brightness, contrast, and coordinates to obtain structured optimization suggestions for the tobacco packaging inspection configuration. Specifically, this includes the following steps: Step S61: Analyze the parameter deviation type, risk level, and suggested correction direction in the parameter deviation analysis results, and construct a parameter optimization objective function indexed by the detection window.
[0108] Preferably, step S61 aims to transform the fuzzy optimization requirements into precise mathematical problems. By analyzing the defect correlation results, the parameter deviation type (e.g., excessively high brightness threshold), risk level (e.g., high risk), and suggested correction direction (e.g., reduction) for each problem are extracted.
[0109] Preferably, an independent multi-objective constrained optimization objective function can be constructed for each detection window. This function needs to optimize multiple competing metrics simultaneously. For example, minimizing a weighted sum function: Minimize:F(θ)=w1*(1-Recall(θ))+w2*FPR(θ)+w3*|θ-θ_current|.
[0110] Here, θ represents the parameter vector to be optimized (e.g., brightness threshold, contrast, coordinate offset), Recall(θ) and FPR(θ) are the detection rate and false alarm rate based on virtual simulation prediction, w1, w2, and w3 are weighting coefficients set according to the risk level (e.g., to prioritize the detection rate of high-risk defects, w1 is set to be much larger than w2), and |θ - θ_current| is a regularization term to prevent excessively drastic parameter adjustments. Additionally, the function includes constraints, such as the brightness threshold must be within the physical limitations of the device (e.g., 0 ≤ θ_brightness ≤ 255), and coordinate adjustments must not exceed the image boundaries.
[0111] Step S62: Train a random forest decision tree model based on historical parameter tuning data, input the parameter bias type and risk level into the pre-trained random forest decision tree model, and generate a set of parameter adjustment rules that satisfy the parameter optimization objective function by minimizing the Gini coefficient, thus obtaining the initial decision tree model.
[0112] Preferably, the model can be constructed using the random forest algorithm. The model is characterized by parameter bias type (one-hot encoding) and risk level (numerical or ordinal encoding). Training data comes from historical parameter tuning data, where each record contains the parameters before adjustment, the adjustment action (i.e., features), and the measured detection rate and false alarm rate after adjustment (i.e., labels). During training, each decision tree uses minimizing the Gini coefficient as the criterion for node splitting. The Gini coefficient is calculated as Gini(p) = 1 - Σ(p_i)^2, where p_i is the proportion of samples in a node belonging to the i-th category (e.g., "optimization successful" or "optimization failed"). By minimizing the Gini impurity, the tree can find the optimal split point, thereby generating a clear decision path. Finally, the entire random forest model integrates the prediction results of multiple trees, forming a powerful initial decision tree model (here referring to the entire random forest model) capable of mapping problem features to optimization actions.
[0113] Step S63: The initial decision tree model is trained using Monte Carlo simulation, and an effective parameter adjustment path that can improve the detection rate and reduce the false alarm rate is selected through reverse optimization.
[0114] Preferably, Monte Carlo simulation can be used to conduct massive testing on the parameter adjustment strategy recommended by the initial decision tree model. Random sampling is performed near the recommended parameter values. For example, if the model recommends adjusting the brightness threshold to 100, 10,000 parameter combinations are randomly generated in a uniform distribution within the interval [90, 110]. For each sampled parameter, the rapid simulation of steps S3 and S4 is rerun in the digital twin environment to calculate its detection rate and false alarm rate. Then, a Pareto optimal frontier screening condition is set using inverse optimization screening logic. For example, all parameter combinations that satisfy recall > 0.95 and false alarm rate < 0.05 are retained; or, non-dominated solutions are found among all samples that cannot improve one metric while keeping another metric constant.
[0115] Step S64: The defect association results are matched with the most suitable adjustment rule branch of the effective parameter adjustment path by the feature matching algorithm to obtain the structured optimization suggestions for tobacco packaging inspection configuration.
[0116] Preferably, a feature matching algorithm can be used to calculate the similarity between the current defect association result (i.e., the feature vector of the problem to be solved) and the problem features corresponding to each path in the set of effective parameter adjustment paths. Commonly used similarity measures include Euclidean distance or cosine similarity. The path with the highest similarity is selected as the most suitable adjustment rule branch. Finally, a structured optimization suggestion is generated, the content of which is a structured JSON data object, which may include: window_id: "Detection window 10" risk_level: "High risk" adjustments: [ { parameter: "brightness_threshold", suggested_value: 105, operation: "decrease_by_10"}, { parameter: "contrast", suggested_value: 1.2, operation: "increase_by_0.1"}, { parameter: "center_y", suggested_value: 450, operation: "shift_up_by_5px"} ] It is worth noting that the above suggestions can be directly parsed and executed by automated systems, or provided to external staff as precise operational guidance, thereby completing a full closed loop from problem diagnosis to solution.
[0117] Beneficial effects of steps S61 to S64: Step S61 analyzes the parameter deviation type and risk level in the defect association results to construct a parameter optimization objective function indexed by the detection window, clarifying constraints such as brightness threshold minimization, contrast optimization range, and coordinate tolerance, thus establishing a mathematical programming foundation for subsequent optimization. Step S62 trains a random forest decision tree model based on historical parameter tuning data, using parameter deviation and risk level as feature inputs. By minimizing the Gini coefficient, it generates a set of parameter adjustment rules for different defect patterns, forming a data-driven initial decision model. Step S63 uses Monte Carlo simulation to enhance the initial model, and through large-scale parameter combination simulation and reverse optimization, it selects effective parameter adjustment paths that can simultaneously improve the detection rate and reduce the false alarm rate, ensuring the feasibility and superiority of the optimization scheme. Step S64 finally uses a feature matching algorithm to adapt the defect association results to the effective paths, locates the optimal adjustment rule branch, and generates structured optimization suggestions containing specific brightness, contrast, and coordinate correction values, completing the closed-loop output from problem diagnosis to parameter self-optimization, providing a precise and reliable automated parameter tuning scheme for detection configuration.
[0118] Overall beneficial effects of steps S1 to S6: Step S1 involves the fusion of four data sources, integrating real-time equipment configuration, material optical parameters, real defect samples, and tobacco-specific rules into standardized fused data, providing a unified and standardized data foundation for subsequent simulations. Step S2 utilizes this data to drive an optical simulation engine, accurately simulating the optical properties of the cigarette pack material based on physical rendering technology, generating high-fidelity optical simulation results, and creating a near-realistic visual environment for virtual inspection. Step S3 combines the simulation results with dynamic detection window parameters, using configuration-driven rendering and parallel computing technologies to efficiently generate a dynamic rendering image sequence containing simulated defects, achieving accurate reproduction of the production line inspection scenario. Step S4 inputs the image sequence into the virtual detection engine. The system utilizes a double-precision evaluation model to quantitatively calculate the detection rate and false alarm rate, and completes a full defect coverage evaluation through parallel testing, producing an objective quantitative test report to accurately reflect the performance of the detection configuration. Step S5 performs intelligent analysis on the test report, using a defect association algorithm to locate the root cause of missed detections, identify parameter deviations in the detection window, and establish a causal relationship between defects and configuration, providing a clear direction for parameter optimization. Step S6 finally uses a decision tree algorithm based on the defect association results to generate structured optimization suggestions for window brightness, contrast, and coordinates, thereby completing a closed loop from detection configuration performance evaluation to automatic parameter tuning, effectively improving the accuracy and reliability of the detection configuration and avoiding reliance on human experience.
[0119] like Figure 2 As shown, this embodiment provides an example of a digital twin pre-verification system for tobacco packaging inspection configuration. In this embodiment, the digital twin pre-verification system is applied to the digital twin pre-verification method as described in the above embodiment.
[0120] Specifically, the digital twin pre-verification system includes a standardized fusion data acquisition module 1 with sequential electrical or signal connections, a cigarette pack optical simulation module 2, a dynamic rendering image sequence calculation module 3, a quantitative test report acquisition module 4, a defect association module 5, and a structured optimization suggestion acquisition module 6.
[0121] The standardized fusion data acquisition module 1 is used to perform four-source data fusion processing based on real-time equipment configuration data, tobacco pack material optical parameter library, real defect sample library, and tobacco-specific rule library to obtain standardized fusion data. The tobacco pack optical simulation module 2 is used to input the standardized fusion data into the tobacco pack physical rendering optical simulation engine, and simulate the laser material dispersion effect through a micro-surface GGX distribution model and anisotropic parameters based on the characteristics of the high gloss of the aluminum film calibrated by dynamic reflection variance, to obtain the optical simulation results. The dynamic rendering image sequence calculation module 3 is used to fuse the optical simulation results with the dynamic detection window parameters, focus the ROI region of the optical simulation results through configuration-driven rendering technology, and process real defect samples through a parallel computing architecture to obtain the dynamic rendering image. The sequence-based quantitative test report acquisition module 4 inputs the dynamically rendered image sequence into the virtual detection engine, calculates the detection rate and false alarm rate of the dynamically rendered image based on the double-precision evaluation model, and performs full defect coverage testing through the parallel sample test engine to obtain a quantitative test report; the defect association module 5 inputs the quantitative test report into the risk positioning engine, matches missed defects with configuration parameter deviations through the defect association algorithm, and locates coordinate anomalies through the high-risk defect identification component of the risk positioning engine to obtain defect association results; the structured optimization suggestion acquisition module 6 inputs the defect association results into the parameter optimization model, calculates adjustment suggestions for window brightness, contrast, and coordinates through the decision tree algorithm, and obtains structured optimization suggestions for tobacco packaging inspection configuration.
[0122] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Figure 3 As shown, the electronic device 7 includes a processor 71 and a memory 72 coupled to the processor 71.
[0123] The memory 72 stores program instructions for implementing the federated learning-based collaborative energy-saving method for government data clusters in any of the above embodiments.
[0124] The processor 71 is used to execute program instructions stored in the memory 72 for collaborative energy saving of government data clusters based on federated learning.
[0125] The processor 71 can also be referred to as a CPU (Central Processing Unit). The processor 71 may be an integrated circuit chip with signal processing capabilities. The processor 71 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor.
[0126] Furthermore, Figure 4 This is a schematic diagram of the structure of a storage medium according to an embodiment of this application. See also: Figure 4 In this embodiment of the application, the storage medium 8 stores program instructions 81 capable of implementing all the above methods. These program instructions 81 can be stored in the storage medium in the form of a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, or terminal devices such as computers, servers, mobile phones, and tablets.
[0127] In the several embodiments provided in this application, it should be understood that the disclosed systems, methods, and approaches can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between systems or units may be electrical, mechanical, signal, or other forms.
[0128] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units. The above are merely embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made based on the description and drawings of this application, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A digital twin pre-validation method for tobacco packaging inspection configuration, characterized in that, The digital twin pre-verification method includes: Step S1: Based on real-time equipment configuration data, tobacco pack material optical parameter library, real defect sample library and tobacco-specific rule library, perform four-source data fusion processing to obtain standardized fused data; Step S2: Input the standardized fused data into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration of the aluminum film specular characteristics, simulate the laser material dispersion effect through the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results. Step S3: The optical simulation results are fused with the dynamic detection window parameters. The ROI region of the optical simulation results is focused by the configuration-driven rendering technology, and the real defect samples are processed by the parallel computing architecture to obtain a dynamic rendering image sequence. Step S4: Input the dynamic rendering image sequence into the virtual detection engine, calculate the detection rate and false alarm rate of the dynamic rendering image based on the double precision evaluation model, and perform full defect coverage test through the parallel sample test engine to obtain a quantitative test report. Step S5: Input the quantitative test report into the risk location engine, match the missed defects with the configuration parameter deviation through the defect association algorithm, and locate the coordinate anomaly through the high-risk defect identification component of the risk location engine to obtain the defect association result; Step S6: Input the defect association results into the parameter optimization model, and use the decision tree algorithm to calculate adjustment suggestions for window brightness, contrast and coordinates to obtain structured optimization suggestions for the tobacco packaging inspection configuration.
2. The digital twin pre-verification method according to claim 1, characterized in that, Step S1 involves fusing four sources of data—real-time device configuration data, a library of optical parameters for cigarette packaging materials, a library of real-world defect samples, and a tobacco-specific rule base—to obtain standardized fused data, including: Step S11: Extract the number of detection windows, position coordinates, brightness threshold, and contrast parameters of the real-time device configuration data, and convert them into JSON structure data; Step S12: By querying the optical parameter library of cigarette pack materials, the cigarette pack brand in the JSON structure data is mapped to the corresponding material optical attribute set to obtain a standardized material parameter vector; Step S13: Based on the standardized material parameter vector, the defect samples are labeled with optical properties, and the defect feature vector set of each defect sample is extracted by the SIFT algorithm. Step S14: Based on the tobacco-specific rule base, analyze the misjudgment suppression logic of the trademark splicing seam and the box lid seam, and compile the misjudgment suppression logic into an executable data filtering function; Step S15: Spatiotemporal alignment and feature-level fusion are performed on the JSON structure data, the standardized material parameter vector, the defect feature vector set, and the executable data filtering function, and the standardized fused data is generated through a data consistency verification algorithm.
3. The digital twin pre-verification method according to claim 2, characterized in that, Step S2: Input the standardized fused data into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration of the aluminum film specular characteristics, simulate the laser material dispersion effect through the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results, including: Step S21: Initialize the optical simulation environment of the cigarette pack physical rendering optical simulation engine, configure the position, focal length, and lighting conditions of the virtual camera according to the detection environment parameters defined by the JSON structure data, and obtain a standardized virtual detection scene; Step S22: In the standardized virtual detection scenario, the Monte Carlo path tracing algorithm is applied to the aluminum-coated film area based on the standardized material parameter vector in the standardized fusion data, and the high-light reflection intensity is calculated by substituting the dynamic reflection variance parameter to obtain a high-fidelity reflection image of the aluminum-coated film area. Step S23: Call the micro-surface GGX distribution model to set the anisotropy coefficient to the preset tobacco measured value, and simulate the dispersion effect of the laser material region under several viewpoints through spectral rendering to obtain the anisotropic scattering image of the laser material. Step S24: The high-fidelity reflection image and the anisotropic scattering image of the laser material are fused at the pixel level, and texture mapping is performed according to the geometric model of the cigarette pack to obtain the optical simulation result of the cigarette pack.
4. The digital twin pre-verification method according to claim 2, characterized in that, Step S3: The optical simulation results are fused with the dynamic detection window parameters. The ROI region of the optical simulation results is focused using configuration-driven rendering technology. Real defect samples are processed using a parallel computing architecture to obtain a dynamically rendered image sequence, including: Step S31: Extract the vertex coordinates, spatial dimensions, and priority information of all detection windows from the JSON structure data to obtain the window definition dataset; Step S32: Register the window definition dataset with the optical simulation results in coordinate space, and map the two-dimensional coordinates of each detection window to the actual pixel area of the optical simulation image through an affine transformation matrix to obtain a window image mapping relationship table; Step S33: Perform super-resolution cropping on the optical simulation image region corresponding to each detection window in the window image mapping table using a bilinear interpolation algorithm to obtain local candidate image regions; Step S34: Apply a configuration-driven rendering strategy to the local candidate image regions according to the priority information of the detection window, improve the rendering accuracy of key regions by adaptive sampling rate, and obtain a multi-resolution ROI image set. Step S35: Register and fuse the multi-resolution ROI image set with the defect feature vector in the real defect sample library, and superimpose the defect texture onto the corresponding ROI image using the alpha blending algorithm to obtain a batch of simulated defect candidate sample images. Step S36: Initialize the parallel computing architecture, divide the simulated defect candidate sample image batch into tasks according to the detection window dimension, schedule several computing nodes to execute the rendering pipeline synchronously through a load balancing algorithm, and generate a dynamic rendering image sequence with spatiotemporal information.
5. The digital twin pre-verification method according to claim 1, characterized in that, Step S4: Input the dynamically rendered image sequence into the virtual detection engine, calculate the detection rate and false alarm rate of the dynamically rendered image based on the double-precision evaluation model, and perform a full defect coverage test through a parallel sample testing engine to obtain a quantitative test report, including: Step S41: Match the image frames of the dynamically rendered image sequence with the corresponding detection window configuration information using a timestamp alignment algorithm to obtain a detection sample set; Step S42: Input the detection sample set into the pre-trained deep learning defect detection model, and extract the surface texture, geometric shape and optical anomaly features of the detection sample set through a multi-scale feature pyramid network to obtain a preliminary defect identification result matrix; Step S43: Filter the preliminary defect identification result matrix using tobacco-specific rules, and eliminate false alarm samples by suppressing misjudgments of splicing seams and verifying fine seams in the box lid, to obtain a defect judgment result set; Step S44: Start the parallel sample testing engine, divide the defect judgment result set into several test subsets according to the defect category, and synchronously execute the defect verification process through a multi-core parallel computing architecture to obtain the original test data including the detection status of each sample. Step S45: Calculate the number of defects detected and the number of false alarms for each detection window in the original test data, and substitute them into the detection rate formula and the false alarm rate formula to obtain the performance index set. Step S46: Integrate the performance index set of all detection windows to obtain a quantitative test report including time dimension, spatial dimension, and defect type dimension.
6. The digital twin pre-verification method according to claim 5, characterized in that, Step S5: Input the quantitative test report into the risk location engine, match missed defects with configuration parameter deviations using a defect association algorithm, and locate coordinate anomalies using the high-risk defect identification component of the risk location engine to obtain defect association results, including: Step S51: Parse the set of performance indicators in the quantitative test report, extract the sample numbers of all missed defects with a detection rate of zero and their corresponding detection window identifiers, and obtain the initial list of missed defects. Step S52: Retrieve the original rendering data of the samples corresponding to the initial list of missed defects in the dynamic rendering image sequence, and restore the morphological features and gray-level distribution characteristics of the missed defects in the image space through the feature deconvolution algorithm to obtain the feature map of the missed defects. Step S53: Calculate the statistical correlation between the defect feature intensity and window brightness threshold and contrast parameters of the missed defect feature map and the detection window parameters in the standardized fusion data using the Pearson correlation coefficient algorithm to obtain the parameter defect correlation matrix; Step S54: Perform cluster analysis on the parameter defect correlation matrix, identify parameter defect combinations with significant correlations using the DBSCAN density clustering algorithm, and locate the set of high-risk parameter configurations that lead to systematic missed detections. Step S55: Correct and register each high-risk parameter configuration set separately, and obtain a parameter deviation analysis result containing specific deviation types and correction amounts based on a high-risk parameter configuration set; Step S56: Integrate all parameter deviation analysis results and sort them in descending order according to the severity level of defects to obtain structured defect association results.
7. The digital twin pre-verification method according to claim 6, characterized in that, Step S6: Input the defect association results into the parameter optimization model, and calculate adjustment suggestions for window brightness, contrast, and coordinates using a decision tree algorithm to obtain structured optimization suggestions for the tobacco packaging inspection configuration, including: Step S61: Analyze the parameter deviation type, risk level, and suggested correction direction in the parameter deviation analysis results, and construct a parameter optimization objective function indexed by the detection window; Step S62: Train a random forest decision tree model based on historical parameter tuning data, input the parameter bias type and risk level into the pre-trained random forest decision tree model, and generate a set of parameter adjustment rules that satisfy the parameter optimization objective function by minimizing the Gini coefficient, thereby obtaining the initial decision tree model; Step S63: The initial decision tree model is trained using Monte Carlo simulation, and an effective parameter adjustment path that can improve the detection rate and reduce the false alarm rate is selected through reverse optimization. Step S64: The defect association result is matched with the most suitable adjustment rule branch of the effective parameter adjustment path by the feature matching algorithm to obtain the structured optimization suggestion of the tobacco packaging detection configuration.
8. A digital twin pre-verification system for tobacco packaging inspection configuration, wherein the digital twin pre-verification system is applied to the digital twin pre-verification method as described in any one of claims 1 to 7, characterized in that, The digital twin pre-verification system includes: The standardized fusion data acquisition module is used to perform four-source data fusion processing based on real-time equipment configuration data, tobacco pack material optical parameter library, real defect sample library and tobacco-specific rule library to obtain standardized fusion data. The cigarette pack optical simulation module is used to input the standardized fused data into the cigarette pack physical rendering optical simulation engine. Based on the dynamic reflection variance calibration of the characteristics of the aluminum film specular highlights, the laser material dispersion effect is simulated through the micro-surface GGX distribution model and anisotropic parameters to obtain the optical simulation results. The dynamic rendering image sequence calculation module is used to fuse the optical simulation results with the dynamic detection window parameters, focus the ROI region of the optical simulation results through configuration-driven rendering technology, and process real defect samples through a parallel computing architecture to obtain a dynamic rendering image sequence. The quantitative test report acquisition module is used to input the dynamic rendering image sequence into the virtual detection engine, calculate the detection rate and false alarm rate of the dynamic rendering image based on the double precision evaluation model, and perform full defect coverage test through the parallel sample test engine to obtain a quantitative test report. The defect association module is used to input the quantitative test report into the risk location engine, match the missed defects with the configuration parameter deviation through the defect association algorithm, and locate the coordinate anomaly through the high-risk defect identification component of the risk location engine to obtain the defect association result. The structured optimization suggestion acquisition module is used to input the defect association results into the parameter optimization model, and calculate the adjustment suggestions for window brightness, contrast and coordinates through the decision tree algorithm to obtain the structured optimization suggestions for the tobacco packaging inspection configuration.
9. An electronic device, characterized in that, The method includes a processor and a memory coupled to the processor, the memory storing program instructions executable by the processor; when the processor executes the program instructions stored in the memory, it implements the digital twin pre-verification method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions that, when executed by a processor, enable the digital twin pre-verification method as described in any one of claims 1 to 7.