Computer vision-based high-efficiency defect detection system for batch production of gift box packaging

By using computer vision-based texture direction analysis and Sobel filter processing, combined with crease suspicion index and comprehensive anomaly index, efficient and accurate detection of crease defects in gift box packaging is achieved. This solves the problem of difficulty in identifying subtle creases in existing technologies and improves detection efficiency and accuracy.

CN121458692BActive Publication Date: 2026-04-24SHENYANG XINYUHE TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENYANG XINYUHE TECHNOLOGY CO LTD
Filing Date
2025-11-10
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

Existing computer vision-based gift box packaging inspection methods are unable to effectively identify subtle creases and defects, resulting in poor inspection performance in mass production and affecting packaging strength and product quality.

Method used

The texture direction analysis module is used to obtain the directional consistency of the surface grayscale image. The Sobel filter is used to obtain the linear feature saliency map. The crease suspicion index and comprehensive anomaly index are used to determine whether the suspected crease area is a defect area. Combined with directional consistency, efficient detection is performed.

Benefits of technology

It improves the accuracy and efficiency of crease detection, enabling precise identification of creases in mass production, ensuring packaging quality, and reducing false and missed detection rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121458692B_ABST
    Figure CN121458692B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of gift box packaging appearance detection, and particularly relates to a high-efficiency flaw detection system for batch production of gift box packaging based on computer vision. The system comprises: a texture direction analysis module, which is used for collecting surface images of the gift box packaging, pre-processing to obtain surface gray images, and obtaining the direction consistency of each pixel point; a suspected crease area acquisition module, which is used for acquiring a linear feature saliency map and acquiring a suspected crease area; a crease suspicion index acquisition module, which is used for acquiring a crease suspicion index of the suspected crease area; a crease anomaly detection module, which is used for acquiring a comprehensive anomaly index of the suspected crease area according to the crease suspicion index of the suspected crease area and the mean value of the direction consistency of all pixel points in the suspected crease area; and judging whether the suspected crease area is a crease flaw area according to the comprehensive anomaly index. The present application can improve the accuracy of crease detection for the gift box packaging.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of gift box packaging appearance inspection technology, specifically to a high-efficiency defect detection system for mass production of gift box packaging based on computer vision. Background Technology

[0002] In the mass production of gift box packaging, computer vision-based defect detection systems are commonly used to automate quality control of surface defects. Currently, the mainstream and advanced method in this field is based on high-precision image template comparison. This method uses a pre-acquired image of a standard qualified product as a template, and then performs pixel-level comparison and difference analysis between the image of the product to be inspected and the template image on the inspection line. The advantage of this method is that it achieves rapid screening of macroscopic defects that differ significantly from the template, such as obvious dents and large-area stains, through automated image subtraction and difference threshold judgment. This represents a preliminary upgrade from manual visual inspection to automated detection in gift box packaging production, ensuring product quality to a certain extent.

