Packaging box surface flaw detection method and system

By merging illumination and texture components and performing multi-scale edge detection, spatiotemporal volume features are constructed, solving the problems of illumination sensitivity and texture interference in the detection of surface defects on packaging boxes, and achieving high-precision and high-robust defect recognition.

CN121685395APending Publication Date: 2026-03-17JIANGSU HUAYIN PACKAGING TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-18
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing technologies for detecting defects on the surface of packaging boxes suffer from problems such as light sensitivity, severe texture interference, and lack of utilization of temporal information, resulting in insufficient detection stability and accuracy.

Method used

By decomposing and merging the illumination and texture components of the packaging box surface image, edge detection is performed using multiple Gaussian scales, a spatiotemporal volume is constructed and features are extracted, and the features of the spatiotemporal volume are used to identify defects.

Benefits of technology

It achieves high-precision and robust automatic detection of surface defects in packaging boxes, effectively solving the problems of light sensitivity and texture interference, and improving the stability and accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121685395A_ABST
    Figure CN121685395A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer vision, and discloses a packaging box surface flaw detection method and system, and the method comprises the steps: shooting the surface of a packaging box, and obtaining an image sequence of the surface of the packaging box; extracting an illumination component and a texture component of the target image; mapping the illumination component of the target image to a preset gray level, and combining the illumination component with the texture component of the target image to obtain an illumination balanced image corresponding to the target image; performing edge detection on the illumination equalization image by using a plurality of preset Gaussian scales to obtain a plurality of edge images corresponding to the illumination equalization image; fusing the plurality of edge images to obtain an enhanced edge image; superposing a plurality of enhanced edge images corresponding to the image sequence to form a space-time body; extracting features of the space-time body; defects present on the surface of the packaging box are identified. According to the method, high-precision and high-robustness automatic detection of the surface flaws of the packaging box is realized through key technical means such as illumination equalization, multi-scale edge fusion and time-space feature extraction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision technology, and more specifically, to a method and system for detecting surface defects in packaging boxes. Background Technology

[0002] With the continuous improvement of automation and intelligence in modern manufacturing, product quality control has become a key link in ensuring enterprise competitiveness and consumer satisfaction. In the packaging industry, packaging boxes, as an important component of product appearance, directly affect the overall image and market acceptance of the product. Therefore, efficient and accurate detection of defects such as scratches, dents, printing defects, and stains on the surface of packaging boxes has become an indispensable part of the production process.

[0003] Traditional manual visual inspection methods rely on the experience and attention of operators, resulting in low efficiency, high subjectivity, and susceptibility to fatigue-induced missed detections, making it difficult to meet the real-time and consistency requirements of high-speed production lines. To overcome these shortcomings, machine vision-based automatic inspection technology has been widely applied in the field of packaging box surface defect identification in recent years. However, existing technologies still face many challenges. Packaging boxes are made of diverse materials (such as cardboard, plastic, and metal-coated films), with complex surface reflective properties. The brightness distribution of images captured under different lighting conditions varies significantly, causing the same defect to appear inconsistently in different images, affecting the stability of detection. At the same time, packaging box surfaces often contain rich textures and patterns (such as brand logos and decorative patterns). These normal texture features can easily be confused with real defects, leading to false positives or false negatives.

[0004] Against this backdrop, the present invention proposes a method and system for detecting surface defects in packaging boxes, aiming to solve the problems of light sensitivity, severe texture interference, and lack of time sequence information utilization in the existing technology, and to provide a reliable and efficient solution for intelligent packaging inspection. Summary of the Invention

[0005] In order to solve the above-mentioned technical problems, this application is made to provide a method and system for detecting surface defects of packaging boxes, which aims to solve the problems of light sensitivity, serious texture interference and lack of time information utilization in the prior art, and provide a reliable and efficient solution for intelligent packaging inspection.

[0006] In a first aspect, the present invention provides a method for detecting surface defects of a packaging box, comprising: photographing the surface of the packaging box to obtain an image sequence of the surface of the packaging box, the image sequence containing multiple consecutive frames of images of the surface of the packaging box; taking any frame of the surface of the packaging box in the image sequence as a target image, extracting the illumination component and texture component of the target image; mapping the illumination component of the target image to a preset grayscale level and merging it with the texture component of the target image to obtain an illumination equalization image corresponding to the target image; performing edge detection on the illumination equalization image using multiple preset Gaussian scales to obtain multiple edge maps corresponding to the illumination equalization image; fusing the multiple edge maps to obtain an enhanced edge map; superimposing the multiple enhanced edge maps corresponding to the image sequence to form a spatiotemporal volume; extracting features of the spatiotemporal volume; and identifying defects existing on the surface of the packaging box based on the features of the spatiotemporal volume.

[0007] Optionally, in the aforementioned method for detecting surface defects in packaging boxes, mapping the illumination component of the target image to a preset grayscale level includes: setting a neutral grayscale value based on the material of the packaging box. The neutral gray value Used to reflect the grayscale level; merged with the texture component of the target image to obtain an illumination equalization image corresponding to the target image, including: identifying the printing area on the surface of the packaging box; constructing a printing sensing mask based on the printing area. When pixel Printing sensing mask when located in the printing area When the pixel Printing sensing mask when located outside the printing area ; Calculate the illumination equalization image ,in This refers to the target image. This represents the illumination component of the target image.

