A kind of intelligent detection method for flatness of packaging box surface
By combining three-dimensional contour scanning and material density distribution, discrete void areas on the surface of packaging boxes are accurately identified and defect indexes are calculated, solving the problem of detection result deviation in existing technologies and achieving more accurate surface flatness detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WENZHOU FUJIE TECH CO LTD
- Filing Date
- 2026-05-15
- Publication Date
- 2026-06-12
Smart Images

Figure CN122199546A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial visual inspection technology, specifically a method for intelligent detection of the surface flatness of packaging boxes. Background Technology
[0002] Conventional packaging box surface flatness inspection often uses two-dimensional visual inspection or simple three-dimensional point cloud sampling methods. It relies on single geometric contour data to determine the surface defect status, and identifies surface depressions and protrusions through sparse point cloud sampling. Flatness is determined solely by single-point height difference or basic contour features. Some inspection methods only combine the basic material parameters of the packaging box to carry out single-dimensional defect judgment, without performing fine boundary processing on discrete abnormal areas within the three-dimensional contour data.
[0003] Two-dimensional detection methods cannot capture tiny discrete void defects in three-dimensional space. Simple three-dimensional sampling is difficult to accurately lock the boundary shape of discrete voids. The degree of defect is calculated by only a single geometric feature, which cannot correlate the spatial correspondence between the density distribution of the packaging box material and the geometric defects. The correlation information between density abnormality areas and geometric void areas is not included in the detection system. The calculation of a single defect feature cannot truly reflect the actual surface undulation deviation. The detection results deviate from the actual flatness of the packaging box surface.
[0004] It is necessary to generate closed boundary curves for discrete void regions within high-density sampling points in the 3D contour data stream, calculate the defect index based on the boundary perimeter and area values, fuse the geometric defect index corresponding to the discrete void region with the overlapping density anomaly blocks in the material density distribution map, analyze the surface undulation deviation based on the fused parameters, and output the final detection result. Summary of the Invention
[0005] This invention aims to solve at least one of the technical problems existing in the prior art; Therefore, this invention proposes an intelligent detection method for the surface flatness of packaging boxes, comprising: In response to the trigger command to start surface flatness detection, the three-dimensional contour scan data stream of the packaging box to be inspected is acquired; Extract the set of high-density sampling points from the three-dimensional contour scan data stream, and identify discrete void regions existing in the set of high-density sampling points; Perform a boundary tracing operation on the discrete cavity region to generate a closed boundary curve surrounding the discrete cavity region; The perimeter and area of the closed boundary curve are statistically analyzed, and the defect index is calculated based on the perimeter and area values. Obtain the material density distribution map of the packaging box to be tested, and extract the density anomaly blocks in the material density distribution map that overlap with the discrete void region; The defect index and the density anomaly block are combined to generate an intermediate state evaluation parameter set; The intermediate state evaluation parameter set is analyzed to obtain the surface undulation deviation, and the surface flatness detection result of the packaging box is output based on the surface undulation deviation.
[0006] Furthermore, the step of acquiring the three-dimensional contour scan data stream of the packaging box to be inspected includes: The linear laser emitter is controlled to perform a spiral scan on the outer surface of the packaging box to be tested at a constant angular velocity, and the original photoelectric signal sequence of the reflected light intensity changing over time is collected. The original photoelectric signal sequence is input into an adaptive gain amplifier for dynamic range adjustment to obtain a preprocessed signal stream with normalized amplitude. A high-speed analog-to-digital conversion operation is performed on the preprocessed signal stream to generate a digitally quantized signal frame with a fixed sampling interval; The digitally quantized signal frame is transmitted to an edge computing node, and a real-time point cloud reconstruction algorithm is executed in the edge computing node to output a three-dimensional contour scan data stream containing spatial coordinates and reflection intensity.
[0007] Further, the step of identifying discrete void regions present in the high-density sampling point set includes: Construct a virtual cube grid array covering the high-density sampling point set, and assign an initial occupancy mark to each virtual cube grid; Traverse each data point in the high-density sampling point set, map the data point to the corresponding virtual cube grid, and clear the occupancy mark of the mapped virtual cube grid; Scan all virtual cube grids and identify those virtual cube grids with initial occupancy marks as blank grid cells; Adjacent blank grid cells are aggregated to form multiple candidate void regions; Calculate the number of connected components in each candidate cavity region, and remove candidate cavity regions with a number of connected components less than a preset threshold to obtain discrete cavity regions.
[0008] Furthermore, the step of performing boundary tracing operation on the discrete void region includes: Starting from the geometric center of the discrete void region, rays are emitted in multiple predetermined directions until they reach non-void data points; Record the first intersection position of each ray with a non-hole data point, and mark all the first intersection positions as boundary seed points; Starting from any boundary seed point, retrieve adjacent non-hole data points in a clockwise direction and add the retrieved adjacent non-hole data points to the boundary point sequence; Continue performing adjacency search operations until the end point of the current boundary point sequence coincides with the start point, forming a closed boundary point loop; The boundary point loop is smoothed by filtering to eliminate sawtooth fluctuations caused by sampling noise and generate a closed boundary curve.
[0009] Further, the step of calculating the defect index based on the perimeter value and the area value includes: Obtain the theoretical circular reference region enclosed by the closed boundary curve, and calculate the equivalent radius of the theoretical circular reference region; Calculate the ideal perimeter and ideal area of the theoretical circular reference region based on the equivalent radius; The difference between the perimeter value of the closed boundary curve and the ideal perimeter value is calculated to obtain the absolute value of the perimeter deviation. The absolute value of the area deviation is obtained by performing a difference calculation between the area value enclosed by the closed boundary curve and the ideal area value. Multiply the absolute value of the perimeter deviation by a preset perimeter weighting factor, and multiply the absolute value of the area deviation by a preset area weighting factor. Add the two products together and divide by the ideal area value to obtain the defect index.
[0010] Further, the step of extracting density anomaly blocks that overlap with the discrete void region in the material density distribution map includes: Read the pre-stored substrate density map of the packaging box to be tested, which is generated by an industrial computed tomography (CT) scanner; The substrate density map is registered and aligned with the spatial coordinates of the discrete void region to establish a pixel-level positional correspondence. A comparative analysis window that completely overlaps with the discrete void region is defined in the substrate density map; Calculate the local density gradient value of each pixel within the comparison analysis window; Clusters of pixels whose local density gradient values exceed a preset gradient threshold are selected and defined as density anomalous blocks.
[0011] Further, the step of fusing the defect index with the density anomaly block to generate an intermediate state evaluation parameter set includes: The total number of pixels in the density anomaly block is counted, and the average gray value of the density anomaly block is obtained. The average gray value is mapped to a preset material porosity conversion table to obtain the corresponding material structure porosity coefficient. Extract the numerical features of the defect index, and perform logarithmic transformation on the numerical features to generate standardized defect feature values; Using the material structure porosity coefficient as a weighting factor, the standardized defect feature values are weighted and amplified to obtain preliminary fusion parameters; Obtain the manufacturing process type identifier of the packaging box to be inspected, and call the corresponding correction offset table according to the manufacturing process type identifier; The initial fusion parameters are offset corrected using the aforementioned correction offset table, and an intermediate state evaluation parameter set is output.
[0012] Further, the step of parsing the intermediate state evaluation parameter set to obtain the surface undulation deviation includes: The intermediate state evaluation parameter set is deconstructed using multidimensional features to separate morphological feature vectors and material feature vectors; The morphological feature vector is input into a pre-trained deep convolutional neural network model, which outputs a morphological deviation probability value. The material science feature vector is input into a pre-trained support vector regression model, and the support vector regression model outputs material compensation coefficients. Multiply the morphological deviation probability value by a preset morphological influence benchmark value to obtain the morphological contribution deviation amount; Multiply the material compensation coefficient by the preset material influence benchmark value to obtain the material contribution deviation. The surface undulation deviation is obtained by arithmetically summing the morphological contribution deviation and the material contribution deviation.
[0013] Further, the step of outputting the surface flatness test result of the packaging box based on the surface undulation deviation includes: Obtain the product grade classification standard document for the packaging box to be inspected, wherein the product grade classification standard document contains multiple flatness threshold ranges; Traverse the multiple smoothness threshold intervals to find the target threshold interval where the surface undulation deviation is located; Extract the grade identifiers corresponding to the target threshold range, wherein the grade identifiers include superior product identifiers, qualified product identifiers, and defective product identifiers; Generate a detection result data packet containing the surface undulation deviation value, the upper and lower limits of the target threshold range, and the level identifier; The detection result data packet is sent to the sorting control system of the production line, and a sorting action instruction corresponding to the grade identifier is triggered.
[0014] Further, the step of using the material structure porosity coefficient as a weighting factor to weight and amplify the standardized defect feature values to obtain preliminary fusion parameters includes: Read the value of the material structure porosity coefficient and determine whether the material structure porosity coefficient is greater than a preset porosity critical threshold. When the material structure porosity coefficient is less than or equal to the porosity critical threshold, the first linear amplification function is invoked, the slope parameter of the first linear amplification function is configured as the product of the material structure porosity coefficient and the preset basic amplification factor, and the standardized defect feature value is input into the configured first linear amplification function, and the first intermediate parameter is output. When the material structure porosity coefficient is greater than the porosity critical threshold, the second nonlinear amplification function is invoked. The second nonlinear amplification function contains an exponential term with the natural logarithm as the base. The material structure porosity coefficient is substituted into the coefficient of the exponential term of the second nonlinear amplification function, and the standardized defect feature value is input into the configured second nonlinear amplification function to output the second intermediate parameter. Obtain the surface coating thickness data of the packaging box to be tested, and query the preset thickness compensation table based on the surface coating thickness data to obtain the corresponding thickness attenuation factor; Multiply the first intermediate parameter or the second intermediate parameter by the thickness attenuation factor, and determine the product as the preliminary fusion parameter.
[0015] Compared with the prior art, the beneficial effects of the present invention are: By extracting a high-density set of sampling points from a 3D contour scan data stream, it is possible to accurately locate discrete void regions within the set. Boundary tracing operations are then performed on the identified discrete void regions to form closed boundary curves surrounding them. By statistically analyzing the perimeter and area of these closed boundary curves, the defect index can be directly calculated. This process fully preserves the geometric features of the discrete void regions, refines their boundary representation information, and mitigates the ambiguity in defect representation caused by sparse sampling points. It ensures that the defect index aligns with the actual geometric state of the discrete voids, improves the detail of the geometric defect representation, reduces information loss due to single geometric parameter judgments, and makes the quantification of the defect degree consistent with the true spatial morphology of the discrete void regions.
[0016] By acquiring the material density distribution map of the packaging box to be inspected, areas with abnormal material density distribution can be located. Density anomaly blocks that overlap with discrete void areas in the density distribution map can be extracted, establishing a correspondence between geometric defect areas and material density anomaly areas. The defect index and density anomaly blocks are fused to generate a corresponding intermediate state evaluation parameter set. Geometric and density features can be integrated to form multi-dimensional evaluation information. By analyzing the intermediate state evaluation parameter set, the corresponding surface undulation deviation is obtained, allowing the deviation to reflect the combined effect of geometric defects and density anomalies. This ensures that the test results closely match the actual defect state of the packaging box surface, eliminating evaluation errors caused by single-dimensional detection. It also ensures that the surface flatness test results match the actual defect situation of the packaging box surface, improving the accuracy and reliability of the test results. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the steps of an intelligent detection method for the surface flatness of a packaging box as described in this invention. Figure 2 A flowchart for identifying discrete void regions; Figure 3 Comparison chart of boundary curve smoothing filtering; Figure 4 A schematic diagram showing the correlation between the logarithmic standardized transformation curve of the defect index and the weighted amplification of the fusion parameters; Figure 5 Box plot comparing the distribution of deviations contributed by morphology and material in the surface flatness inspection of packaging boxes. Detailed Implementation
[0018] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] See Figure 1 This invention provides an intelligent method for detecting the surface flatness of packaging boxes, the specific method including: In response to the trigger command to initiate surface flatness detection, the system acquires the 3D contour scan data stream of the packaging box to be inspected, extracts the set of high-density sampling points from the 3D contour scan data stream, identifies discrete void regions existing in the set of high-density sampling points, performs boundary tracking operation on the discrete void regions, generates closed boundary curves surrounding the discrete void regions, calculates the perimeter and area values of the closed boundary curves, and calculates the defect index based on the perimeter and area values. The system also acquires the material density distribution map of the packaging box to be inspected, extracts density anomaly blocks that overlap with the discrete void regions from the material density distribution map, fuses the defect index and density anomaly blocks to generate an intermediate state evaluation parameter set, parses the intermediate state evaluation parameter set to obtain the surface undulation deviation, and outputs the surface flatness detection result of the packaging box based on the surface undulation deviation.
[0020] In one embodiment of the present invention, a linear laser emitter is controlled to perform a helical scan on the outer surface of the packaging box to be inspected at a constant angular velocity, acquiring the original photoelectric signal sequence of reflected light intensity changing over time. The original photoelectric signal sequence is input into an adaptive gain amplifier for dynamic range adjustment to obtain a preprocessed signal stream with normalized amplitude. A high-speed analog-to-digital conversion operation is performed on the preprocessed signal stream to generate a digital quantized signal frame with a fixed sampling interval. The digital quantized signal frame is transmitted to an edge computing node, and a real-time point cloud reconstruction algorithm is executed in the edge computing node to output a three-dimensional contour scan data stream containing spatial coordinates and reflection intensity.
[0021] In practice, in response to the trigger command to start surface flatness detection, the acquisition operation of the three-dimensional contour scanning data stream is executed. In practice, the linear laser emitter performs a spiral scan around the outer surface of the packaging box to be inspected at a constant angular velocity of 180 degrees per second. The scanning pitch of the linear laser emitter is set to 0.1 mm. During this process, the linear laser emitter continuously collects the reflected light intensity signal reflected from the surface of the packaging box. The reflected light intensity signal changes with time to form the original photoelectric signal sequence. In the flat area of the packaging box surface, the reflected light intensity signal presents a stable high level. In the area where there are depressions or holes on the surface of the packaging box, the reflected light intensity signal will show obvious pulse-like drops. In some embodiments, the acquired raw photoelectric signal sequence is immediately input to an adaptive gain amplifier for dynamic range adjustment. The adaptive gain amplifier dynamically adjusts its amplification factor according to the instantaneous amplitude of the raw photoelectric signal sequence. For signal segments with lower amplitudes, the adaptive gain amplifier uses a higher gain; for signal segments with amplitudes close to the saturation threshold, the adaptive gain amplifier uses a lower gain. After processing by the adaptive gain amplifier, the raw photoelectric signal sequence is adjusted into a preprocessed signal stream with a uniform amplitude fluctuation range and normalized amplitude. Optionally, the amplitude of the preprocessed signal stream is constrained within the range of 0 to 5 volts. The adjustment process of the preprocessed signal stream can be expressed as follows: ; in: This represents the input amplitude of the original photoelectric signal sequence at the nth sampling time. This indicates that the adaptive gain amplifier at the nth sampling time is based on... The magnification is calculated in real time. This represents the output amplitude of the preprocessed signal stream at the nth sampling time, after amplitude normalization. In practice, the normalized preprocessed signal stream is fed into a high-speed analog-to-digital converter (ADC). The ADC performs analog-to-digital conversion on the preprocessed signal stream at a fixed sampling interval of 1 mega-times per second, converting the continuous analog voltage signal into discrete digital quantized signal frames. Each digital quantized signal frame contains 1024 sampling points, and each sampling point represents the quantized reflected light intensity value as a 16-bit binary number. The digital quantized signal frames are transmitted via industrial Ethernet to edge computing nodes deployed alongside the production line. At the edge computing nodes, a real-time point cloud reconstruction algorithm, based on the triangulation principle and the spatial pose parameters of the linear laser emitter, calculates the time-intensity information carried by the digital quantized signal frames. The real-time point cloud reconstruction algorithm converts the timestamp and light intensity value of each sampling point into a coordinate point in three-dimensional space and the corresponding reflected intensity value.
[0022] In one embodiment of the present invention, see [reference] Figure 2 A virtual cube grid array covering a high-density sampling point set is constructed, and an initial occupancy mark is assigned to each virtual cube grid. Each data point in the high-density sampling point set is traversed, and the data point is mapped to the corresponding virtual cube grid. The occupancy mark of the mapped virtual cube grid is cleared. All virtual cube grids are scanned, and the virtual cube grids that retain the initial occupancy mark are determined as blank grid cells. Adjacent blank grid cells are aggregated to form multiple candidate hole regions. The number of connected components in each candidate hole region is calculated, and candidate hole regions with a number of connected components less than a preset threshold are removed to obtain discrete hole regions.
[0023] In specific implementations, identifying discrete void regions within a high-density sampling point set begins with constructing a virtual cube grid array covering the high-density sampling point set. Each grid cell in the virtual cube grid array is a cube with a side length of 0.5 mm, and each virtual cube grid is assigned an initial occupancy flag set to the logical value "1" to indicate that the grid is unoccupied. The high-density sampling point set contains one million data points, and its spatial coordinates range from 0 to 200 mm on the X-axis, 0 to 150 mm on the Y-axis, and -10 to 10 mm on the Z-axis. The dimensions of the virtual cube grid array are divided according to this coordinate range. In some embodiments, the index of the virtual cube grid is obtained through discretization calculation, and the formula for calculating the index of a data point mapped to the virtual cube grid is expressed as: ; in: , , These represent the integer index numbers of the virtual cube mesh in the X, Y, and Z directions, respectively. , , This represents the three-dimensional coordinates of data points in a high-density sampling point set. , , This represents the minimum boundary value of the high-density sampling point set in the three coordinate directions. This represents the constant side length of the virtual cube mesh. When traversing each data point in the high-density sampling point set, the system calculates the virtual cube mesh index corresponding to each data point according to the above formula, and clears the initial occupancy mark of the mapped virtual cube mesh from "1" to "0". This mark clearing operation indicates that the virtual cube mesh has been occupied by a data point. In practice, after completing the mapping and mark clearing operations for all data points, the system scans all virtual cube meshes in the virtual cube mesh array. Virtual cube meshes that still retain the initial occupancy mark "1" are identified as blank mesh cells. During the scan, it was found that the number of blank mesh cells accounts for approximately eight percent of the total number of virtual cube mesh arrays.
[0024] The aggregation of adjacent blank grid cells is performed by checking their spatial adjacency. The system uses a six-neighbor connectivity rule to determine whether two blank grid cells are adjacent; that is, two blank grid cells sharing a face are considered adjacent. A region growing algorithm is used to iteratively merge all adjacent blank grid cells starting from any blank grid cell, forming multiple spatially continuous blank grid clusters. Each blank grid cluster is defined as a candidate void region. In some embodiments, the number of connected components in each candidate void region is calculated by analyzing the topological connectivity of the blank grid cells within the candidate void region. The number of connected components refers to the number of non-connected sub-regions within the candidate void region. A continuous blank grid cluster has a connected component count of 1, while a cluster containing isolated blank grids has a connected component count greater than 1. Optionally, the system presets a connected component count threshold of 3. After calculating the connected component count for each candidate void region, candidate void regions with a connected component count less than 3 are removed. The removal operation directly deletes the blank grid cluster records corresponding to candidate void regions with a connected component count of 1 or 2. In practical implementation, candidate void regions retained after filtering by the number of connected components are defined as discrete void regions. Discrete void regions are represented in the virtual cube grid array as spatial regions composed of multiple connected blank grid cells with at least three internal connected components. Optionally, for candidate void regions with exactly three connected components, the system further checks the volume of each connected sub-region, retaining only those where the volume of all connected sub-regions is greater than the volume of a single grid cell. It can be understood that the identification process of discrete void regions relies on the construction and labeling mechanism of the virtual cube grid array. By quantifying the aggregation state and connectivity characteristics of blank grid cells, discrete spaces representing surface defects are accurately separated from the high-density sampling point set.
[0025] In one embodiment of the present invention, starting from the geometric center of the discrete void region, rays are emitted in multiple predetermined directions until they reach non-void data points. The first intersection position of each ray with the non-void data point is recorded, and all first intersection positions are marked as boundary seed points. Starting from any boundary seed point, adjacent non-void data points are retrieved in a clockwise direction, and the retrieved adjacent non-void data points are added to the boundary point sequence. The adjacency retrieval operation is continuously performed until the end point of the current boundary point sequence coincides with the start point, forming a closed boundary point loop. The boundary point loop is then smoothed and filtered to eliminate sawtooth fluctuations caused by sampling noise and generate a closed boundary curve. Obtain the theoretical circular reference area enclosed by the closed boundary curve, and calculate the equivalent radius of the theoretical circular reference area. Based on the equivalent radius, calculate the ideal perimeter and ideal area of the theoretical circular reference area. Perform a difference operation between the perimeter value of the closed boundary curve and the ideal perimeter value to obtain the absolute value of the perimeter deviation. Perform a difference operation between the area value enclosed by the closed boundary curve and the ideal area value to obtain the absolute value of the area deviation. Multiply the absolute value of the perimeter deviation by a preset perimeter weighting factor, and multiply the absolute value of the area deviation by a preset area weighting factor. Add the two products together and divide by the ideal area value to obtain the defect index.
[0026] In specific implementation, the boundary tracing operation for discrete void regions starts from the geometric center of the discrete void region. The geometric center of the discrete void region is obtained by calculating the arithmetic mean of the coordinates of all empty grid cells within the discrete void region. For example, the geometric center coordinates of a discrete void region in three-dimensional space are (102.3 mm, 75.6 mm, 0.2 mm). Rays are emitted from this geometric center point in twelve uniformly distributed predetermined directions, which are evenly distributed at 30-degree intervals on the horizontal plane. In some embodiments, each ray extends stepwise along its direction vector, extending 0.1 mm at a time and checking whether the current position exists in the high-density sampling point set. When the ray extends to a position point, and no data point less than 0.05 mm away from that position point can be found in the high-density sampling point set, it is determined that the ray has touched a non-void data point and stops extending. The position of the ray endpoint at this time is recorded as the first intersection position. Refer to Table 1, which shows some of the ray directions recorded in one operation and their corresponding first intersection position coordinates.
[0027] Table 1. Example table of ray directions and corresponding coordinates of the first intersection position: In specific implementation, all initial intersection points are marked as boundary seed points. Starting from any boundary seed point, for example, from the boundary seed point (112.5, 75.6, 0.3) corresponding to the direction with a 0-degree angle to the positive X-axis, adjacent non-hollow data points are searched in a clockwise direction. The adjacency search range is set as a cubic space with a side length of 0.2 mm centered on the current point. Within this cubic space, data points belonging to the high-density sampling point set that have not been marked as boundary points are searched. It can be understood that the first adjacent non-hollow data point that meets the criteria is added to the boundary point sequence. The system updates the current point to the newly added point and continues to perform the adjacency search operation. In each search, the system excludes points already existing in the boundary point sequence to prevent backtracking, and the boundary point sequence continuously extends. In some embodiments, boundary tracking continues until the Euclidean distance between the endpoint and the starting point of the boundary point sequence in three-dimensional space is less than 0.1 mm. At this point, it is determined that the endpoint and the starting point coincide, thus forming a closed boundary point loop. The boundary point loop may contain hundreds of ordered spatial points. Optionally, a moving average filter is used to smooth the boundary point loop. The filter window width is set to 5 points. The smoothing filter calculates the average coordinates of the points in the window and replaces the coordinates of the center point. The smoothing filter traverses all points in the boundary point loop, eliminating small coordinate fluctuations caused by sampling noise and generating a smooth closed boundary curve. In specific implementation, the perimeter of the closed boundary curve is obtained by accumulating the distances of the straight line segments between adjacent points in the closed boundary curve. The area enclosed by the closed boundary curve is obtained by calculating the projected area of the polygon on the XY plane. For example, the perimeter of a closed boundary curve is measured to be 15.7 mm, and the area it encloses is measured to be 12.4 square millimeters.
[0028] See Figure 3This study demonstrates the core effects of boundary tracing and noise suppression. Specifically, starting from the geometric center of the discrete cavity region (the solid circle in the image, with coordinates approximately (102.3 mm, 75.6 mm)), boundary seed points are obtained through multi-directional ray tracing. A closed original boundary point loop is generated through clockwise adjacency retrieval, as indicated by the solid line in the image (including noise). This curve exhibits significant sawtooth fluctuations due to sampling noise from the 3D contour scan, making it unsuitable for subsequent defect calculation. To eliminate the interference of sampling noise on morphological feature extraction, a moving average filter is applied to the original boundary point loop (the window width is set to 5 points, and the center point coordinates are replaced by the mean of the coordinates within the window), ultimately generating the smoothed closed boundary curve indicated by the dashed line in the image. The comparison shows that the smoothing process effectively filters out the high-frequency jitter of the original boundary, preserves the true contour shape of the cavity region, and strictly maintains the closure of the curve, providing a reliable foundation for the accurate calculation of subsequent morphological parameters such as perimeter and area. The figure fully verifies the effectiveness of the boundary tracking-smoothing filtering process: the original boundary loop completely preserves the original sampling information of the cavity region, the smoothed curve eliminates noise without contour distortion, and the positioning accuracy of the cavity center provides a precise geometric benchmark for the construction of the equivalent circular reference area, which is the core pre-process for calculating the defect index.
[0029] In one embodiment of the present invention, a pre-stored substrate density map of the packaging box to be tested, generated by an industrial computed tomography (CT) scanner, is read. The substrate density map is registered and aligned with the spatial coordinates of discrete void regions to establish a pixel-level positional correspondence. A contrast analysis window that completely overlaps with the discrete void regions is delineated in the substrate density map. The local density gradient value of each pixel within the contrast analysis window is calculated. Clusters of pixels whose local density gradient values exceed a preset gradient threshold are selected and defined as density anomaly blocks. The total number of pixels in the density anomaly blocks is counted, and the average gray value of the density anomaly blocks is obtained. This average gray value is mapped to a preset material porosity conversion table to obtain the corresponding material structure porosity coefficient. The numerical features of the defect index are extracted, and the numerical features are logarithmically transformed to generate standardized defect feature values. The system reads the material structure porosity coefficient and determines whether it is greater than a preset porosity critical threshold. When the material structure porosity coefficient is less than or equal to the porosity critical threshold, it calls the first linear amplification function, configuring the slope parameter of the first linear amplification function as the product of the material structure porosity coefficient and a preset base amplification factor. The standardized defect feature value is input into the configured first linear amplification function, and the first intermediate parameter is output. When the material structure porosity coefficient is greater than the porosity critical threshold, it calls the second nonlinear amplification function, which contains an exponential term with the natural logarithm as the base. The material structure porosity coefficient is substituted into the coefficient of the exponential term of the second nonlinear amplification function, and the standardized defect feature value is input into the configured second nonlinear amplification function, and the second intermediate parameter is output. The system obtains the surface coating thickness data of the packaging box to be tested, and queries a preset thickness compensation table based on the surface coating thickness data to obtain the corresponding thickness attenuation factor. The first or second intermediate parameter is multiplied by the thickness attenuation factor, and the product result is determined as the preliminary fusion parameter. Obtain the manufacturing process type identifier of the packaging box to be tested, and call the corresponding correction offset table according to the manufacturing process type identifier. Use the correction offset table to perform offset correction on the preliminary fusion parameters and output the intermediate evaluation parameter set.
[0030] In specific implementation, extracting density anomaly blocks overlapping discrete void regions in the material density distribution map begins by reading a pre-stored substrate density map of the packaging box to be tested. This substrate density map is generated synchronously by an industrial computed tomography (CT) scanner during the packaging box production process. The substrate density map is a two-dimensional grayscale image containing 65,536 pixels. The grayscale value of each pixel represents the density of the packaging box material in that local area; high grayscale values correspond to high material density, and low grayscale values correspond to low material density. In some embodiments, a feature point matching algorithm is used to register and align the substrate density map with the spatial coordinates of the discrete void regions. The system extracts at least four feature corner points on the edge contour of the discrete void regions and manually marks four corresponding feature points at the corresponding positions in the substrate density map. The pixel-level positional correspondence is achieved by solving the spatial transformation matrix. After registration and alignment, a one-to-one mapping is established between the pixel coordinate system of the substrate density map and the spatial coordinate system of the three-dimensional contour scan data. In practical implementation, a contrast analysis window that completely overlaps with the discrete void region is delineated in the substrate density map. The shape and size of the contrast analysis window are determined by the projection polygon of the discrete void region onto the XY plane. The system converts the vertex coordinates of the polygon into pixel coordinates in the substrate density map based on the registration relationship, and connects these vertices with straight lines to form a closed pixel region as the contrast analysis window. It can be understood that the local density gradient value of each pixel within the contrast analysis window is calculated using the Sobel operator. The system takes a 3x3 pixel neighborhood centered on each pixel and calculates the grayscale difference in the horizontal and vertical directions of this neighborhood, as well as the local density gradient value. From the horizontal difference results and vertical difference results The square root of the sum of squares gives us: ; Table 1 shows the coordinates of some pixels within a comparative analysis window and their calculated local density gradient values.
[0031] Table 1. Pixel coordinates and local density gradient values: In some embodiments, pixel clusters with local density gradient values exceeding a preset gradient threshold are filtered out. The preset gradient threshold is set to 10.0. The system traverses all pixels within the comparison analysis window, marks pixels with local density gradient values greater than 10.0, and checks the spatial adjacency of these marked pixels. Adjacent marked pixels are grouped into a cluster, and each such pixel cluster is defined as a density anomalous block. Multiple independent density anomalous blocks may be identified within a single comparison analysis window. In a specific implementation, the total number of pixels in a density anomalous block is counted, and the average gray value of the density anomalous block is obtained. The system processes each identified density anomalous block separately. For example, for a density anomalous block consisting of 25 pixels, the system accumulates the original gray values of these 25 pixels in the substrate density map and then divides by 25 to obtain the average gray value of the density anomalous block. Assume the calculation result is 128. Optionally, the average grayscale value is mapped to a preset material porosity conversion table to obtain the corresponding material structure porosity coefficient. The material porosity conversion table is a predefined lookup table that establishes a non-linear mapping relationship from the average grayscale value to the material structure porosity coefficient. Numerical features of the defect index are extracted and subjected to logarithmic transformation to generate standardized defect feature values; these numerical features are the defect index. The original values were processed using a base-10 logarithmic function to standardize the defect feature values. The calculation formula is: ; in: Indicator of defect level It is a very small constant used to prevent taking the logarithm with respect to zero. This represents the generated standardized defect feature value. The material structure porosity coefficient is read, and it is determined whether the material structure porosity coefficient is greater than a preset porosity critical threshold, which is set to 0.7. When the material structure porosity coefficient is less than or equal to 0.7, the first linear amplification function is invoked, and the slope parameter of the first linear amplification function is... Configured as the porosity coefficient of the material structure Compared with the preset base magnification The product of, i.e. and standardize the defect feature values The input is fed into the configured first linear amplification function, and the first intermediate parameter is output. When the porosity coefficient of the material structure is greater than 0.7, the second nonlinear amplification function is invoked. This second nonlinear amplification function contains an exponential term with the natural logarithm as its base, specifically in the form of... The porosity coefficient of the material structure Substituting the coefficient of the exponential term into the second nonlinear amplification function and standardize the defect feature values The input is fed into the configured second nonlinear amplification function, and the output is the second intermediate parameter. The surface coating thickness data of the packaging box to be inspected is obtained. The surface coating thickness data is obtained by measuring with an online thickness gauge, and the value is, for example, 0.05 mm. Based on the surface coating thickness data, a preset thickness compensation table is consulted. The thickness compensation table defines the thickness attenuation factor from the thickness value. The linear decreasing relationship was used to find the corresponding thickness attenuation factor. The first intermediate parameter Or the second intermediate parameter Multiply by thickness attenuation factor The product result is then used as the initial fusion parameter. ,Right now or The manufacturing process type identifier of the packaging box to be inspected is obtained. This identifier is read from the production management system, for example, it might be identified as "die-cutting and creasing process". The corresponding correction offset table is then retrieved based on the manufacturing process type identifier. This table stores empirical correction values for the initial fusion parameters applied to different processes. The initial fusion parameters were adjusted using a correction offset table. Perform offset correction and output intermediate state evaluation parameter set. .
[0032] See Figure 4 In the standardization and parameter fusion stage of the intelligent detection method for the flatness of packaging box surfaces, the construction and application of the logarithmic normalization transformation curve serves the quantitative characterization of defect features. The curve uses the original defect index as the horizontal axis and the logarithmic normalization transformation curve as the vertical axis. The transformed standardized defect feature value exhibits a non-linear growth characteristic of first rising rapidly and then leveling off: when the original defect index is in the range of 0 to 1, the standardized feature value rapidly climbs from the negative range to near 0; as the original defect index further increases to the range of 1 to 5, the standardized feature value continues to grow positively and gradually approaches the upper limit of 0.75. This transformation effectively achieves non-linear normalization and feature scaling of the original defect value. In conjunction with the technical implementation logic, this standardized defect feature value is the core input for parameter fusion: in the fusion step, the average gray value of the density anomaly block must first be calculated and mapped to obtain the material structure porosity coefficient, determining whether it exceeds the porosity critical threshold of 0.7—if not, the first linear amplification function is configured based on the slope of the product of the material structure porosity coefficient and the basic amplification factor to process the standardized defect feature value; if it exceeds, the second non-linear amplification function, composed of an exponential term with the natural logarithm as the base, is substituted to complete weighted amplification, obtaining the preliminary fusion parameters. The node distribution of the curves in the figure (the original defect indexes 1, 2, and 4 correspond to standardized feature values of approximately -0.1, 0.4, and 0.6, respectively) intuitively corresponds to the characteristic mapping law of the defect index from low amplitude to high amplitude under logarithmic transformation. At the same time, it provides a standardized feature input basis for subsequent weighted amplification, thickness compensation, and process offset correction by combining the material structure porosity coefficient. It is a key visual quantitative basis for achieving accurate generation of intermediate state evaluation parameter set.
[0033] In one embodiment of the present invention, the intermediate state evaluation parameter set is deconstructed into multidimensional features to separate morphological feature vectors and material feature vectors. The morphological feature vectors are input into a pre-trained deep convolutional neural network model, which outputs a morphological deviation probability value. The material feature vectors are input into a pre-trained support vector regression model, which outputs a material compensation coefficient. The morphological deviation probability value is multiplied by a preset morphological influence benchmark value to obtain the morphological contribution deviation. The material compensation coefficient is multiplied by a preset material influence benchmark value to obtain the material contribution deviation. The morphological contribution deviation and the material contribution deviation are arithmetically summed to obtain the surface undulation deviation. Obtain the product grade classification standard document for the packaging box to be inspected. This product grade classification standard document contains multiple flatness threshold ranges. Traverse multiple flatness threshold ranges to find the target threshold range where the surface undulation deviation is located. Extract the grade identifier corresponding to the target threshold range. The grade identifier includes the superior product identifier, qualified product identifier, and defective product identifier. Generate a test result data packet containing the surface undulation deviation value, the upper and lower limits of the target threshold range, and the grade identifier. Send the test result data packet to the sorting control system of the production line and trigger the sorting action instruction corresponding to the grade identifier.
[0034] In practice, the intermediate state evaluation parameter set is deconstructed using multidimensional features to separate morphological feature vectors and material feature vectors. The multidimensional feature deconstruction is achieved through principal component analysis (PCA). The intermediate state evaluation parameter set is a set containing twelve numerical parameters. PCA projects the twelve parameters onto two principal component directions. The projection coefficients on the first principal component direction constitute the morphological feature vector, and the projection coefficients on the second principal component direction constitute the material feature vector. The morphological feature vector is a vector with six dimensions, and the material feature vector is a vector with six dimensions. In some embodiments, morphological feature vectors are input into a pre-trained deep convolutional neural network model. The pre-trained deep convolutional neural network model has five convolutional layers and three fully connected layers. After receiving the six-dimensional morphological feature vectors, the model outputs a scalar value between 0 and 1 through multiple nonlinear transformations. This scalar value is defined as the morphological deviation probability value. For example, when the input morphological feature vector is [0.12, 0.85, -0.33, 0.47, -0.09, 0.21], the morphological deviation probability value output by the deep convolutional neural network model is 0.85. In practical implementation, the material science feature vector is input into a pre-trained support vector regression model. The pre-trained support vector regression model uses a radial basis function as its kernel function. After receiving the six-dimensional material science feature vector, the model calculates a real-valued output based on its internal support vectors and weights. This real-valued output is defined as the material compensation coefficient. For example, when the input material science feature vector is [0.05, -0.18, 0.33, 0.11, -0.24, 0.07], the material compensation coefficient output by the support vector regression model is 0.3. It can be understood that multiplying the shape deviation probability value by a preset shape influence benchmark value yields the shape contribution deviation. The preset shape influence benchmark value is a constant calibrated through process experiments. For example, if the shape influence benchmark value is set to 1.2, the shape contribution deviation... The calculation formula is: ; in: This represents the probability value of morphological deviation from the output of a deep convolutional neural network model. This indicates that the preset shape affects the baseline value. This represents the calculated morphological contribution deviation. In practice, the material compensation coefficient is multiplied by a preset material influence benchmark value to obtain the material contribution deviation. The preset material influence benchmark value is another constant calibrated through materials science experiments; for example, the material influence benchmark value is set to 0.8. The calculation is the material compensation coefficient. Material Influence Baseline Value The product of the morphological contribution deviation. Deviation from material contribution By performing arithmetic summation, the surface undulation deviation can be obtained. For example, morphological contribution deviation Material contribution deviation Then the surface undulation deviation Optionally, the system obtains a product grade classification standard document for the packaging box to be inspected. This document is stored in a structured query language database table, defining multiple flatness threshold intervals and their corresponding grade identifiers. For example, the flatness threshold interval [0.0, 1.0) corresponds to the identifier "A", the flatness threshold interval [1.0, 2.0) corresponds to the identifier "B", and the flatness threshold interval [2.0, +∞) corresponds to the identifier "C". In some embodiments, the system iterates through multiple flatness threshold intervals to find the target threshold interval where the surface undulation deviation falls. The system sequentially reads the lower and upper limits of each threshold interval from the product grade classification standard document, compares the surface undulation deviation value with each interval, and determines that the interval is the target threshold interval when the surface undulation deviation value is greater than or equal to the lower limit of an interval and less than the upper limit of that interval. The grade identifiers corresponding to the target threshold range are extracted. These grade identifiers include superior, qualified, and defective product identifiers. In the example, identifier "A" represents superior product, identifier "B" represents qualified product, and identifier "C" represents defective product. The surface fluctuation deviation of 1.26 falls within the interval [1.0, 2.0), therefore the extracted grade identifier is "B," i.e., qualified product. In practical implementation, a detection result data package containing the surface fluctuation deviation value, the upper and lower limits of the target threshold range, and the grade identifiers is generated.
[0035] See Figure 5This study presents the distribution characteristics and differences of morphological and material contribution deviations in the surface flatness inspection of packaging boxes. Regarding morphological contribution deviation, the upper quartile is approximately 0.81, the median is approximately 0.55, and the lower quartile is approximately 0.26. The upper beard line extends to a high position of approximately 1.13, and the lower limit of the lower beard line is approximately 0.1. The overall distribution range is large, and the box height is relatively high, indicating that the morphological dimension deviation has a high degree of dispersion and a wide fluctuation range, making it the main source of fluctuation in the surface flatness deviation of packaging boxes. Regarding material contribution deviation, the upper quartile is approximately 0.45, the median is approximately 0.40, and the lower quartile is approximately 0.28. The upper beard line upper limit is approximately 0.56, and the lower beard line lower limit is approximately 0.08. The overall distribution range is relatively narrower, and the box height is lower than the morphological contribution deviation, reflecting that the material dimension deviation fluctuates more smoothly and has a significantly lower degree of dispersion than the morphological dimension. Comparing the distributions of the two types of deviations, the median of the deviations contributed by morphology, the upper edge of the box, and the upper beard line are all higher than those contributed by material. This directly reflects that in the surface flatness inspection process of this packaging box, the deviation contribution from morphological features is significantly greater than that from material features, and the influence of material dimension deviation on the overall surface undulation deviation is relatively weak. At the same time, the lower limits of the two types of deviations are similar, indicating that their minimum deviation ranges are basically the same, but their maximum deviation ranges and fluctuation amplitudes are significantly different.
[0036] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.
Claims
1. A method for intelligent detection of the surface flatness of a packaging box, characterized in that, include: In response to the trigger command to start surface flatness detection, the three-dimensional contour scan data stream of the packaging box to be inspected is acquired; Extract the set of high-density sampling points from the three-dimensional contour scan data stream, and identify discrete void regions existing in the set of high-density sampling points; Perform a boundary tracing operation on the discrete cavity region to generate a closed boundary curve surrounding the discrete cavity region; The perimeter and area of the closed boundary curve are statistically analyzed, and the defect index is calculated based on the perimeter and area values. Obtain the material density distribution map of the packaging box to be tested, and extract the density anomaly blocks in the material density distribution map that overlap with the discrete void region; The defect index and the density anomaly block are combined to generate an intermediate state evaluation parameter set; The intermediate state evaluation parameter set is analyzed to obtain the surface undulation deviation, and the surface flatness detection result of the packaging box is output based on the surface undulation deviation.
2. The intelligent detection method for the surface flatness of a packaging box according to claim 1, characterized in that, The step of acquiring the three-dimensional contour scan data stream of the packaging box to be inspected includes: The linear laser emitter is controlled to perform a spiral scan on the outer surface of the packaging box to be tested at a constant angular velocity, and the original photoelectric signal sequence of the reflected light intensity changing over time is collected. The original photoelectric signal sequence is input into an adaptive gain amplifier for dynamic range adjustment to obtain a preprocessed signal stream with normalized amplitude. A high-speed analog-to-digital conversion operation is performed on the preprocessed signal stream to generate a digitally quantized signal frame with a fixed sampling interval; The digitally quantized signal frame is transmitted to an edge computing node, and a real-time point cloud reconstruction algorithm is executed in the edge computing node to output a three-dimensional contour scan data stream containing spatial coordinates and reflection intensity.
3. The intelligent detection method for the surface flatness of a packaging box according to claim 2, characterized in that, The step of identifying discrete void regions present in the high-density sampling point set includes: Construct a virtual cube grid array covering the high-density sampling point set, and assign an initial occupancy mark to each virtual cube grid; Traverse each data point in the high-density sampling point set, map the data point to the corresponding virtual cube grid, and clear the occupancy mark of the mapped virtual cube grid; Scan all virtual cube grids and identify those virtual cube grids with initial occupancy marks as blank grid cells; Adjacent blank grid cells are aggregated to form multiple candidate void regions; Calculate the number of connected components in each candidate cavity region, and remove candidate cavity regions with a number of connected components less than a preset threshold to obtain discrete cavity regions.
4. The intelligent detection method for the surface flatness of a packaging box according to claim 3, characterized in that, The steps for performing boundary tracing operations on the discrete cavity region include: Starting from the geometric center of the discrete void region, rays are emitted in multiple predetermined directions until they reach non-void data points; Record the first intersection position of each ray with a non-hole data point, and mark all the first intersection positions as boundary seed points; Starting from any boundary seed point, retrieve adjacent non-hole data points in a clockwise direction and add the retrieved adjacent non-hole data points to the boundary point sequence; Continue performing adjacency search operations until the end point of the current boundary point sequence coincides with the start point, forming a closed boundary point loop; The boundary point loop is smoothed by filtering to eliminate sawtooth fluctuations caused by sampling noise and generate a closed boundary curve.
5. The intelligent detection method for the surface flatness of a packaging box according to claim 4, characterized in that, The steps for calculating the defect index based on the perimeter and area values include: Obtain the theoretical circular reference region enclosed by the closed boundary curve, and calculate the equivalent radius of the theoretical circular reference region; Calculate the ideal perimeter and ideal area of the theoretical circular reference region based on the equivalent radius; The difference between the perimeter value of the closed boundary curve and the ideal perimeter value is calculated to obtain the absolute value of the perimeter deviation. The absolute value of the area deviation is obtained by performing a difference calculation between the area value enclosed by the closed boundary curve and the ideal area value. Multiply the absolute value of the perimeter deviation by a preset perimeter weighting factor, and multiply the absolute value of the area deviation by a preset area weighting factor. Add the two products together and divide by the ideal area value to obtain the defect index.
6. The intelligent detection method for the surface flatness of a packaging box according to claim 5, characterized in that, The step of extracting density anomaly blocks that overlap with the discrete void region in the material density distribution map includes: Read the pre-stored substrate density map of the packaging box to be tested, which is generated by an industrial computed tomography (CT) scanner; The substrate density map is registered and aligned with the spatial coordinates of the discrete void region to establish a pixel-level positional correspondence. A comparative analysis window that completely overlaps with the discrete void region is defined in the substrate density map; Calculate the local density gradient value of each pixel within the comparison analysis window; Clusters of pixels whose local density gradient values exceed a preset gradient threshold are selected and defined as density anomalous blocks.
7. The intelligent detection method for the surface flatness of a packaging box according to claim 6, characterized in that, The step of fusing the defect index and the density anomaly block to generate an intermediate evaluation parameter set includes: The total number of pixels in the density anomaly block is counted, and the average gray value of the density anomaly block is obtained. The average gray value is mapped to a preset material porosity conversion table to obtain the corresponding material structure porosity coefficient. Extract the numerical features of the defect index, and perform logarithmic transformation on the numerical features to generate standardized defect feature values; Using the material structure porosity coefficient as a weighting factor, the standardized defect feature values are weighted and amplified to obtain preliminary fusion parameters; Obtain the manufacturing process type identifier of the packaging box to be inspected, and call the corresponding correction offset table according to the manufacturing process type identifier; The initial fusion parameters are offset corrected using the aforementioned correction offset table, and an intermediate state evaluation parameter set is output.
8. The intelligent detection method for the surface flatness of a packaging box according to claim 7, characterized in that, The step of parsing the intermediate state evaluation parameter set to obtain the surface undulation deviation includes: The intermediate state evaluation parameter set is deconstructed using multidimensional features to separate morphological feature vectors and material feature vectors; The morphological feature vector is input into a pre-trained deep convolutional neural network model, which outputs a morphological deviation probability value. The material science feature vector is input into a pre-trained support vector regression model, and the support vector regression model outputs material compensation coefficients. Multiply the morphological deviation probability value by a preset morphological influence benchmark value to obtain the morphological contribution deviation amount; Multiply the material compensation coefficient by the preset material influence benchmark value to obtain the material contribution deviation. The surface undulation deviation is obtained by arithmetically summing the morphological contribution deviation and the material contribution deviation.
9. The intelligent detection method for the surface flatness of a packaging box according to claim 8, characterized in that, The steps for outputting the surface flatness test result of the packaging box based on the surface undulation deviation include: Obtain the product grade classification standard document for the packaging box to be inspected, wherein the product grade classification standard document contains multiple flatness threshold ranges; Traverse the multiple smoothness threshold intervals to find the target threshold interval where the surface undulation deviation is located; Extract the grade identifiers corresponding to the target threshold range, wherein the grade identifiers include superior product identifiers, qualified product identifiers, and defective product identifiers; Generate a detection result data packet containing the surface undulation deviation value, the upper and lower limits of the target threshold range, and the level identifier; The detection result data packet is sent to the sorting control system of the production line, and a sorting action instruction corresponding to the grade identifier is triggered.
10. The intelligent detection method for the surface flatness of a packaging box according to claim 9, characterized in that, The step of using the material structure porosity coefficient as a weighting factor to weight and amplify the standardized defect feature values to obtain preliminary fusion parameters includes: Read the value of the material structure porosity coefficient and determine whether the material structure porosity coefficient is greater than a preset porosity critical threshold. When the material structure porosity coefficient is less than or equal to the porosity critical threshold, the first linear amplification function is invoked, the slope parameter of the first linear amplification function is configured as the product of the material structure porosity coefficient and the preset basic amplification factor, and the standardized defect feature value is input into the configured first linear amplification function, and the first intermediate parameter is output. When the material structure porosity coefficient is greater than the porosity critical threshold, the second nonlinear amplification function is invoked. The second nonlinear amplification function contains an exponential term with the natural logarithm as the base. The material structure porosity coefficient is substituted into the coefficient of the exponential term of the second nonlinear amplification function, and the standardized defect feature value is input into the configured second nonlinear amplification function to output the second intermediate parameter. Obtain the surface coating thickness data of the packaging box to be tested, and query the preset thickness compensation table based on the surface coating thickness data to obtain the corresponding thickness attenuation factor; Multiply the first intermediate parameter or the second intermediate parameter by the thickness attenuation factor, and determine the product as the preliminary fusion parameter.