[0003] Because creases create stress concentration points, they severely weaken the structural strength of packaging, making it highly susceptible to cracking during subsequent handling and stacking, leading to damage to the internal products. While the template comparison method can detect significant macroscopic defects, it is not effective in identifying subtle defects such as creases. This is because these defects are not significant in terms of grayscale and morphology. Furthermore, since cardboard packaging materials are typically corrugated (to increase the box's resistance to deformation), their surfaces exhibit consistent raised and recessed textures under light, further complicating the identification of creases. Summary of the Invention

[0004] To address the aforementioned technical problems, the present invention aims to provide a high-efficiency defect detection system for mass production of gift box packaging based on computer vision. The specific technical solution adopted is as follows:

[0005] One embodiment of the present invention provides a high-efficiency defect detection system for mass production of gift box packaging based on computer vision. The system includes:

[0006] The texture orientation analysis module is used to acquire surface images of gift box packaging and preprocess them to obtain surface grayscale images; the orientation consistency of each pixel is obtained based on the difference between the gradient orientation angle of each pixel in the surface grayscale image and the principal gradient orientation angle of the surface grayscale image.

[0007] The suspected crease region acquisition module is used to process each pixel in the surface grayscale image using Sobel filters in different directions to obtain a linear feature saliency map; the linear feature saliency map is then subjected to threshold segmentation and morphological processing to obtain the suspected crease region.

[0008] The crease suspicion index acquisition module is used to draw perpendicular lines from each pixel on the center line of the minimum bounding rectangle of a suspected crease area to the center line, and obtain the crease suspicion index of the suspected crease area based on the difference in gray values ​​of the pixels on both sides of the center line symmetrical about the center line.

[0009] The crease anomaly detection module is used to obtain a comprehensive anomaly index for a suspected crease area based on the crease suspicion index of the suspected crease area and the average value of the directional consistency of all pixels in the suspected crease area; and to determine whether the suspected crease area is a crease defect area based on the comprehensive anomaly index.

[0010] Preferably, obtaining the orientation consistency of each pixel based on the difference between the gradient direction angle of each pixel in the surface grayscale image and the principal gradient direction angle of the surface grayscale image includes:

[0011] The Sobel gradient operator is used to calculate the gradient values ​​of a pixel in the x and y directions of the surface grayscale image. The gradient direction angle of the pixel is obtained based on its gradient values ​​in the x and y directions. The gradient direction angle of each pixel is modulo 180° to obtain the modulo-diminished gradient direction angle. The 180° angle is divided into intervals of 10° each to obtain different angle intervals. The number of modulo-diminished gradient direction angles of each pixel in each angle interval is obtained. The center value of the angle interval containing the largest number of modulo-diminished gradient direction angles is taken as the principal gradient direction angle of the surface grayscale image. The difference between the modulo-diminished gradient direction angle of a pixel and the principal gradient direction angle of the surface grayscale image is calculated. The difference is mapped using a cosine function, and the mapped value is normalized to obtain the directional consistency of the pixel.

[0012] Preferably, the gradient direction angle of each pixel is modulo 180° to obtain the modulo-modulated gradient direction angle, including:

[0013] If the gradient direction angle of a pixel is less than or equal to 180°, then the gradient direction angle after taking the modulus of the pixel is the gradient direction angle of the pixel itself; if the gradient direction angle of the pixel is greater than 180°, then the gradient direction angle after taking the modulus of the pixel is the difference between the gradient direction angle of the pixel and 180°.

[0014] Preferably, Sobel filters in different directions are used to process each pixel in the surface grayscale image to obtain a linear feature saliency map, including:

[0015] Sobel filters in each direction are used to process each pixel in the surface grayscale image to obtain the response value of each pixel in each direction. The linear feature saliency map is obtained by retaining the response value of each pixel in each direction.

[0016] Preferably, a perpendicular line is drawn from each pixel on the center line of the smallest bounding rectangle of a suspected crease region to the center line. The crease suspicion index of the suspected crease region is obtained based on the difference in grayscale values ​​of the pixels on both sides of the center line symmetrical about the center line, including:

[0017] For a suspected crease area, the perpendicular line passing through a pixel on the center line is denoted as the first perpendicular line. A predetermined number of pixels on one side of the center line are taken sequentially on the first perpendicular line to form a first pixel set. A predetermined number of pixels on the other side of the center line are taken sequentially on the first perpendicular line to form a second pixel set. In the first pixel set and the second pixel set, every two symmetrical pixels are combined to form different pixel pairs.

[0018] The weight of a pixel pair is obtained by squaring the ratio of the distance of a pixel from the center line to half the number of pixel pairs corresponding to the first perpendicular line, and then applying a negative correlation mapping to the squared result using an exponential function with the natural constant as the base.

[0019] The symmetrical grayscale difference corresponding to the first vertical line is obtained by weighting the absolute values ​​of the difference between the grayscale values ​​of the two pixels in each pixel pair using the weights of each pixel pair; the symmetrical grayscale sum corresponding to the first vertical line is obtained by weighting the sum of the grayscale values ​​of the two pixels in each pixel pair using the weights of each pixel pair; the normalized symmetrical grayscale difference corresponding to the first vertical line is obtained by dividing the symmetrical grayscale difference corresponding to the first vertical line by the symmetrical grayscale sum corresponding to the first vertical line; and the degree of symmetry corresponding to the first vertical line is obtained by subtracting the normalized symmetrical grayscale difference corresponding to the first vertical line from the first preset value.

[0020] The crease suspicion index of the suspected crease region is obtained by considering the aspect ratio of the smallest bounding rectangle of the suspected crease region and the degree of symmetry corresponding to the perpendicular line from the center line passing through each pixel on the center line.

[0021] Preferably, the crease suspicion index of the suspected crease region is obtained based on the aspect ratio of the smallest bounding rectangle of the suspected crease region and the degree of symmetry corresponding to the perpendicular line from the center line passing through each pixel on the center line, including:

[0022] The geometric parameters of a suspected crease region are obtained by dividing the length of the minimum bounding rectangle of the suspected crease region by the sum of the width of the minimum bounding rectangle and the scale parameter. The geometric parameters of the suspected crease region are normalized using the hyperbolic tangent function and multiplied by the mean of the degree of symmetry corresponding to the perpendicular line of each pixel on the center line of the minimum bounding rectangle of the suspected crease region to obtain the crease suspicion index of the suspected crease region.

[0023] Preferably, a comprehensive anomaly index for a suspected crease region is obtained based on the crease suspicion index of a suspected crease region and the average of the directional consistency of all pixels within the suspected crease region, including:

[0024] The comprehensive anomaly index of a suspected crease region is obtained by weighted summing the crease suspicion index of a suspected crease region and the mean of the orientation consistency of all pixels in the suspected crease region.

[0025] The embodiments of the present invention have at least the following beneficial effects: This application acquires a surface image of a gift box packaging and preprocesses it to obtain a surface grayscale image; based on the difference between the gradient direction angle of each pixel in the surface grayscale image and the main gradient direction angle of the surface grayscale image, the directional consistency of each pixel is obtained, the main direction of the overall texture of the corrugated paper is analyzed, and the difference between creases and normal paper texture is analyzed from the perspective of the directionality of texture change, thereby improving the accuracy of crease defects;

[0026] Furthermore, Sobel filters with different orientations are used to process each pixel in the surface grayscale image to obtain a linear feature saliency map. Thresholding and morphological processing are performed on the linear feature saliency map to obtain suspected crease regions. Perpendicular lines are drawn from each pixel on the center line of the minimum bounding rectangle of a suspected crease region. The crease suspicion index of the suspected crease region is obtained based on the difference in grayscale values ​​of the pixels on both sides of the center line symmetrical about the center line. Finally, the comprehensive anomaly index of each suspected crease region is obtained by combining the directional consistency of each pixel. The comprehensive anomaly index is used to determine whether the suspected crease region is a crease defect region. Thus, while eliminating texture interference, the real crease is accurately located, achieving efficient and high-accuracy crease detection in mass production. Attached Figure Description

[0027] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 A system block diagram of a high-efficiency defect detection system for mass production of gift box packaging based on computer vision, provided in an embodiment of the present invention;

[0029] Figure 2 This is a schematic diagram of a crease in a high-efficiency defect detection system for mass production of gift box packaging based on computer vision, provided as an embodiment of the present invention. Detailed Implementation

[0030] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a computer vision-based high-efficiency defect detection system for mass production of gift box packaging according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0032] The following description, in conjunction with the accompanying drawings, details the specific solution of the high-efficiency defect detection system for mass production of gift box packaging based on computer vision provided by this invention.