[0008] Optionally, the aforementioned method for detecting surface defects in packaging boxes further includes, before performing edge detection on the illumination equalization image using multiple preset Gaussian scales: convolving the illumination equalization image using a preset anisotropic differential filter to obtain a multi-channel response map corresponding to the illumination equalization image. , The number of filtering directions of the anisotropic differential filter. For the first The local responsivity under various filtering directions is calculated; the local structure sensitivity map of the illumination equalization image is calculated. , The preset weights are used to calculate the final structural sensitivity of the illumination-equalized image. , , Each of the pixels The pixel mean and standard deviation of a local region centered at a preset size. The first balance factor is preset; based on the final structure sensitivity of the illumination-equalized image. The value range is set for the multiple Gaussian scales.

[0009] Optionally, in the aforementioned method for detecting surface defects in packaging boxes, fusing the multiple edge maps to obtain an enhanced edge map includes: calculating gradient magnitude maps corresponding to the multiple edge maps based on the multiple edge maps, wherein the first edge map... The edge map is , No. The gradient magnitude diagram is as follows ; Calculate the pixel Multiple edge confidences corresponding to the multiple edge maps, wherein the first... Each edge confidence level , The pixel The pixel grayscale variance of a local area with a preset size centered on the target. The preset adjustment factor, This represents the dot product. The function is in terms of real numbers An exponential function with base 0; calculate the enhanced edge map. , The second balance factor is preset. The function is used to find the maximum value.

[0010] Optionally, in the aforementioned method for detecting surface defects in packaging boxes, extracting the features of the spatiotemporal volume includes: using a preset 3D convolution kernel to extract the spatial detail features of the spatiotemporal volume; detecting the stability of the spatial detail features of the spatiotemporal volume within the spatiotemporal volume; constructing the temporal duration features of the spatiotemporal volume based on the stability of the spatial detail features; and merging the spatial detail features and the temporal duration features of the spatiotemporal volume as the features of the spatiotemporal volume.

[0011] Optionally, the aforementioned method for detecting defects on the surface of a packaging box includes, in which multiple enhanced edge maps corresponding to the image sequence are superimposed to form a spatiotemporal volume, the following steps are taken: edge detection is performed on a preset packaging box surface template image using multiple preset Gaussian scales to obtain multiple template edge maps corresponding to the packaging box surface template image; the multiple template edge maps are fused to obtain an enhanced template edge map; the multiple enhanced edge maps are compared with the enhanced template edge map to obtain multiple difference maps reflecting the differences between the multiple enhanced edge maps and the enhanced template edge map; and the multiple difference maps are superimposed to form the spatiotemporal volume.

[0012] Optionally, the aforementioned method for detecting surface defects in packaging boxes, wherein superimposing multiple enhanced edge images corresponding to the image sequence to form a spatiotemporal volume includes: taking the first enhanced edge image from the multiple enhanced edge images; identifying the geometric features of the first enhanced edge image; calculating the stability of the geometric features; when the stability of the geometric features is higher than a preset threshold, using the geometric features as structural anchor points of the first enhanced edge image; calculating the local edge direction of the structural anchor points; based on the position and local edge direction of the structural anchor points, searching for corresponding structural anchor points from the second enhanced edge image of the multiple enhanced edge images, until all structural anchor points of the multiple enhanced edge images are found; fitting and establishing an affine transformation matrix based on all structural anchor points of the multiple enhanced edge images; and superimposing the multiple enhanced edge images according to the affine transformation matrix to obtain the spatiotemporal volume.

[0013] Optionally, the aforementioned method for detecting surface defects in packaging boxes, in calculating the stability of the geometric features, includes: taking any corner point of the geometric features as the target pixel point. ; Calculate the target pixel point Structural saliency matrix ,in For the target pixel point Any pixel within a region of a preset size centered on the target. For the enhanced edge map at pixel points The gradient along the x-axis. For the enhanced edge map at pixel points The gradient along the y-axis. The preset attenuation control factor is used to calculate the target pixel. Structural saliency matrix Perform eigenvalue decomposition to obtain the largest eigenvalue. and minimum eigenvalue ; Calculate the target pixel point Structural stability index , The third balance factor is preset; the stability of the geometric feature is determined based on the structural stability index of multiple corner points of the geometric feature.

[0014] Secondly, the present invention provides a packaging box surface defect detection system, comprising: an imaging module for capturing images of the surface of the packaging box to obtain an image sequence of the surface of the packaging box, the image sequence containing multiple consecutive frames of images of the surface of the packaging box; an extraction module for extracting the illumination component and texture component of the target image using any frame of the surface of the packaging box in the image sequence as the target image; a merging module for mapping the illumination component of the target image to a preset grayscale level and merging it with the texture component of the target image to obtain an illumination equalization image corresponding to the target image; a detection module for performing edge detection on the illumination equalization image using multiple preset Gaussian scales to obtain multiple edge maps corresponding to the illumination equalization image; a fusion module for fusing the multiple edge maps to obtain an enhanced edge map; an overlay module for overlaying the multiple enhanced edge maps corresponding to the image sequence to form a spatiotemporal volume; a feature module for extracting features of the spatiotemporal volume; and a recognition module for recognizing defects existing on the surface of the packaging box based on the features of the spatiotemporal volume.

