Efficient flaw detection system for batch production of gift box packages based on computer vision
By using computer vision-based texture direction analysis and Sobel filter processing, combined with the crease suspicion index, we have achieved efficient and high-accuracy detection of minor creases and defects in gift box packaging, solving the problem of difficulty in identifying creases and defects in existing technologies.
Patent Information
- Application Number
- CN202511636175.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-10
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2045-11-10
AI Technical Summary
Existing computer vision-based gift box packaging defect detection systems struggle to effectively identify subtle creases and defects, especially when the texture of the corrugated paper surface interferes with detection, resulting in poor detection performance.
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 suspected crease region is obtained through threshold segmentation and morphological processing. The crease suspicion index and comprehensive anomaly index are combined to determine whether it is a crease defect region.
It improves the accuracy and efficiency of detecting crease defects, enabling precise identification of crease defects in mass production, reducing false detection and missed detection rates, and ensuring the quality of gift box packaging.
Smart Images

Figure CN121458692A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of gift box packaging appearance detection, and in particular to a high-efficiency defect detection system for batch production of gift box packaging based on computer vision. BACKGROUND
[0002] In the batch production process of gift box packaging, in order to realize the automatic quality control of the surface defects of the packaging, a defect detection system based on computer vision is generally used. At present, the mainstream and advanced method in this field is a detection method based on high-precision image template comparison. This method pre-acquires an image of a standard qualified product as a template, and compares and analyzes the differences between the image of the product to be detected and the template image at the pixel level on the detection line. The advantage of this method is that it realizes the rapid screening of obvious macro defects such as pits and large-area stains with significant differences from the template through automatic image subtraction and difference threshold judgment, and realizes the preliminary upgrade from manual inspection to automatic detection for the production of gift box packaging, which to some extent guarantees the quality of the products leaving the factory.
[0003] Since the crease defects form stress concentration points, they seriously weaken the structural strength of the packaging, and are extremely easy to cause the packaging to crack in subsequent handling and stacking, resulting in damage to the internal products. Although the template comparison method can detect obvious macro defects, it is not effective for identifying subtle crease defects. The reason is that such defects are not significant in terms of gray scale and shape, and at the same time, due to the structure of the paper box packaging material, which is usually corrugated (to increase the anti-deformation performance of the packaging box), there are concave-convex lines on the surface in the same direction under light, which further increases the difficulty of identifying crease defects. SUMMARY
[0004] In order to solve the above technical problems, the purpose of the present application is to provide a high-efficiency defect detection system for batch production of gift box packaging based on computer vision, and the technical solution adopted is as follows: An embodiment of the present application provides a high-efficiency defect detection system for batch production of gift box packaging based on computer vision, which comprises: A texture direction analysis module is used to acquire the surface image of the gift box packaging and pre-process it to obtain a surface gray scale image; and the direction consistency of each pixel point is obtained according to the difference between the gradient direction angle of each pixel point in the surface gray scale image and the main gradient direction angle of the surface gray scale image. A suspected crease area acquisition module is used to process each pixel point in the surface gray scale image by using different direction Sobel filters to obtain a linear feature saliency map; and the suspected crease area is obtained by threshold segmentation and morphological processing of the linear feature saliency map. The crease suspicion index acquisition module is configured to draw a perpendicular line of the center line through each pixel point of a minimum circumscribed rectangle of a suspected crease area, and acquire a crease suspicion index of the suspected crease area according to a difference between the gray scale values of the pixel points on the two sides of the center line with respect to the center line. The crease anomaly detection module is configured to acquire a comprehensive anomaly index of the suspected crease area according to the crease suspicion index of the suspected crease area and the average of the direction consistency of all pixel points in the suspected crease area, and determine whether the suspected crease area is a crease defect area according to the comprehensive anomaly index.
[0005] Preferably, the direction consistency of each pixel point is acquired according to a difference between a gradient direction angle of the pixel point and a main gradient direction angle of the surface gray scale image, and the method comprises the following steps. The gradient values of the pixel point in the x and y directions are calculated using a Sobel gradient operator; the gradient direction angle of the pixel point is acquired according to the gradient values of the pixel point in the x and y directions; the gradient direction angle of each pixel point is respectively taken modulo 180° to obtain a taken modulo gradient direction angle; 180° is divided into different angle intervals with 10° as an interval, and the number of taken modulo gradient direction angles of the pixel points of the surface gray scale image falling in each angle interval is acquired; the center value of the angle interval containing the largest number of taken modulo gradient direction angles is taken as the main gradient direction angle of the surface gray scale image; the difference between the taken modulo gradient direction angle of the pixel point and the main gradient direction angle of the surface gray scale image is calculated, and a mapping value is acquired by mapping two times of the difference using a cosine function; and the direction consistency of the pixel point is obtained by normalizing the mapping value.
[0006] Preferably, the gradient direction angle of each pixel point is respectively taken modulo 180° to obtain a taken modulo gradient direction angle, and the method comprises the following steps. If the gradient direction angle of the pixel point is less than or equal to 180°, the taken modulo gradient direction angle of the pixel point is the gradient direction angle itself; if the gradient direction angle of the pixel point is greater than 180°, the taken modulo gradient direction angle of the pixel point is the difference between the gradient direction angle and 180°.
[0007] Preferably, the linear feature saliency map is acquired by processing the pixel points of the surface gray scale image using Sobel filters of different directions, and the method comprises the following steps. The response values of the pixel points in each direction are acquired by processing the pixel points of the surface gray scale image using the Sobel filters of different directions; and the linear feature saliency map is obtained by retaining the response values of the pixel points in each direction.
[0008] Preferably, the crease suspicion index of the suspected crease region is obtained according to the difference between the gray scale values of the pixels on the vertical line of the center line of the minimum circumscribed rectangle of the suspected crease region on both sides of the center line, including: For a suspected crease region, a vertical line passing through a pixel point on the center line is recorded as a first vertical line, a preset number of pixel points on one side of the center line are sequentially taken on the first vertical line to form a first pixel point set, a preset number of pixel points on the other side of the center line are sequentially taken on the first vertical line to form a second pixel point set, and each two symmetric pixel points in the first pixel point set and the second pixel point set form different pixel point pairs; The ratio of the distance of a pixel point in a pixel point pair from the center line to half the number of pixel point pairs corresponding to the first vertical line is squared, and the squared result is negatively correlated mapped using an exponential function with a natural constant as the base to obtain the weight of the pixel point pair; The absolute values of the difference between the gray scale values of the two pixel points in each pixel point pair are weighted and summed to obtain the symmetric gray scale difference corresponding to the first vertical line, the sum of the gray scale values of the two pixel points in each pixel point pair is weighted and summed to obtain the symmetric gray scale sum corresponding to the first vertical line, and the symmetric gray scale difference corresponding to the first vertical line is divided by the symmetric gray scale sum corresponding to the first vertical line to obtain the normalized symmetric gray scale difference corresponding to the first vertical line. The first preset value is subtracted from the normalized symmetric gray scale difference corresponding to the first vertical line to obtain the symmetry degree corresponding to the first vertical line; The crease suspicion index of the suspected crease region is obtained according to the aspect ratio of the minimum circumscribed rectangle of the suspected crease region and the symmetry degree corresponding to the vertical line of the center line passing through each pixel point on the center line.
[0009] Preferably, the crease suspicion index of the suspected crease region is obtained according to the aspect ratio of the minimum circumscribed rectangle of the suspected crease region and the symmetry degree corresponding to the vertical line of the center line passing through each pixel point on the center line, including: The sum of the length ratio of the minimum circumscribed rectangle of a suspected crease region to the minimum circumscribed rectangle width and a scale parameter is obtained to obtain the geometric shape parameter of the suspected crease region. The geometric shape parameter of the suspected crease region is normalized using a hyperbolic tangent function and multiplied by the mean of the symmetry degrees corresponding to the vertical lines of the center line of the minimum circumscribed rectangle of the suspected crease region to obtain the crease suspicion index of the suspected crease region.
[0010] Preferably, the comprehensive anomaly index of a suspected crease region is obtained according to the crease suspicion index of the suspected crease region and the mean of the direction consistency of all pixel points in the suspected crease region, including: The crease suspicion index of a suspected crease area and the average of the direction consistency of all pixel points in the suspected crease area are weighted and summed to obtain a comprehensive abnormality index of the suspected crease area.
[0011] The embodiment of the present application has at least the following beneficial effects: the surface image of the gift box packaging is collected and preprocessed to obtain a surface gray image; the direction consistency of each pixel point is obtained according to the difference between the gradient direction angle of each pixel point in the surface gray image and the main gradient direction angle of the surface gray image, and the main direction of the overall texture of the corrugated paper is analyzed, so that the difference between the crease and the normal paper surface texture is analyzed from the directionality of the texture change, thereby improving the accuracy of the crease defect; Further, the Sobel filter of different directions is used to process each pixel point in the surface gray image to obtain a linear feature saliency map; the suspected crease area is obtained by threshold segmentation and morphological processing on the linear feature saliency map; the perpendicular line of the center line of the minimum circumscribed rectangle of a suspected crease area is drawn through each pixel point on the center line, the crease suspicion index of the suspected crease area is obtained according to the difference between the gray values of the pixel points on the two sides of the center line with respect to the center line of the center line, and finally the comprehensive abnormality index of each suspected crease area is obtained by combining the direction consistency of each pixel point, so as to determine whether the suspected crease area is a crease defect area by using the comprehensive abnormality index, thereby accurately locking the real crease while excluding the texture interference, and realizing efficient and high-accuracy detection of the crease in batch production. BRIEF DESCRIPTION OF DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, and the advantages thereof, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.
[0013] Figure 1 A system block diagram of a gift box packaging batch production defect efficient detection system based on computer vision provided by the embodiment of the present application is provided. Figure 2 A crease schematic diagram of a gift box packaging batch production defect efficient detection system based on computer vision provided by the embodiment of the present application is provided. DETAILED DESCRIPTION
[0014] In order to further illustrate the technical means and effects taken by the present application to achieve the predetermined object, the specific implementation, structure, features and effects of a computer vision-based high-efficiency defect detection system for batch production of gift box packaging according to the present application are described in detail as follows in combination with the drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures or characteristics in one or more embodiments can be combined in any suitable form.
[0015] 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 the present application belongs.
[0016] The specific scheme of the computer vision-based high-efficiency defect detection system for batch production of gift box packaging provided by the present application is described in detail below in combination with the drawings.
[0017] In an embodiment, the main application scenario of the present application is that the present application detects the crease defects of the outer packaging box of the gift box and improves the qualified rate of the gift box packaging.
[0018] Please refer to Figure 1 which shows a system block diagram of the computer vision-based high-efficiency defect detection system for batch production of gift box packaging provided by the embodiment of the present application. The system includes the following modules: The texture direction analysis module is used to collect the surface image of the gift box packaging and obtain the surface gray image through preprocessing; and the direction consistency of each pixel point is obtained according to the difference between the gradient direction angle of each pixel point in the surface gray image and the main gradient direction angle of the surface gray image.
[0019] The data preparation stage of the whole defect detection process of image acquisition aims to collect the surface image of the gift box packaging from the complex production environment by using mature machine vision technology, and eliminate interference such as uneven illumination and noise through a series of standardized preprocessing operations, and output a high-quality and standardized gray image. The industrial site environment is complex, and factors such as light changes and equipment vibrations will directly cause problems such as noise, uneven brightness and blur in the collected image. If such original image is directly input into the subsequent detection algorithm, it will seriously interfere with the feature extraction and judgment, resulting in high false detection and missed detection rates. Therefore, a standardized preprocessing process must be used to lay a reliable data foundation for subsequent analysis. Here, a series of classic image processing techniques that have been verified by industry are used to purify and enhance the original image, and convert it into a standardized image that only contains information of the gift box surface itself and excludes external interference as much as possible. In order to accurately identify and classify the crease defects, high-quality and standardized input data are provided, and the accuracy and stability of the detection results of the whole system are ensured.
[0020] Specifically, the normalized image acquisition: a stable image acquisition station is constructed above the production line conveyor belt. Deploy fixed high-resolution industrial cameras, and equip with evenly distributed light sources to ensure uniform illumination of the surface of the gift box. The camera is linked with the production line control system, and when each gift box package arrives at the detection station, it is triggered by a photoelectric sensor to automatically collect the surface image of the gift box package, that is, a high-definition color image, and simultaneously record product number, timestamp and other metadata.
[0021] Image preprocessing: first grayscale, convert the surface image of the colored gift box package to a grayscale image, reduce the data volume and improve the processing speed. Then, noise suppression is performed, and Gaussian filtering or median filtering (selected according to the noise type) is used to smooth the image, effectively suppressing the random noise introduced by the image sensor.
[0022] Image enhancement: use the limited contrast adaptive histogram equalization algorithm to enhance the overall contrast of the grayscale image, making the surface texture of the corrugated paper and potential defects more clear, while avoiding over amplifying noise, thereby obtaining the surface grayscale image.
[0023] Establish a preprocessed image library: associate the surface grayscale image obtained after preprocessing with its corresponding metadata (product number, timestamp, etc.), and store it in the database in a structured form to form an image library for subsequent operations.
[0024] After obtaining the image library, it contains rich image information, because the corrugated paper used as the raw material for the gift box production has one-way texture on its surface, and each paper surface texture is different. They are normal paper features, but the existing template matching detection method often misreports and misses the similar defects (such as small creases).
[0025] Therefore, it is necessary to analyze the physical nature of the paper and the crease. First, the surface texture of the paper has very strong directional consistency on a macro level. By analyzing the directional consistency of the texture, the directional consistency coefficient is obtained, which measures the degree of similarity between the current region and the normal texture. Although the texture of each gift box material surface is different, it shows strong and consistent directionality on a macro level. By calculating the directional consistency, the degree to which any region in the image "looks like normal texture" can be measured, outputting a "directional consistency map" corresponding to the original image, thereby providing a key basis for distinguishing between true and false defects.
[0026] The directional consistency of each pixel point is obtained according to the difference between the gradient direction angle of each pixel point in the surface grayscale image and the main gradient direction angle of the surface grayscale image.
[0027] Specifically, the Sobel gradient operator is used to calculate the gradient values of a pixel in the surface gray image in x and y directions; the gradient direction angle of the pixel is obtained according to the gradient values of the pixel in x and y directions; the gradient direction angle of each pixel is respectively taken modulo 180° to obtain the modulo gradient direction angle; 180° is divided into intervals with 10° as an interval to obtain different angle intervals, and the number of the modulo gradient direction angles of the pixels in the surface gray image falling in each angle interval is obtained, and the center value of the angle interval containing the most modulo gradient direction angles is taken as the main gradient direction angle of the surface gray image; the difference between the modulo gradient direction angle of a pixel and the main gradient direction angle of the surface gray image is calculated, and the mapping value is obtained by mapping twice the difference using the cosine function, and the direction consistency of the pixel is obtained by normalizing the mapping value.
[0028] The calculation model of the direction consistency is specifically: , wherein C represents the direction consistency of a pixel; θ represents the modulo gradient direction angle of a pixel, and the calculation formula of the gradient direction angle is , respectively represent the gradient values of a pixel in x and y directions, the direction with the most drastic change at each pixel is calculated, and the modulo gradient direction angle is obtained by folding the two angles of the same line together, so as to fold the gradient direction angle into the range of 0° to 180°, thereby eliminating the periodic ambiguity of the direction angle, and the obtaining manner is specifically: if the gradient direction angle of a pixel is less than or equal to 180°, the modulo gradient direction angle of the pixel is the gradient direction angle itself; if the gradient direction angle of the pixel is greater than 180°, the modulo gradient direction angle of the pixel is the difference between the gradient direction angle of the pixel and 180°, for example, 0° and 180° represent the same line, only the directions are opposite, if the angle less than 180° is 30°, the angle is directly 30°, if the angle greater than 180° is 200°, the modulo is 20° after subtracting 180°; is the main gradient direction angle of the surface gray image, which represents the global texture main direction, and the angle difference is doubled because the direction angle is periodic (for example, 0° and 180° represent the same line), and using double angles can eliminate this ambiguity and ensure that the difference between 0° and 180° is consistent after calculation (both tend to 1); The cos calculation of the cosine is to map the 2 times of the angle difference to the consistency score. When the local direction is completely consistent or completely opposite to the main direction, the angle difference is 0° or 180°, and after doubling, it is 0° or 360°, and the cosine value is 1, indicating the highest consistency. When the local direction is perpendicular to the main direction (difference 90°), after doubling, it is 180°, and the cosine value is -1, indicating the lowest consistency; because the value range of the cosine is ultimately [-1, 1], it is not suitable as a score standard, and by The entire score is normalized, and finally the fitting score of each pixel to the main direction is obtained, that is, the direction consistency of the pixel point.
[0029] Thus the direction consistency of each pixel point in the surface gray image can be obtained.
[0030] The suspected crease area acquisition module is used to process each pixel point in the surface gray image by using different direction Sobel filters to obtain a linear feature saliency map; the linear feature saliency map is threshold segmented and morphologically processed to obtain a suspected crease area.
[0031] In the above analysis process, the fitting score (direction consistency) of each pixel point to the main direction is obtained through the calculation and analysis of the direction consistency. These scores can effectively measure the direction of the normal texture, but they can only reflect the deviation of the direction of each region from the normal direction macroscopically, and the direction consistency alone cannot be used as the basis for crease defect detection. Therefore, features associated with the depth of the defect are extracted from the image data, and an index that can quantify the crease defect condition is constructed for crease detection.
[0032] To achieve a balance between efficiency and accuracy, a two-level processing strategy of "from coarse to fine" is adopted. The technical basis is that: although the crease defect is similar to the texture background, it will show specific and quantifiable physical characteristics. First, quickly locate all suspected crease areas, and then conduct in-depth, multi-dimensional and three-dimensional measurement.
[0033] A crease appears as a "dark line" or "bright line" in an image, and its core feature is that the gray value will change dramatically (i.e., the gradient is large) in the direction perpendicular to its direction. However, the direction of the crease of the gift box on the production line is random, so different direction Sobel filters are used to process the surface gray image, such as setting a group of Sobel filters to 0°, 45°, 90° and 135° Sobel filters to process the surface gray image.
[0034] Then, the linear feature saliency map is obtained by processing each pixel point in the surface gray image using different direction Sobel filters. Specifically, the response value of each pixel point in each direction is obtained by processing each pixel point in the surface gray image using the Sobel filter in each direction, and the linear feature saliency map is obtained by retaining the response value of each pixel point in each direction.
[0035] For a pixel point, if it is a point on the crease, the response value in the direction that can maximize its gradient will be much higher than that in other directions. The essence of processing each pixel point in the surface gray image using different direction Sobel filters is to calculate the change rate and direction of the pixel gray value in a small region (i.e. the region covered by the filter kernel) around the pixel point in a specific direction. The value output after convolution calculation is the "response value" of the pixel point in this specific filter direction. If it is only texture or noise, the response in each direction may be weak, or no direction is particularly prominent. Therefore, for each pixel point, the maximum value of the "response value" corresponding to all direction filters is taken. The pixel points of the crease will all be retained because there is a direction with a strong response, and the texture gradient change is usually more gentle and more continuous than the real crease, so the "maximum response value" is relatively low. The noise is isolated and has no directionality, so the maximum response value is also low. Finally, a linear feature saliency map is obtained, in which the crease is enhanced and the background texture and noise are relatively suppressed. A gray image is generated, the background is black, and the area like the crease is white or gray. The brightness value of each pixel in the image represents the possibility of the presence of linear features, regardless of direction. The area where the crease is located will appear as bright lines in the image.
[0036] Finally, the obtained linear feature saliency map is threshold segmented, and Otsu algorithm is used for threshold segmentation (an adaptive threshold can be obtained), which calculates an optimal threshold for the entire image or different regions of the image, and binarizes the pixels. The white color is the suspected crease area, and the black color is the background, to obtain a binary suspected crease area mask image, in which the white part is the preliminary extracted all possible creases and linear interferences.
[0037] Further, morphological closing operation (using a linear structure element, the operation of first expanding and then eroding the binary image is performed to connect the broken white areas) is performed on the suspected crease area mask image to obtain the suspected crease area. It should be noted that the image processing operation is a known technology and will not be described in detail here.
[0038] The crease suspicion index acquisition module is configured to draw a vertical line of the center line through each pixel point on the center line of the minimum circumscribed rectangle of a suspected crease area, and acquire a crease suspicion index of the suspected crease area according to a difference between the gray scale values of the pixel points on the vertical line on both sides of the center line.
[0039] Because the characteristics of the crease are weak and irregular, the detection of the crease must be realized through multi-level feature fusion. The physical characteristics of the crease are embodied in a high aspect ratio (standard feature), and the macroscopic gray scale change on both sides of the crease is symmetrical (key macro feature). Through mutual verification of complementary features, a high-robustness and high-specificity crease suspicion index is formed, and then the crease defect is detected to ensure the accuracy of the detection.
[0040] For a suspected crease area, the complementary features thereof, i.e., geometric morphology and gray scale symmetry, are extracted. The crease satisfies both of the features, and the crease suspicion index is obtained by synthesizing the features. The crease suspicion index is used to judge the defect condition of the suspected crease area.
[0041] The suspected crease area in the linear feature saliency map is mapped to the surface gray scale image, and the suspected crease area in the surface gray scale image is further analyzed.
[0042] Specifically, a minimum circumscribed rectangle of each suspected crease area is acquired, a center line of the minimum circumscribed rectangle is acquired, and a vertical line of the center line is drawn through each pixel point on the center line of the minimum circumscribed rectangle of the suspected crease area.
[0043] For a suspected crease area, a vertical line through a pixel point on the center line is denoted as a first vertical line, a preset number of pixel points on one side of the center line on the first vertical line are sequentially taken to form a first pixel point set, a preset number of pixel points on the other side of the center line on the first vertical line are sequentially taken to form a second pixel point set, and each two symmetrical pixel points in the first pixel point set and the second pixel point set form different pixel point pairs. The ratio of the distance of a pixel point in a pixel point pair to the center line to half of the number of pixel point pairs corresponding to the first vertical line is squared, and the squared result is negatively related mapped by using an exponential function with a natural constant as a base to obtain a weight of the pixel point pair. The absolute value of the difference between the gray values of the two pixels in each pixel pair is weighted and summed to obtain a symmetric gray difference corresponding to the first vertical line using the weight of each pixel pair; the sum of the gray values of the two pixels in each pixel pair is weighted and summed to obtain a symmetric gray sum corresponding to the first vertical line using the weight of each pixel pair; the normalized symmetric gray difference corresponding to the first vertical line is obtained by using the symmetric gray difference corresponding to the first vertical line; the symmetric degree corresponding to the first vertical line is obtained by subtracting the normalized symmetric gray difference corresponding to the first vertical line from the first preset value. According to the aspect ratio of the minimum circumscribed rectangle of the suspected crease region and the symmetry degree corresponding to the vertical line passing through each pixel point on the center line, the crease suspicion index of the suspected crease region is obtained.
[0044] Specifically, the sum of the length ratio of the minimum circumscribed rectangle of a suspected crease region to the minimum circumscribed rectangle width and the scale parameter is obtained to obtain the geometric shape parameter of the suspected crease region; the geometric shape parameter of the suspected crease region is normalized by using the hyperbolic tangent function, and multiplied by the average of the symmetry degree corresponding to the vertical line passing through each pixel point on the center line of the minimum circumscribed rectangle of the suspected crease region to obtain the crease suspicion index of the suspected crease region.
[0045] The calculation model of the symmetry degree is specifically: , wherein DC represents the symmetry degree corresponding to the vertical line passing through a pixel point on the center line of the minimum circumscribed rectangle of a suspected crease region; 1 is the first preset value; exp is the exponential function with the natural constant as the base; r represents the number of pixel pairs corresponding to the vertical line, that is, the number of pixel points on one side of the center line taken on the vertical line, that is, the preset number, the value of the preset number is 25% of the width of the minimum circumscribed rectangle and is rounded up to obtain, wherein the length of the length and the width of the minimum circumscribed rectangle is measured in the number of pixel points, as shown in Figure 2 The white pixels in the figure are the suspected crease region, the black pixels are the normal region, the black and white circles represent the pixel points, the rectangular box in the figure is the minimum circumscribed rectangle of a suspected crease region, the row of white pixels marked as 1 in the figure is the center line of the minimum circumscribed rectangle, the pixels marked as 2 and 3 are two pixels symmetric about the center line, forming a pixel pair, the pixels marked as 4 and 5 also form a pixel pair, the width of the minimum circumscribed rectangle is 5 pixel points, and the length is 11 pixel points, that is, the width is 5, so the value of r is 2; represents the distance of the i-th pixel pair in the pixel pair corresponding to the vertical line from the center line, wherein the distance of the two pixels from the center line is the same, The weight of the i-th pixel pair is a function of the modified Gaussian weight formula, which modifies the decay term (original formula in the parentheses) in the original Gaussian weight formula to be exponentially increasing with the increase of , and the decay rate is determined by , which means that the closer the pixel is to the center of the crease, the higher its value and the greater its weight. and represent the gray values of one pixel and the other pixel in the i-th pixel pair, respectively. is the absolute value of the difference between the gray values of the two pixels, which quantifies the absolute difference in symmetry position gray value and reflects the degree of asymmetry of the pixel pair (if the difference is 0, it is completely symmetrical). is the symmetry gray difference corresponding to the vertical line, and the greater it is, the lower the symmetry of the gray values on both sides. is the symmetry gray sum corresponding to the vertical line, and it is compared to normalize the symmetry gray difference. The greater the value of , the higher the symmetry of the gray values of the pixels on both sides of the center line on the vertical line, i.e., the greater the symmetry degree corresponding to the vertical line.
[0046] The calculation model of the crease suspicion index of a crease region is as follows: , 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 appears, it gradually approaches 1 and can be adjusted by the scale parameter k to adjust the saturation speed, which meets the change process when the ratio is greater than 0. The minimum bounding rectangle extracted from the suspected region is obtained, and its aspect ratio is calculated. The greater the ratio, the closer the function value to 1. The scale parameter k is the average of the aspect ratios of the minimum bounding rectangles of historical creases. is a geometric morphological parameter. Figure 2 N is the length of the center line, , and the value of N is 11, which can also be said to be the number of vertical lines of the center line passing through the pixels on the center line.
[0047] The crease suspicion index of each suspected crease region can be obtained in this way.
[0048] The crease abnormality detection module is configured to obtain a comprehensive abnormality index of a suspected crease region according to a crease suspicion index of the suspected crease region and a mean value of direction consistency of all pixel points in the suspected crease region; and determine whether the suspected crease region is a crease defect region according to the comprehensive abnormality index.
[0049] A suspected crease region has a high crease suspicion index, but if its direction is highly consistent with the background texture, 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, the direction consistency of the texture layer is obtained as a supplement, and the crease suspicion index is weighted and fused, which can solve this problem, effectively suppress false defects, and highlight real defects.
[0050] The crease suspicion index of a suspected crease region and the mean value of direction consistency of all pixel points in the suspected crease region are weighted and summed to obtain a comprehensive abnormality index of the suspected crease region.
[0051] Because the surface texture (direction consistency) is used as an enhancement of the crease suspicion index, the mean value of the direction consistency is given a small weight (which can be set according to the actual texture of the gift box, and the higher the weight, the greater the influence of the feature on the comprehensive score), and the crease suspicion index is given a large weight. The reference value of the weight parameter of the mean value of the direction consistency of all pixel points in the suspected crease region is 0.4, and the reference value of the weight parameter of the crease suspicion index is 0.6. The weight parameters can be optimized according to the actual detection results.
[0052] Further, the surface gray scale images of the qualified gift box packages in history are analyzed to obtain the comprehensive abnormality indexes of the suspected crease regions therein, and the 99th percentile thereof is taken as a judgment threshold. If the comprehensive abnormality index of a suspected crease region in the surface gray scale image of the gift box package to be detected is greater than the judgment threshold, the suspected crease region is a crease defect region, and the gift box package to be detected is unqualified. If it is unqualified, the crease defect region is marked red and flows to the unqualified region for subsequent tracing operation, and if it is qualified, it is normally sent to the designated position. After completing the detection of each batch, the data of the unqualified gift box packages are generated as a report for subsequent analysis.
[0053] It should be noted that the above-mentioned embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of the present application. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing are also possible or can be advantageous.
[0054] The various embodiments in the specification are described in progressive manner, and the same or similar parts between the various embodiments can be mutually referred to, and each embodiment focuses on the difference from other embodiments.
[0055] The above description is merely preferred embodiments of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
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 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.
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 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.
3. The high-efficiency defect detection system for mass production of gift box packaging based on computer vision according to claim 2, 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°.
4. 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 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 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.
5. 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 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 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.
6. The high-efficiency defect detection system for mass production of gift box packaging based on computer vision according to claim 5, characterized in that, 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.
7. 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 the 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
Industrial article appearance detection method and system based on machine vision
CN119672020A
Circuit board microsection image defect detection method
CN120635071A
Method and system for detecting quality of PET (Polyethylene Terephthalate) protective film prime coating process
CN120894304A
Analytical method and device for wrinkles
JP2015042199A
Cited By
Instant noodle boxing positioning method and system based on machine vision
CN121767452A