[0033] In this embodiment, the main application scenario of the present invention is: This application mainly detects creases and defects in the outer packaging of gift boxes to improve the pass rate of gift box packaging.

[0034] Please see Figure 1 The diagram illustrates a system block diagram of a high-efficiency defect detection system for mass production of gift box packaging based on computer vision, according to an embodiment of the present invention. The system includes the following modules:

[0035] The texture orientation analysis module is used to acquire surface images of gift box packaging and preprocess them to obtain surface grayscale images; the orientation consistency of each pixel is obtained based on the difference between the gradient orientation angle of each pixel in the surface grayscale image and the principal gradient orientation angle of the surface grayscale image.

[0036] The core objective of the data preparation stage in the entire defect detection process—image acquisition—is to utilize mature machine vision technology to capture surface images of gift box packaging from complex production environments. Through a series of standardized preprocessing operations, interference such as uneven lighting and noise is eliminated, resulting in a high-quality, standardized grayscale image. The complex industrial environment, with its variations in lighting and equipment vibrations, directly leads to noise, uneven brightness, and blurriness in the acquired images. Directly inputting such raw images into subsequent detection algorithms severely interferes with feature extraction and judgment, leading to increased false positives and false negatives. Therefore, a standardized preprocessing workflow is essential to lay a reliable data foundation for subsequent analysis. This study employs a series of industrially validated classic image processing techniques to cleanse and enhance the raw images, transforming them into standardized images that contain only information about the gift box surface itself and minimize external interference. This provides high-quality, standardized input data for the accurate identification and classification of creases and defects, ensuring the accuracy and stability of the entire system's detection results.

[0037] Specifically, standardized image acquisition involves constructing a stable image acquisition station above the production line conveyor belt. Fixed high-resolution industrial cameras are deployed, equipped with evenly distributed light sources to ensure uniform illumination of the gift box surface. The cameras are linked to the production line control system; when each gift box arrives at the inspection station, a photoelectric sensor triggers the automatic acquisition of a surface image of the gift box—a high-definition color image—and simultaneously records metadata such as product number and timestamp.

[0038] Image preprocessing: First, grayscale conversion is performed to transform the surface image of the colored gift box packaging into a grayscale image, reducing the amount of data and improving processing speed. Next, noise suppression is performed by smoothing the image using Gaussian filtering or median filtering (selected according to the type of noise), effectively suppressing random noise introduced by the image sensor.