[0015] The above-described technical solutions of the present invention have at least one or more of the following beneficial effects: According to the technical solution of the present invention, through key technical means such as illumination equalization, multi-scale edge fusion and spatiotemporal feature extraction, high-precision and robust automatic detection of defects on the surface of packaging boxes is achieved. It effectively solves the core problems of light sensitivity, serious texture interference and lack of temporal information utilization in the existing technology, and has outstanding technical progress and significant industrial application value. Attached Figure Description

[0016] The above and other objects, features, and advantages of this application will become more apparent from the more detailed description of the embodiments of this application in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the embodiments of this application to explain this application and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.

[0017] Figure 1 This is a flowchart of a method for detecting surface defects of a packaging box according to an embodiment of this application; Figure 2 This is a partial flowchart of a method for detecting surface defects in a packaging box according to an embodiment of this application; Figure 3 This is another partial flowchart of a method for detecting surface defects of a packaging box according to an embodiment of this application; Figure 4 This is a block diagram of a packaging box surface defect detection system according to an embodiment of this application. Detailed Implementation

[0018] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.

[0019] like Figure 1 As shown, one embodiment of the present invention provides a method for detecting surface defects in packaging boxes, comprising: Step S110: Take a picture of the surface of the packaging box to obtain an image sequence of the surface of the packaging box. The image sequence contains multiple consecutive frames of images of the surface of the packaging box.

[0020] Step S120: Using the image of the surface of the packaging box in any frame of the image sequence as the target image, extract the illumination component and texture component of the target image.

[0021] In this embodiment, by decomposing the target image into illumination components and texture components, and then standardizing and mapping the illumination components before fusing them with the texture components, an illumination-balanced image is generated. This significantly reduces the image brightness fluctuations caused by uneven ambient lighting, reflections, or shadows, ensuring that subsequent processing is not affected by changes in illumination and improving the stability and consistency of defect detection under complex lighting conditions.

[0022] Step S130: Map the illumination component of the target image to a preset gray level and merge it with the texture component of the target image to obtain the illumination equalization image corresponding to the target image.

[0023] In this embodiment, multiple preset Gaussian scales are used to perform edge detection on the illumination-equalized image and then fused to obtain an enhanced edge map. This method can simultaneously capture edge features at different scales, preserving the fine structure of minor imperfections while suppressing interference from high-frequency noise and irrelevant textures, thereby improving the accuracy and completeness of edge information.

[0024] Step S140: Use multiple preset Gaussian scales to perform edge detection on the illumination equalization image to obtain multiple edge maps corresponding to the illumination equalization image.

[0025] Step S150: Fuse multiple edge maps to obtain an enhanced edge map.

[0026] Step S160: Superimpose multiple enhanced edge maps corresponding to the image sequence to form a spatiotemporal volume.

[0027] In this embodiment, enhanced edge maps corresponding to multiple consecutive frames of images are superimposed to construct a three-dimensional spatiotemporal volume, making full use of the temporal correlation information formed during the transportation of the packaging box. This spatiotemporal modeling method not only helps to eliminate random noise or artifacts in single-frame images, but also effectively identifies dynamic defects that exhibit specific patterns in the time dimension (such as scratch trajectories, periodic printing defects, etc.), significantly improving the reliability and recall rate of detection.

[0028] Step S170: Extract the features of the spatiotemporal volume.

[0029] Step S180: Based on the characteristics of the spatiotemporal volume, identify the defects present on the surface of the packaging box.

[0030] In this embodiment, since normal printed patterns and brand logos are static textures, they exhibit stable structures in the spatiotemporal volume, while real defects usually have local abrupt changes and temporal discontinuities. Therefore, identification based on spatiotemporal volume features can effectively distinguish between normal textures and abnormal defects, and significantly reduce false alarms caused by complex pattern backgrounds.

[0031] According to the technical solution of this embodiment, by using key technical means such as illumination equalization, multi-scale edge fusion and spatiotemporal feature extraction, high-precision and high-robust automatic detection of defects on the surface of packaging boxes is achieved. It effectively solves the core problems in the prior art, such as light sensitivity, serious texture interference and lack of temporal information utilization, and has outstanding technical progress and significant industrial application value.

[0032] One embodiment of the present invention provides a method for detecting surface defects of packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects of packaging boxes in this embodiment includes, in step S130, mapping the illumination component of the target image to a preset grayscale level, comprising: Set the neutral grayscale value according to the material of the packaging box. neutral gray value Used to reflect grayscale levels.

[0033] In this embodiment, by presetting corresponding neutral grayscale values ​​based on the specific material of the packaging box (such as white cardboard, coated paper, laminating material, etc.), the mapping of light components is made more consistent with the actual physical characteristics. Different materials have different abilities to reflect and absorb light, and using a fixed grayscale value uniformly can easily lead to distortion in overly bright or dark areas. This solution ensures that non-printed areas present a natural and consistent visual effect after the lighting is balanced by using neutral grayscale values ​​adapted to the material, effectively avoiding artificial artifacts introduced by improper grayscale mapping.