[0039] Image enhancement: A contrast-limited adaptive histogram equalization algorithm is used to enhance the overall contrast of the grayscale image, making the surface texture and potential defects of the corrugated paper clearer, while avoiding excessive amplification of noise, thus obtaining a surface grayscale image.

[0040] Establish a preprocessed image library: Associate the preprocessed surface grayscale images with their corresponding metadata (product number, timestamp, etc.) and store them in the database in a structured form to form an image library for subsequent operations.

[0041] After obtaining the image library, which contains rich image information, it was found that the surface of the corrugated paper used in gift box production has unidirectional textures, and each paper surface has a different texture. These are normal paper surface features, but similar defects (such as small creases) are often falsely detected using existing template matching detection methods.

[0042] Therefore, it is necessary to analyze the physical nature of paper and creases. First, the surface texture of paper exhibits a very strong directional consistency on a macroscopic scale. By analyzing the directional consistency of the texture, a directional consistency coefficient is obtained, which measures the degree of similarity between the current area and the normal texture. Although the texture of each gift box material surface is different, they all exhibit a strong and consistent directionality on a macroscopic scale. By calculating directional consistency, the degree to which any area in the image "resembles a normal texture" can be measured, outputting a "directional consistency map" corresponding to the original image, thus providing a crucial basis for subsequently distinguishing between genuine and counterfeit defects.

[0043] The orientation consistency of each pixel is obtained by comparing the gradient orientation angle of each pixel in the surface grayscale image with the principal gradient orientation angle of the surface grayscale image.

[0044] Specifically, the Sobel gradient operator is used to calculate the gradient values ​​of a pixel in the x and y directions of the surface grayscale image; the gradient direction angle of the pixel is obtained based on the gradient values ​​in the x and y directions; the gradient direction angle of each pixel is modulo 180° to obtain the modulo-diminished gradient direction angle; the 180° is divided into intervals of 10° to obtain different angle intervals, and the number of modulo-diminished gradient direction angles of each pixel in the surface grayscale image is obtained in each angle interval. The center value of the angle interval containing the largest number of modulo-diminished gradient direction angles is taken as the main gradient direction angle of the surface grayscale image; the difference between the modulo-diminished gradient direction angle of a pixel and the main gradient direction angle of the surface grayscale image is calculated, and twice the difference is mapped using the cosine function to obtain the mapped value. The mapped value is normalized to obtain the directional consistency of the pixel.

[0045] The specific calculation model for directional consistency is as follows:

[0046] ,

[0047] Where C represents the directional consistency of a pixel; θ represents the gradient direction angle of a pixel after modulo, and the formula for calculating the gradient direction angle is: , These represent the gradient values ​​of a pixel in the x and y directions, respectively. The direction of the most drastic change at each pixel is calculated. The modulo gradient direction angle is obtained by folding two angles of the same line together to fold the gradient direction angle within the range of 0° to 180°, thus eliminating the ambiguity of the periodicity of the direction angle. Specifically, if the gradient direction angle of a pixel is less than or equal to 180°, the modulo gradient direction angle is the pixel's own gradient direction angle. If the gradient direction angle of a pixel is greater than 180°, the modulo gradient direction angle is the difference between the pixel's gradient direction angle and 180°. For example, 0° and 180° represent the same line, only in opposite directions. An angle less than 180°, such as 30°, is simply its angle of 30°. If greater than 180°, such as 200°, the modulo operation subtracts 180°, resulting in 20°.

[0048] The principal gradient direction angle of the surface grayscale image represents the principal direction of the global texture, and the angle difference... Doubling is used because the direction angle is periodic (for example, 0° and 180° represent the same line). Using double angles can eliminate this ambiguity and ensure that the difference between 0° and 180° is calculated consistently (both tend to 1).

[0049] The cosine calculation maps the 2x angle difference to a consistency score. When the local direction is exactly the same as or completely opposite to the principal direction, the angle difference is 0° or 180°, and doubling it results in 0° or 360°, with a cosine value of 1, indicating the highest consistency. When the local direction is perpendicular to the principal direction (90° difference), doubling it results in 180°, with a cosine value of -1, indicating the lowest consistency. Because the final range of the cosine is [-1, 1], it is not suitable as a scoring standard. The entire score is normalized to obtain the matching score of each pixel with the main direction, which is the directional consistency of that pixel.

[0050] This allows us to obtain the directional consistency of each pixel in the surface grayscale image.

[0051] The suspected crease region acquisition module is used to process each pixel in the surface grayscale image using Sobel filters in different directions to obtain a linear feature saliency map; the linear feature saliency map is then subjected to threshold segmentation and morphological processing to obtain the suspected crease region.

[0052] In the above analysis, the alignment score (alignment score) of each pixel with the main direction was obtained through directional consistency calculation. These scores can effectively measure the orientation of normal textures; however, they can only reflect the deviation of each region's orientation from the normal direction macroscopically. Relying solely on directional consistency cannot be used as a basis for crease and defect detection. Therefore, it is necessary to extract features related to defect depth from image data and construct an index that can quantify the crease and defect situation for crease detection.

[0053] To achieve a balance between efficiency and accuracy, a two-stage processing strategy, from coarse to fine, is adopted. The underlying technology is that while creases and imperfections may resemble the textured background, they exhibit specific, quantifiable physical characteristics. First, all suspected crease areas are quickly located, and then they are subjected to in-depth, multi-dimensional, three-dimensional measurement.

[0054] A crease appears as a "dark line" or "bright line" in an image. Its core feature is that the grayscale value changes drastically (i.e., a large gradient) in the direction perpendicular to its direction. However, the crease direction of gift boxes on the production line is random. Therefore, it is necessary to use Sobel filters with different directions to process the surface grayscale image. For example, a set of Sobel filters with 0°, 45°, 90°, and 135° can be set to process the surface grayscale image.

[0055] Next, Sobel filters in different directions are used to process each pixel in the surface grayscale image to obtain a linear feature saliency map. Specifically, Sobel filters in different directions are used to process each pixel in the surface grayscale image to obtain the response value of each pixel in each direction, and the response value of each pixel in each direction is retained to obtain a linear feature saliency map.

[0056] For a pixel, if it's on a crease, its response value will be much higher in the direction that maximizes its gradient than in other directions. Essentially, the Sobel filter in different directions processes each pixel in a surface grayscale image by calculating the rate of change and direction of the pixel's grayscale value in a specific direction within a small region around the pixel (i.e., the area covered by the filter kernel). The output value after convolution is the pixel's "response value" in that specific filter direction. If it's just texture or noise, its response in all directions may be relatively weak, or no direction may be particularly prominent. Therefore, for each pixel, the maximum value of its "response value" across all filter directions is taken. Because pixels representing creases have a strong response in one direction, they are all preserved. Texture gradients are typically smoother and more continuous than realistic creases, resulting in a relatively low "maximum response value." Noise is isolated and non-directional, thus its maximum response value is also low. The result is a linear feature saliency map where creases are enhanced and background texture and noise are relatively suppressed. This generates a direction-independent linear feature saliency map, which is a grayscale image with a black background and crease-like areas appearing as white or gray. The brightness value of each pixel in this image represents the probability of linear features present at that location, regardless of direction. The area containing the crease will appear as a bright line in this image.

[0057] Finally, thresholding is performed on the obtained linear feature saliency map. The Otsu algorithm (which can obtain an adaptive threshold) is used for thresholding. The algorithm calculates an optimal threshold for the entire image or different regions of the image, and binarizes the pixels. White represents the suspected crease region and black represents the background, resulting in a binarized mask map of the suspected crease region. The white part is the initially extracted all possible creases and linear interferences.

[0058] Furthermore, a morphological closing operation needs to be performed on the mask image of the suspected crease region (using a linear structuring element to perform a dilation and erosion operation on the binary image to connect the broken white areas) to obtain the suspected crease region. It should be noted that the image processing operation here is a well-known technique and will not be elaborated upon further.

[0059] The crease suspicion index acquisition module is used to draw perpendicular lines from each pixel on the center line of the smallest bounding rectangle of a suspected crease area to the center line, and obtain the crease suspicion index of the suspected crease area based on the difference in gray values ​​of the pixels on both sides of the center line symmetrical about the center line.

[0060] Because creases are subtle and irregular, their detection requires multi-level feature fusion. The physical characteristics of creases include a high aspect ratio (standard feature) and symmetrical macroscopic grayscale changes on both sides of the crease (key macroscopic feature). By using complementary features to corroborate each other, a highly robust and specific crease suspicion index is formed, thereby detecting crease defects and ensuring detection accuracy.

[0061] For suspected crease areas, their unique complementary features are extracted: geometric shape and grayscale symmetry. Creases will simultaneously satisfy both of these features, and a crease suspicion index is obtained by combining them. This index is used to determine the defect status of suspected crease areas.

[0062] This allows for the mapping of suspected crease regions in the linear feature saliency map to the surface grayscale image, enabling further analysis of the suspected crease regions in the surface grayscale image.

[0063] Specifically, obtain the smallest bounding rectangle of each suspected crease region, and obtain the center line of the smallest bounding rectangle. Draw a perpendicular line to the center line from each pixel point on the center line of the smallest bounding rectangle of the suspected crease region.