[0034] In step S130, the texture components of the target image are merged to obtain the illumination equalization image corresponding to the target image, including: (1) Identify the printed areas on the surface of the packaging box.

[0035] (2) Construct a printing sensing mask based on the printing area When pixel Printing sensing mask when located in the printing area When pixel Printing sensing mask located outside the printing area .

[0036] In this embodiment, by constructing a printing-sensing mask, it is possible to intelligently identify which areas in an image belong to printed content (such as brand logos, text, patterns, etc.).

[0037] (3) Calculate the illumination equalization image ,in Represents the target image. This represents the illumination component of the target image.

[0038] In this embodiment, the original illumination estimates are directly retained for printed areas to avoid damaging the original design details by applying illumination normalization operations; while for non-printed areas, illumination correction is performed to adjust them to a neutral grayscale reference. This differentiated processing strategy eliminates illumination interference while fully preserving the key visual information of the packaging box, significantly improving the accuracy of subsequent defect detection.

[0039] Traditional methods often misidentify high-contrast printed edges as scratches or damage. However, the technical solution in this embodiment explicitly "exempts" printed areas from participating in illumination equalization reconstruction through a masking mechanism, ensuring that these legitimate textures are not misidentified as anomalies during edge detection and spatiotemporal feature extraction. This fundamentally reduces false positives caused by complex graphic backgrounds, improving the system's specificity and industrial applicability. In non-printed areas, by subtracting the estimated illumination component from the original image and superimposing it onto a neutral grayscale reference, subtle local structural changes (such as micro-scratches, indentations, and blemishes) are highlighted, giving them higher contrast and recognizability in the illumination equalization image, thereby improving the detection capability for low-contrast, small-scale defects.

[0040] One embodiment of the present invention provides a method for detecting surface defects in packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects in packaging boxes in this embodiment further includes the following step before step S140: (1) Convolve the illumination equalization image using a preset anisotropic differential filter to obtain the multi-channel response map corresponding to the illumination equalization image. , This represents the number of filtering directions for the anisotropic differential filter. For the first Local responsivity under various filtering directions.

[0041] In this embodiment, by convolving the illumination-equalized image with preset anisotropic differential filters in multiple directions, the local gradient responses of edges, lines, and texture structures in different orientations of the image can be accurately captured. Compared with traditional isotropic operators (such as Sobel or Laplacian), this method has stronger sensitivity and discrimination ability for directional defects (such as scratches, creases, printing misalignments, etc.).

[0042] (2) Calculate the local structure sensitivity map of the illumination equalization image. , The preset weights.

[0043] In this embodiment, a structural sensitivity map is obtained by weighted sum of squares and square root of the responses in each direction. This effectively integrates multi-directional information, highlighting regions with genuine structural changes (such as defect edges) while suppressing false responses in noisy or smooth areas. The weight values ​​can be optimized based on the common directional distribution of actual packaging defects, further enhancing the targeting of detection.

[0044] (3) Calculate the final structure sensitivity of the illumination-equalized image. , , In pixels The pixel mean and standard deviation of a local region centered at a preset size. This is the preset first balance factor.

[0045] In this embodiment, by performing local mean-standard deviation normalization on the structure sensitivity map, global response bias caused by uneven surface material of the packaging box, differences in printing density, or residual illumination gradients is effectively eliminated. This normalization strategy makes the structure sensitivity more locally comparative, ensuring that the degree of structural anomaly can be fairly evaluated in both high-texture and low-texture regions.

[0046] (4) Based on the final structure sensitivity of the illumination-equalized image The value range is set with multiple Gaussian scale values.

[0047] According to the technical solution of this embodiment, multiple Gaussian scale parameters are dynamically set based on the value range of the final structural sensitivity, enabling the edge detection process to allocate scale resources "on demand"—for example, a smaller Gaussian scale is used in areas with high structural sensitivity (which may correspond to small scratches or sharp edges) to preserve details; while a larger scale is used in areas with low sensitivity but broad defects (such as stains or bulges) to capture wide-area variations. This data-driven multi-scale strategy is significantly superior to fixed scale combinations, improving the comprehensive detection capability for defects of different types and scales.

[0048] One embodiment of the present invention provides a method for detecting surface defects on packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects on packaging boxes in this embodiment includes step S150 as follows: (1) Based on multiple edge maps, calculate the gradient magnitude maps corresponding to the multiple edge maps, where the first edge map is the gradient magnitude map corresponding to the second edge map. The edge map is , No. The gradient magnitude diagram is as follows .

[0049] In this embodiment, the intensity of the edge response at each scale is quantified by calculating the gradient magnitude map corresponding to each edge map.

[0050] (2) Calculate pixels Multiple edge confidences corresponding to multiple edge maps, where the first... Each edge confidence level , It is based on pixels The pixel grayscale variance of a local area with a preset size centered on the target. The preset adjustment factor, This represents the dot product. The function is in terms of real numbers An exponential function with base 0.

[0051] On the surface of packaging boxes, normally printed content such as brand logos and decorative patterns often have strong edge responses, making them easily misidentified as defects by traditional edge detectors. The technical solution in this embodiment introduces local gray-level variance as a context-aware factor to dynamically reduce the edge confidence of these high-texture areas, fundamentally reducing false edge outputs caused by legitimate patterns and significantly improving the specificity of subsequent defect identification.