[0064] For a suspected crease area, the perpendicular line passing through a pixel on the center line is denoted as the first perpendicular line. A predetermined number of pixels on one side of the center line are taken sequentially on the first perpendicular line to form a first pixel set. A predetermined number of pixels on the other side of the center line are taken sequentially on the first perpendicular line to form a second pixel set. In the first pixel set and the second pixel set, every two symmetrical pixels are combined to form different pixel pairs.

[0065] The weight of a pixel pair is obtained by squaring the ratio of the distance of a pixel from the center line to half the number of pixel pairs corresponding to the first perpendicular line, and then applying a negative correlation mapping to the squared result using an exponential function with the natural constant as the base.

[0066] The symmetrical grayscale difference corresponding to the first vertical line is obtained by weighting the absolute values ​​of the difference between the grayscale values ​​of the two pixels in each pixel pair using the weights of each pixel pair; the symmetrical grayscale sum corresponding to the first vertical line is obtained by weighting the sum of the grayscale values ​​of the two pixels in each pixel pair using the weights of each pixel pair; the normalized symmetrical grayscale difference corresponding to the first vertical line is obtained by dividing the symmetrical grayscale difference corresponding to the first vertical line by the symmetrical grayscale sum corresponding to the first vertical line; and the degree of symmetry corresponding to the first vertical line is obtained by subtracting the normalized symmetrical grayscale difference corresponding to the first vertical line from the first preset value.

[0067] The crease suspicion index of the suspected crease region is obtained by considering the aspect ratio of the smallest bounding rectangle of the suspected crease region and the degree of symmetry corresponding to the perpendicular line from the center line passing through each pixel on the center line.

[0068] Specifically, the geometric parameters of a suspected crease region are obtained by dividing the length of the minimum bounding rectangle of the suspected crease region by the sum of the width of the minimum bounding rectangle and the scale parameter. The geometric parameters of the suspected crease region are normalized using the hyperbolic tangent function and multiplied by the mean of the degree of symmetry corresponding to the perpendicular line of each pixel on the center line of the minimum bounding rectangle passing through the suspected crease region to obtain the crease suspicion index of the suspected crease region.

[0069] The specific model for calculating the degree of symmetry is as follows:

[0070] ,

[0071] Where DC represents the degree of symmetry corresponding to the perpendicular line from a pixel on the center line of the minimum bounding rectangle passing through a suspected crease region; 1 is the first preset value; exp is an exponential function with the natural constant as the base; r represents the number of pixel pairs corresponding to the perpendicular line, that is, the number of pixels on one side of the center line on the perpendicular line, which is also the preset number. The preset number is 25% of the width of the minimum bounding rectangle and rounded up. The length and width of the minimum bounding rectangle are measured in pixels, such as... Figure 2 As shown in the figure, white represents the suspected crease area, black represents the normal area, and black and white circles represent pixels. The rectangle in the figure is the smallest bounding rectangle of a suspected crease area. The row of white pixels labeled 1 is the center line of the smallest bounding rectangle. Pixels labeled 2 and 3 are two pixels symmetrical about the center line, forming a pixel pair. Pixels labeled 4 and 5 also form a pixel pair. The width of the smallest bounding rectangle is 5 pixels and the length is 11 pixels, that is, the width is 5, so the value of r is 2.

[0072] This represents the distance of the i-th pixel in the pixel pair corresponding to the vertical line from the center line, where the two pixels in the pair are at the same distance from the center line. The weight of the i-th pixel pair is a function for calculating the weights, derived from a modified Gaussian weight formula. The decay term in the original Gaussian weight formula (the term within parentheses) is modified to... The rate of decay increases exponentially from the rate of increase. The decision means that pixels closer to the center of the crease have higher value and greater weight.

[0073] and Let represent the grayscale values ​​of one pixel and the other pixel in the i-th pixel pair, respectively. It is the absolute value of the difference between the gray values ​​of two pixels, quantizing the absolute difference in gray values ​​at symmetrical positions, reflecting the degree of asymmetry of the point pair (if the difference is 0, then it is completely symmetrical). This represents the symmetrical grayscale difference corresponding to the vertical line; a larger difference indicates lower grayscale symmetry on both sides. The sum of the symmetrical gray levels corresponding to this vertical line is used to normalize the differences in symmetrical gray levels. The larger the value, the higher the grayscale symmetry of the pixels on both sides of the center line of the vertical line, that is, the greater the degree of symmetry corresponding to the vertical line.

[0074] The specific model for calculating the crease suspicion index of a crease area is as follows:

[0075] ,

[0076] Where S represents the crease suspicion index of a suspected crease region; tanh is the hyperbolic tangent function, which is used for normalization. If a large aspect ratio is present, it asymptotically approaches 1 and the saturation rate can be adjusted by the scale parameter k, conforming to the change process when the ratio is greater than 0. The smallest bounding rectangle extracted from the suspected region is obtained, and its aspect ratio is calculated. The larger the ratio, the higher the function value. The closer it is to 1, the better. The scale parameter k is the average aspect ratio of the smallest bounding rectangle of the historical crease; These are geometric morphological parameters;

[0077] N is the length of the centerline. Figure 2 The value of N is 11, which can also be described as the number of perpendicular lines drawn from the pixels on the center line to the center line. Let be the degree of symmetry corresponding to the j-th vertical line; multiplying the two terms indicates that the crease suspicion index will increase only when both the aspect ratio and grayscale symmetry are satisfied, meaning that this area is more likely to be a crease defect.

[0078] This allows us to obtain the crease suspicion index for each suspected crease area.

[0079] The crease anomaly detection module is used to obtain a comprehensive anomaly index for a suspected crease area based on the crease suspicion index of the suspected crease area and the average value of the directional consistency of all pixels in the suspected crease area; and to determine whether the suspected crease area is a crease defect area based on the comprehensive anomaly index.

[0080] Even if a suspected crease area has a high crease suspicion index, if its direction is highly consistent with the background texture, then it is very likely to be the texture itself rather than a real defect. Conversely, a linear feature with a moderate crease suspicion index but completely inconsistent with the background direction is very likely to be a real crease. Therefore, using the obtained texture-level directional consistency as reinforcement and weighting it with the obtained crease suspicion index can solve this problem, effectively suppressing false defects and highlighting true defects.

[0081] Therefore, the comprehensive anomaly index of the suspected crease region is obtained by weighted summing the crease suspicion index of a suspected crease region and the mean of the orientation consistency of all pixels in the suspected crease region.

[0082] Since surface texture (directional consistency) is used to enhance the crease suspicion index, a smaller weight is given to the mean of directional consistency (which can be set according to the salience of the texture in the actual gift box; the higher the weight, the greater the influence of the feature on the overall score), and a larger weight is given to the crease suspicion index. The reference value for the weight parameter of the mean of directional consistency of all pixels in the suspected crease area is 0.4, and the reference value for the weight parameter of the crease suspicion index is 0.6. The weight parameters can be optimized in the future based on the actual detection results.

[0083] Furthermore, the grayscale images of historically qualified gift box packaging are analyzed to obtain the comprehensive anomaly index of each suspected crease area, and the 99th percentile is used as the judgment threshold. If the comprehensive anomaly index of a suspected crease area in the grayscale image of the gift box packaging to be inspected is greater than the judgment threshold, then the suspected crease area is a crease defect area, and the gift box packaging to be inspected is unqualified. If unqualified, the crease defect area is marked in red and moved to the unqualified area for subsequent traceability operations; if qualified, it is sent to the designated location normally. After each batch of inspection is completed, a report is generated based on the qualified and unqualified data of the unqualified gift box packaging as the basis for subsequent analysis.