[0052] In this embodiment, edge confidence is constructed by combining the grayscale variance of a local region centered on a pixel. Since high-variance regions typically correspond to complex textures or printed patterns and are prone to producing false edges, an exponential decay term is used to suppress the edge response in such regions. This mechanism allows the system to "trust" edges appearing in smooth or low-texture regions (more likely to be genuine defects) while "questioning" edges appearing in high-texture regions (more likely to be normal patterns), thereby achieving intelligent edge quality discrimination and differential weighting.

[0053] (3) Calculate the enhanced edge map , The second balance factor is preset. The function is used to find the maximum value.

[0054] In this embodiment, by normalizing the maximum value of the sum of confidence scores at each location, the generated enhanced edge map has a good numerical range. This not only avoids the response amplitude drift caused by differences in illumination or gain between different images, but also enhances the cross-sample comparability of the edge map, providing a stable and consistent input for subsequent spatiotemporal volume construction and feature extraction.

[0055] According to the technical solution of this embodiment, by introducing an edge confidence model based on local texture complexity perception and a normalized weighted fusion strategy, printing interference is effectively suppressed while preserving the real defect edges, which greatly improves the quality and discriminative power of edge representation, and lays a solid foundation for subsequent spatiotemporal modeling and defect identification, which has significant technical progress and practical value.

[0056] like Figure 2 As shown, one embodiment of the present invention provides a method for detecting surface defects in packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects in packaging boxes in this embodiment includes step S170 as follows: Step S210: Using a preset 3D convolution kernel, extract the spatial detail features of the spatiotemporal volume.

[0057] In this embodiment, a preset 3D convolution kernel is used to extract spatial detail features in the spatiotemporal volume. Compared with traditional 2D image processing methods, the 3D convolution kernel can simultaneously capture information changes of the target object in three-dimensional space (length, width, and depth), which is crucial for identifying defects with complex textures or shapes. This method not only improves the detection capability of subtle defects but also effectively reduces misjudgments caused by changes in lighting conditions or material inhomogeneities.

[0058] Step S220: Detect the stability of the spatial detail features of the spacetime volume within the spacetime volume.

[0059] In this embodiment, by performing stability testing on the extracted spatial detail features, features that maintain consistency across different time points or viewpoints can be selected. This process helps eliminate false features caused by temporary factors (such as noise, moving shadows, etc.), thereby improving the reliability and accuracy of subsequent analysis. Furthermore, this stability assessment mechanism makes the system more robust and suitable for various complex industrial environments.

[0060] Step S230: Based on the stability of the spatial detail features of the spacetime volume, construct the temporal duration features of the spacetime volume.

[0061] In this embodiment, the temporal persistence features constructed based on the stability of spatial detail features enable a deeper understanding of the development process and dynamic characteristics of defects. This not only increases the dimensions of defect detection, shifting from static image analysis to dynamic behavior monitoring, but also allows the system to identify intermittent problems that only manifest within specific time periods, greatly improving the detection range and sensitivity.

[0062] Step S240: The spatial detail features and temporal duration features of the spacetime volume are merged and used as the features of the spacetime volume.

[0063] According to the technical solution of this embodiment, the spatial detail features and temporal persistence features of the spatiotemporal volume are combined to form a feature set that comprehensively describes the surface state of the packaging box. This multi-dimensional feature fusion strategy not only retains the rich information in the original data, but also reduces redundancy and interference through intelligent integration, making the final output feature vector more compact and efficient. For machine learning models, such feature representations are easier to train and have higher generalization ability, enabling them to adapt to more types of defect patterns.

[0064] like Figure 3 As shown, one embodiment of the present invention provides a method for detecting surface defects in packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects in packaging boxes in this embodiment includes step S160 as follows: Step S310: Use multiple preset Gaussian scales to perform edge detection on the preset packaging box surface template image to obtain multiple template edge maps corresponding to the packaging box surface template image.

[0065] Step S320: Fuse multiple template edge maps to obtain an enhanced template edge map.

[0066] In this embodiment, a template image of a flawless standard packaging box surface is pre-acquired, and the same multi-scale edge detection and fusion process as the image to be tested is performed on it to generate a high-fidelity enhanced template edge map, which serves as a reference benchmark for the "ideal state". This method transforms defect detection into a difference analysis problem of "actual edge vs. ideal edge", avoiding the risk of false alarms caused by relying solely on absolute edge strength for judgment, making the detection results more objective and repeatable, and is especially suitable for quality inspection scenarios in large-scale, standardized production.

[0067] Step S330: Compare multiple enhanced edge maps with the enhanced template edge map to obtain multiple difference maps, reflecting the differences between the multiple enhanced edge maps and the enhanced template edge map.

[0068] Packaging box surfaces typically contain fixed crease lines, die-cut outlines, printed borders, and other legitimate structural features. These exhibit strong responses in single-frame edge images and are easily misjudged as defects. In this embodiment, by comparing the enhanced edge image to be tested with the enhanced template edge image pixel by pixel, only the areas where the two are inconsistent are retained as difference signals. This automatically masks all normal structures and printed content that conform to the template, significantly reducing the false positive rate caused by fixed patterns.

[0069] Step S340: Superimpose multiple difference images to form a spacetime volume.

[0070] According to the technical solution of this embodiment, multiple difference images are superimposed to form a spatiotemporal volume. This spatiotemporal volume no longer contains redundant normal structural information, but focuses on "abnormal dynamic trajectories." For example, a scratch that runs through multiple frames will appear as a continuous abnormal channel in the spatiotemporal volume, while random noise will appear as isolated points. This difference-based spatiotemporal representation greatly enhances the identifiability of defects in the time dimension, providing high-quality, high-discriminative input for subsequent 3D convolution or spatiotemporal feature analysis, and improving the overall recognition accuracy.

[0071] like Figure 3 As shown, one embodiment of the present invention provides a method for detecting surface defects in packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects in packaging boxes in this embodiment includes step S160 as follows: Step S310: Take the first enhanced edge image from the multiple enhanced edge images.

[0072] Step S320: Identify the geometric features of the first enhanced edge map.

[0073] Step S330: Calculate the stability of the geometric features.

[0074] Step S340: When the stability of the geometric features is higher than a preset threshold, the geometric features are used as structural anchors of the first enhanced edge map.

[0075] Not all edge features are suitable as alignment references—for example, edges generated by noise or temporary occlusion lack temporal consistency. The technical solution in this embodiment calculates the stability of geometric features and retains only high-confidence features above a preset threshold as structural anchors. This ensures that the selected anchors originate from inherent, recurring structural elements of the packaging box (such as creases, corners, printed positioning marks, etc.), thereby improving the robustness and generalization ability of the affine transformation.

[0076] Step S350: Calculate the local edge direction of the structural anchor point.

[0077] Step S360: Based on the position of the structural anchor point and the local edge direction, find the corresponding structural anchor point from the second enhanced edge map of the multiple enhanced edge maps, until all structural anchor points of the multiple enhanced edge maps are found.

[0078] In this embodiment, not only the spatial location of structural anchor points is utilized, but also their local edge direction information is fused for cross-frame search and matching. This dual constraint of "position + direction" significantly reduces the probability of false matching, especially on the surface of packaging boxes with repetitive textures or symmetrical structures. It can effectively distinguish similar but non-corresponding positions, improve the accuracy of anchor point matching, and lay a solid foundation for subsequent transformation matrix estimation.

[0079] Step S370: Based on all structural anchor points of multiple enhanced edge maps, fit and establish an affine transformation matrix.

[0080] Step S380: Based on the affine transformation matrix, multiple enhanced edge maps are superimposed to obtain a spacetime volume.

[0081] During high-speed transport or handling, packaging boxes may undergo slight affine deformations such as stretching and tilting. The technical solution in this embodiment uses affine transformation instead of a simple translation / rotation model, which can more realistically describe the actual motion state. This allows the superimposed spatiotemporal volume to accurately reflect the true trajectory of the defect in the spatiotemporal dimension while maintaining structural continuity, providing high-quality input for subsequent 3D feature extraction.

[0082] According to the technical solution of this embodiment, by introducing an affine alignment mechanism based on stable geometric anchor points, high-precision spatiotemporal registration of multi-frame enhanced edge maps is achieved without the need for additional hardware (such as high-precision encoders or synchronous triggering devices). This fundamentally solves the detection failure problem caused by motion misalignment, and significantly improves the stability, accuracy and practicality of the packaging box surface defect detection system in real industrial environments. It has outstanding technical innovation and engineering application value.

[0083] One embodiment of the present invention provides a method for detecting surface defects on packaging boxes. Compared with the aforementioned embodiments, the method for detecting surface defects on packaging boxes in this embodiment includes step S330 as follows: (1) Take any corner point in the geometric features as the target pixel point. .

[0084] (2) Calculate the target pixel. Structural saliency matrix ,in For target pixel Any pixel within a region of a preset size centered on the target. To enhance the edge map at the pixel level The gradient along the x-axis. To enhance the edge map at the pixel level The gradient along the y-axis. This is the preset attenuation control factor.

[0085] In this embodiment, by constructing a structural saliency matrix for the target pixel, not only are the directional gradients of the pixel and its neighboring pixels considered, but a Gaussian kernel function is also used to weight the distances, maximizing the influence of the center point and gradually attenuating it from the periphery. This design effectively highlights the main edge directions and intensity changes within the local region, providing a solid quantitative foundation for subsequent stability assessment.

[0086] (3) Calculate the target pixel points Structural saliency matrix Perform eigenvalue decomposition to obtain the largest eigenvalue. and minimum eigenvalue .

[0087] In this embodiment, the eigenvalue decomposition of the structural saliency matrix reveals the energy distribution corresponding to the primary and secondary directions of the local structure. By comparing the maximum and minimum eigenvalues, it is possible to intuitively reflect whether the region has a clear dominant direction or complex texture. The structural stability index can effectively distinguish between rigid structures (such as creases and borders) and flexible or variable regions (such as printed patterns and background textures), thereby improving the detection accuracy of minute deformations.

[0088] (4) Calculate the target pixel. Structural stability index , This is the preset third balance factor.