[0084] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0085] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0086] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A high-efficiency defect detection system for mass production of gift box packaging based on computer vision, characterized in that, The system includes: The texture orientation analysis module is used to acquire surface images of gift box packaging and preprocess them to obtain surface grayscale images; the orientation consistency of each pixel is obtained based on the difference between the gradient orientation angle of each pixel in the surface grayscale image and the principal gradient orientation angle of the surface grayscale image. The suspected crease region acquisition module is used to process each pixel in the surface grayscale image using Sobel filters in different directions to obtain a linear feature saliency map; the linear feature saliency map is then subjected to threshold segmentation and morphological processing to obtain the suspected crease region. The crease suspicion index acquisition module is used to draw perpendicular lines from each pixel on the center line of the minimum bounding rectangle of a suspected crease area to the center line, and obtain the crease suspicion index of the suspected crease area based on the difference in gray values ​​of the pixels on both sides of the center line symmetrical about the center line. The crease anomaly detection module is used to obtain a comprehensive anomaly index of a suspected crease area based on the crease suspicion index of a suspected crease area and the average value of the directional consistency of all pixels in the suspected crease area; and to determine whether the suspected crease area is a crease defect area based on the comprehensive anomaly index. The method of obtaining the orientation consistency of each pixel based on the difference between the gradient direction angle of each pixel in the surface grayscale image and the principal gradient direction angle of the surface grayscale image includes: The Sobel gradient operator is used to calculate the gradient values ​​of a pixel in the x and y directions of the surface grayscale image. The gradient direction angle of the pixel is obtained based on its gradient values ​​in the x and y directions. The gradient direction angle of each pixel is modulo 180° to obtain the modulo-diminished gradient direction angle. The 180° angle is divided into intervals of 10° each to obtain different angle intervals. The number of modulo-diminished gradient direction angles of each pixel in each angle interval is obtained. The center value of the angle interval containing the largest number of modulo-diminished gradient direction angles is taken as the principal gradient direction angle of the surface grayscale image. The difference between the modulo-diminished gradient direction angle of a pixel and the principal gradient direction angle of the surface grayscale image is calculated. The difference is mapped using a cosine function, and the mapped value is normalized to obtain the directional consistency of the pixel. The method of using Sobel filters in different directions to process each pixel in the surface grayscale image to obtain a linear feature saliency map includes: Sobel filters in each direction are used to process each pixel in the grayscale image to obtain the response value of each pixel in each direction. The linear feature saliency map is obtained by retaining the response value of each pixel in each direction. The process involves drawing perpendicular lines from each pixel on the center line of the minimum bounding rectangle passing through a suspected crease region to the center line. The crease suspicion index of the suspected crease region is obtained based on the difference in grayscale values ​​of pixels on either side of the center line symmetrical about the center line, including: For a suspected crease area, the perpendicular line passing through a pixel on the center line is denoted as the first perpendicular line. A predetermined number of pixels on one side of the center line are taken sequentially on the first perpendicular line to form a first pixel set. A predetermined number of pixels on the other side of the center line are taken sequentially on the first perpendicular line to form a second pixel set. In the first pixel set and the second pixel set, every two symmetrical pixels are combined to form different pixel pairs. The weight of a pixel pair is obtained by squaring the ratio of the distance of a pixel from the center line to half the number of pixel pairs corresponding to the first perpendicular line, and then applying a negative correlation mapping to the squared result using an exponential function with the natural constant as the base. The symmetrical grayscale difference corresponding to the first vertical line is obtained by weighting the absolute values ​​of the difference between the grayscale values ​​of the two pixels in each pixel pair using the weights of each pixel pair; the symmetrical grayscale sum corresponding to the first vertical line is obtained by weighting the sum of the grayscale values ​​of the two pixels in each pixel pair using the weights of each pixel pair; the normalized symmetrical grayscale difference corresponding to the first vertical line is obtained by dividing the symmetrical grayscale difference corresponding to the first vertical line by the symmetrical grayscale sum corresponding to the first vertical line; and the degree of symmetry corresponding to the first vertical line is obtained by subtracting the normalized symmetrical grayscale difference corresponding to the first vertical line from the first preset value. The crease suspicion index of the suspected crease area is obtained based on the aspect ratio of the smallest bounding rectangle of the suspected crease area and the degree of symmetry corresponding to the perpendicular line to the center line passing through each pixel on the center line. The step of obtaining the crease suspicion index of the suspected crease region based on the aspect ratio of the smallest bounding rectangle of the suspected crease region and the degree of symmetry corresponding to the perpendicular line from the center line passing through each pixel on the center line includes: The geometric parameters of a suspected crease region are obtained by dividing the length of the minimum bounding rectangle of the suspected crease region by the sum of the width of the minimum bounding rectangle and the scale parameter. The geometric parameters of the suspected crease region are normalized using the hyperbolic tangent function and multiplied by the mean of the degree of symmetry corresponding to the perpendicular line of each pixel on the center line of the minimum bounding rectangle of the suspected crease region to obtain the crease suspicion index of the suspected crease region.

2. The high-efficiency defect detection system for mass production of gift box packaging based on computer vision according to claim 1, characterized in that, The process of taking the gradient direction angle of each pixel modulo 180° to obtain the modulo-derived gradient direction angle includes: If the gradient direction angle of a pixel is less than or equal to 180°, then the gradient direction angle after taking the modulus of the pixel is the gradient direction angle of the pixel itself; if the gradient direction angle of the pixel is greater than 180°, then the gradient direction angle after taking the modulus of the pixel is the difference between the gradient direction angle of the pixel and 180°.

3. The high-efficiency defect detection system for mass production of gift box packaging based on computer vision according to claim 1, characterized in that, The step of obtaining a comprehensive anomaly index for a suspected crease region based on the crease suspicion index of a suspected crease region and the average of the directional consistency of all pixels within the suspected crease region includes: The comprehensive anomaly index of a suspected crease region is obtained by weighted summing the crease suspicion index of a suspected crease region and the mean of the orientation consistency of all pixels in the suspected crease region.

Citation Information

Patent Citations

  • Carton indentation quality detection method and system based on computer vision

    CN114549529A

  • Wrinkle state-analyzing method, and wrinkle state-analysing device

    JP2015062569A