[0089] (5) Determine the stability of the geometric feature based on the structural stability index of multiple corner points of the geometric feature.

[0090] According to the technical solution of this embodiment, through in-depth analysis and stability evaluation of geometric features, a more scientific and reasonable structural anchor point selection strategy is provided, which greatly improves the anti-interference ability and detection accuracy of the packaging box surface defect detection system. It is especially suitable for high-speed and dynamic industrial production environments, demonstrating important technological innovation value and broad application prospects.

[0091] like Figure 4 As shown, one embodiment of the present invention provides a packaging box surface defect detection system, comprising: The imaging module 410 captures images of the surface of the packaging box to obtain an image sequence of the surface of the packaging box, which contains multiple consecutive frames of images of the surface of the packaging box.

[0092] The extraction module 420 takes the image of the surface of the packaging box in any frame of the image sequence as the target image and extracts the illumination component and texture component of the target image.

[0093] In this embodiment, by decomposing the target image into illumination components and texture components, and then standardizing and mapping the illumination components before fusing them with the texture components, an illumination-balanced image is generated. This significantly reduces the image brightness fluctuations caused by uneven ambient lighting, reflections, or shadows, ensuring that subsequent processing is not affected by changes in illumination and improving the stability and consistency of defect detection under complex lighting conditions.

[0094] The merging module 430 maps the illumination component of the target image to a preset gray level and merges it with the texture component of the target image to obtain the illumination equalization image corresponding to the target image.

[0095] In this embodiment, multiple preset Gaussian scales are used to perform edge detection on the illumination-equalized image and then fused to obtain an enhanced edge map. This method can simultaneously capture edge features at different scales, preserving the fine structure of minor imperfections while suppressing interference from high-frequency noise and irrelevant textures, thereby improving the accuracy and completeness of edge information.

[0096] The detection module 440 uses multiple preset Gaussian scales to perform edge detection on the illumination equalization image, and obtains multiple edge maps corresponding to the illumination equalization image.

[0097] The fusion module 450 fuses multiple edge maps to obtain an enhanced edge map.

[0098] The overlay module 460 overlays multiple enhanced edge maps corresponding to the image sequence to form a spatiotemporal volume.

[0099] In this embodiment, enhanced edge maps corresponding to multiple consecutive frames of images are superimposed to construct a three-dimensional spatiotemporal volume, making full use of the temporal correlation information formed during the transportation of the packaging box. This spatiotemporal modeling method not only helps to eliminate random noise or artifacts in single-frame images, but also effectively identifies dynamic defects that exhibit specific patterns in the time dimension (such as scratch trajectories, periodic printing defects, etc.), significantly improving the reliability and recall rate of detection.

[0100] Feature module 470 extracts features of the spatiotemporal volume.

[0101] The identification module 480 identifies defects on the surface of the packaging box based on the characteristics of the spatiotemporal volume.

[0102] In this embodiment, since normal printed patterns and brand logos are static textures, they exhibit stable structures in the spatiotemporal volume, while real defects usually have local abrupt changes and temporal discontinuities. Therefore, identification based on spatiotemporal volume features can effectively distinguish between normal textures and abnormal defects, and significantly reduce false alarms caused by complex pattern backgrounds.

[0103] According to the technical solution of this embodiment, by using key technical means such as illumination equalization, multi-scale edge fusion and spatiotemporal feature extraction, high-precision and high-robust automatic detection of defects on the surface of packaging boxes is achieved. It effectively solves the core problems in the prior art, such as light sensitivity, serious texture interference and lack of temporal information utilization, and has outstanding technical progress and significant industrial application value.

[0104] The basic principles of this application have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this application are merely examples and not limitations, and should not be considered as essential features of each embodiment of this application. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the application to the necessity of employing the aforementioned specific details for implementation.

[0105] The block diagrams of devices, apparatuses, devices, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.

[0106] It should also be noted that in the apparatus, equipment, and methods of this application, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions of this application.

[0107] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this application. Therefore, this application is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0108] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this application to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A method for detecting surface defects of a packaging box, comprising: capturing an image sequence of a surface of the packaging box, the image sequence comprising a plurality of consecutive images of the surface of the packaging box; extracting an illumination component and a texture component of a target image of the image sequence; mapping the illumination component of the target image to a preset gray level and merging the texture component of the target image to obtain an illumination equalization image corresponding to the target image; performing edge detection on the illumination equalization image using a plurality of preset Gaussian scales to obtain a plurality of edge maps corresponding to the illumination equalization image; fusing the plurality of edge maps to obtain an enhanced edge map; stacking a plurality of enhanced edge maps corresponding to the image sequence to form a spatiotemporal body; extracting a feature of the spatiotemporal body; identifying defects existing on the surface of the packaging box based on the feature of the spatiotemporal body.

2. The package surface defect inspection method according to claim 1, wherein The mapping of the illumination component of the target image to a preset gray level comprises: Setting a neutral gray value according to the material of the packaging box , the neutral gray value is used to reflect the gray level; merging the texture component of the target image to obtain an illumination equalization image corresponding to the target image, comprising: identifying a printed area of the surface of the packaging box; Building a print-aware mask according to the print region When the pixel is located in the print region, print-aware mask When the pixel is located outside the print region, print-aware mask ; calculating a local structure sensitivity map of the illumination equalization image wherein representing the target image, representing an illumination component of the target image.

3. The method of claim 1, wherein, Before performing edge detection on the illumination equalization image using a plurality of preset Gaussian scales, further comprising: convolve the illumination balancing image using a preset anisotropic differential filter to obtain a multi-channel response map corresponding to the illumination balancing image , is a number of filtering directions of the anisotropic differential filter, is a local response degree in a first filtering direction, is a local response degree in a first filtering direction, calculating a local structure sensitivity map of the illumination equalization image , are preset weights; calculating a final structure sensitivity of the illumination equalization image , , are a pixel mean and a standard deviation of a local area of a preset size centered at the pixel , is a preset first balancing factor; Based on the final structure sensitivity of the illumination equalization image The value range is set for the multiple Gaussian scales.

4. The method of claim 1, wherein The fusing of the plurality of edge maps to obtain an enhanced edge map comprises: According to the plurality of edge maps, gradient magnitude maps corresponding to the plurality of edge maps are calculated, wherein an i-th edge map is , and an i-th gradient magnitude map is ; and ; and ; calculating the pixel a plurality of edge confidences corresponding to the plurality of edge maps, wherein a first edge confidence , is a pixel intensity variance of a local region of a preset size centered at the pixel is a preset adjustment factor, denotes a dot product, the function is an exponential function with a real number​​ computing the enhanced edge map , is a preset second balancing factor, function for taking the maximum value.

5. The method of claim 1, wherein, The extraction of a feature of the spatiotemporal body comprises: extracting spatial detail features of the spatiotemporal body using a preset 3D convolution kernel; detecting stability of the spatial detail features of the spatiotemporal body in the spatiotemporal body; constructing a time duration feature of the spatiotemporal body according to the stability of the spatial detail features of the spatiotemporal body; merging the spatial detail features and the time duration feature of the spatiotemporal body as the feature of the spatiotemporal body.

6. The method of inspecting surface flaws of a carton according to claim 1, wherein The stacking of a plurality of enhanced edge maps corresponding to the image sequence to form a spatiotemporal body comprises: performing edge detection on a preset packaging box surface template image using a plurality of preset Gaussian scales to obtain a plurality of template edge maps corresponding to the packaging box surface template image; fusing the plurality of template edge maps to obtain an enhanced template edge map; comparing the plurality of enhanced edge maps with the enhanced template edge map to obtain a plurality of difference maps reflecting differences between the plurality of enhanced edge maps and the enhanced template edge map; stacking the plurality of difference maps to form the spatiotemporal body.

7. The carton surface defect detection method of claim 1, wherein, The stacking of a plurality of enhanced edge maps corresponding to the image sequence to form a spatiotemporal body comprises: taking a first enhanced edge map from the plurality of enhanced edge maps; identifying a geometric feature of the first enhanced edge map; calculating stability of the geometric feature; when the stability of the geometric feature is higher than a preset threshold, taking the geometric feature as a structural anchor point of the first enhanced edge map; calculating a local edge direction of the structural anchor point; according to the position and the local edge direction of the structural anchor point, searching for a corresponding structural anchor point from a second enhanced edge map of the plurality of enhanced edge maps until all structural anchor points of the plurality of enhanced edge maps are found; According to all structure anchor points of the multiple enhanced edge maps, an affine transformation matrix is fitted and established; According to the affine transformation matrix, the multiple enhanced edge maps are superimposed to obtain the spatio-temporal body.

8. The package surface defect inspection method according to claim 7, wherein The stability of the geometric feature is calculated, including: Taking any corner point in the geometric features as a target pixel point ; calculating the structure saliency matrix of the target pixel point ​ ,in For the target pixel point Any pixel within a region of a preset size centered on the target. For the enhanced edge map at pixel points The gradient along the x-axis. For the enhanced edge map at pixel points The gradient along the y-axis. This is the preset attenuation control factor; perform eigenvalue decomposition on the structure saliency matrix of the target pixel point to obtain a maximum eigenvalue and a minimum eigenvalue ;​​ The target pixel point is calculated The structural stability index , The third balance factor is preset. According to the structure stability indexes of the multiple corner points of the geometric feature, the stability of the geometric feature is determined.

9. A packaging box surface defect detection system, comprising: a shooting module, which shoots the surface of a packaging box to obtain an image sequence of the surface of the packaging box, the image sequence containing multiple consecutive frames of images of the surface of the packaging box; an extraction module, which extracts an illumination component and a texture component of any frame of image of the surface of the packaging box in the image sequence as a target image; a merging module, which maps the illumination component of the target image to a preset gray level and merges the illumination component with the texture component of the target image to obtain an illumination equalization image corresponding to the target image; a detection module, which uses a plurality of preset Gaussian scales to perform edge detection on the illumination equalization image to obtain a plurality of edge maps corresponding to the illumination equalization image; a fusion module, which fuses the multiple edge maps to obtain an enhanced edge map; a superimposition module, which superimposes multiple enhanced edge maps corresponding to the image sequence to form a spatio-temporal body; a feature module, which extracts features of the spatio-temporal body; an identification module, which identifies defects existing on the surface of the packaging box based on the features of the spatio-temporal body.