Method for intelligent detection and grading determination of pre-made bag packaging defect images

By combining fuzzy membership functions and multi-factor comprehensive analysis models with defect location information, the problem of the combined effect of location and geometric features in the defect detection of prefabricated bag packaging was solved, achieving more accurate defect classification and risk assessment, and improving the reliability of quality assessment.

CN121884010BActive Publication Date: 2026-07-03HEFEI YONGJIANG AUTOMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HEFEI YONGJIANG AUTOMATION TECH CO LTD
Filing Date
2026-03-19
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing methods for detecting and classifying defects in prefabricated bag packaging fail to fully consider the combined effects of defect location and geometric features, resulting in a mismatch between classification results and actual risks. Furthermore, under complex working conditions, there are interactive effects between defect features, making it difficult to achieve accurate quality assessment.

Method used

Fuzzy membership functions are used to process defect features continuously. Combining defect location information with the spatial relationship between the load-bearing area of ​​the prefabricated bag packaging, a comprehensive risk probability distribution of defects is generated through a multi-factor comprehensive analysis model. Evidence theory and expert knowledge base rules are introduced for decision fusion, and the defect area weight is dynamically adjusted to reduce the uncertainty of the grading results.

Benefits of technology

It enables more objective, accurate, and stable intelligent detection and grading of defects in prefabricated bag packaging, improves the reliability of quality assessment, reduces the risk of misjudgment and omission, and provides defect level assessment that is more in line with actual risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121884010B_ABST
    Figure CN121884010B_ABST
Patent Text Reader

Abstract

This invention discloses an intelligent detection and classification method for defects in prefabricated bag packaging images, relating to the fields of machine vision and intelligent quality inspection technology. The method includes acquiring defect images of prefabricated bag packaging and extracting the geometric features and location information of the defects based on the defect images. Fuzzy membership functions are introduced into the various features of the defects for continuous processing. When a defect feature falls within a preset threshold range for adjacent defect levels, the membership weights of the feature belonging to at least two defect levels are calculated. This intelligent detection and classification method for prefabricated bag packaging defects enables more objective, accurate, and stable intelligent detection and classification of defects in prefabricated bag packaging, improving the reliability of quality assessment, reducing the risk of misjudgment and omission, and providing effective support for the quality control and risk management of prefabricated bag packaging products.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision and intelligent quality inspection technology, specifically to a method for intelligent detection and grading of defective images in prefabricated bag packaging. Background Technology

[0002] In the production and quality inspection of prefabricated bag packaging, the detection and classification of packaging defects are crucial steps affecting product sealing performance, transportation safety, and reliability. During the forming, filling, and sealing processes, prefabricated bag packaging is prone to various defects due to factors such as fluctuations in material properties, unstable heat-sealing parameters, or mechanical positioning deviations. These defects may include incomplete seals, localized damage, concentrated wrinkles, or micro-cracks. If these defects are not accurately identified and properly classified, they may lead to quality risks such as leakage and bag breakage during subsequent storage, transportation, or use.

[0003] Existing methods for detecting and classifying defects in prefabricated bag packaging often rely on fixed thresholds based on defect size or a single geometric indicator. For example, a defect is classified as a serious defect if its length or area exceeds a preset threshold, and as a minor defect if it falls below. However, in actual testing, many defect features fall within the critical range of different threshold levels. Using such rigid threshold methods can easily lead to abrupt changes in defect levels due to minor differences in features, resulting in a mismatch between the classification results and the actual impact of the defect on the packaging's safety, thus affecting the accuracy of quality assessment. Furthermore, the risk level of prefabricated bag packaging defects is not only related to their geometric features but also closely related to their specific location within the packaging structure. For example, defects located in sealing or load-bearing areas, even if small, can significantly impact the packaging's sealing and load-bearing capacity; while defects located in non-critical areas have a relatively lower actual risk. Existing technologies typically do not fully consider the combined effect of defect location and geometric features, instead treating various defect features independently, making it difficult to reflect the differentiated contributions of different features in defect classification. Furthermore, under complex operating conditions, various characteristics of prefabricated bag packaging defects often interact, and the indications of different characteristics regarding defect levels may be inconsistent or conflicting. For example, a defect may be close to the severe defect threshold in terms of area, but its location may not be within a load-bearing area, meaning its actual risk level falls between moderate and severe defects. The non-linear relationship between defect characteristics and risk levels, as well as the ambiguity of the boundaries between different levels, makes grading methods based on single rules or static standards difficult to adapt to the actual needs of prefabricated bag packaging defect detection. Summary of the Invention

[0004] The purpose of this invention is to provide an intelligent detection and grading method for defects in prefabricated bag packaging images, thereby solving the problems existing in the prior art.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for intelligent detection and grading of defects in prefabricated bag packaging images, comprising the following steps:

[0006] S1. Obtain defect images of prefabricated bag packaging, and extract geometric features and location information of defects in prefabricated bag packaging based on the defect images;

[0007] S2. Introduce fuzzy membership functions to the various features of the defect for continuous processing. When the defect features are within the preset threshold range of adjacent defect levels, calculate the membership weights of each feature belonging to at least two defect levels.

[0008] S3. Based on the spatial relationship between the defect location information and the load-bearing area of ​​the pre-made bag packaging, the weight coefficient corresponding to the defect area is dynamically adjusted. When the defect is located in a non-load-bearing area, the membership contribution of the defect area feature in the defect classification is reduced.

[0009] S4. Through a multi-factor comprehensive analysis model, the geometric features, location weights, and membership results corresponding to the defect distribution density are fused and calculated to generate a comprehensive risk probability distribution of pre-made bag packaging defects.

[0010] S5. Determine the distribution trend of the comprehensive risk probability within the preset fuzzy interval. When the comprehensive risk probability simultaneously covers the membership peaks of both moderate and severe defects, mark the corresponding defect sample as a sample to be reviewed and output the corresponding risk probability distribution curve.

[0011] As can be seen from the above technical solution, the present invention has the following beneficial effects:

[0012] (1) The intelligent detection and classification method for defects in prefabricated bag packaging extracts the geometric features and location information of defects based on the defect images of prefabricated bag packaging, introduces a fuzzy membership function to process the defect features continuously, avoids the abrupt change problem at the level boundary of the traditional fixed threshold classification method, and makes the defect level judgment more in line with the gradual change law of actual risk. At the same time, by combining the spatial position relationship of defects in the sealing area or load-bearing area of ​​prefabricated bag packaging, the weight of features such as defect area is dynamically adjusted, which effectively reflects the difference in the degree of influence of defects in different locations on the sealing performance and load-bearing capacity of packaging.

[0013] (2) By integrating defect geometric features, location weights, and distribution density information using a multi-factor comprehensive analysis model, a comprehensive risk probability distribution of defects is generated. When there is ambiguity in the level or conflict in features, decision fusion based on evidence theory and expert knowledge base rules are introduced to resolve the issue, thereby reducing the uncertainty and dispersion of defect grading results. Through the above technical means, this invention can achieve more objective, accurate, and stable intelligent detection and grading of defects in prefabricated bag packaging, improve the reliability of quality assessment, reduce the risk of misjudgment and omission, and provide effective support for the quality control and risk management of prefabricated bag packaging products. Attached Figure Description

[0014] Figure 1 This is a flowchart of the intelligent detection and grading method for defects in prefabricated bag packaging according to the present invention. Detailed Implementation

[0015] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0016] Example 1:

[0017] like Figure 1 As shown, the present invention provides a technical solution: a method for intelligent detection and grading of defects in prefabricated bag packaging images, comprising the following steps:

[0018] S1. Obtain defect images of prefabricated bag packaging, and extract geometric features and location information of defects in prefabricated bag packaging based on the defect images;

[0019] S2. Introduce fuzzy membership functions to the various features of the defect for continuous processing. When the defect features are within the preset threshold range of adjacent defect levels, calculate the membership weights of each feature belonging to at least two defect levels.

[0020] S3. Based on the spatial relationship between the defect location information and the load-bearing area of ​​the pre-made bag packaging, the weight coefficient corresponding to the defect area is dynamically adjusted. When the defect is located in a non-load-bearing area, the membership contribution of the defect area feature in the defect classification is reduced.

[0021] S4. Through a multi-factor comprehensive analysis model, the geometric features, location weights, and membership results corresponding to the defect distribution density are fused and calculated to generate a comprehensive risk probability distribution of pre-made bag packaging defects.

[0022] S5. Determine the distribution trend of the comprehensive risk probability within the preset fuzzy interval. When the comprehensive risk probability simultaneously covers the membership peaks of both moderate and severe defects, mark the corresponding defect sample as a sample to be reviewed and output the corresponding risk probability distribution curve.

[0023] S6. Using a decision fusion method based on evidence theory, the conflict of multiple defect features of the sample to be reviewed is resolved. When there is a conflict between the membership degree of the defect area feature and the membership degree of the position weight, the preset expert knowledge base rules are triggered to make inference judgment.

[0024] S7. Update the prefabricated bag packaging defect level label library based on the resolution results, generate a defect level mapping table with transition interval identifiers, and output the final prefabricated bag packaging defect risk level and its confidence assessment results.

[0025] In the above implementation, the method uses a defect image of the pre-made bag packaging as the basic input, and obtains the area, length, shape complexity, and spatial location information of the defect within the overall packaging through image processing and feature extraction techniques. To address the problem of misjudgment of boundary samples caused by rigid thresholds in traditional defect grading, a fuzzy membership function is introduced to continuously map defect features, allowing defect features to express their belonging relationships among multiple defect levels in the form of weights.

[0026] Furthermore, by using a pre-constructed load-bearing area model of prefabricated bag packaging, the spatial location information of defects is matched and analyzed with the load-bearing areas. When a defect is located in a non-load-bearing area, the weighting coefficient of the defect area feature is reduced to weaken its impact on the overall risk assessment, thus better aligning with the actual stress failure mechanism of packaging.

[0027] Based on this, a multi-factor comprehensive analysis model is adopted to fuse and calculate the membership results corresponding to the defect's geometric features, location weights, and distribution density per unit area, outputting the comprehensive risk probability distribution of the defect at each level. When the comprehensive risk probability exhibits a multi-peak or overlapping trend within the fuzzy interval, the defect sample is determined to have level uncertainty. For such samples, a decision fusion method based on evidence theory is introduced to weight and combine the evidence formed by different defect features. When there is a conflict between the membership results corresponding to the defect area features and location weights, reasoning and judgment are performed by calling preset rules in the expert knowledge base to obtain a defect level conclusion that is more in line with engineering experience, and the defect classification results are updated accordingly.

[0028] In the above implementation, by introducing a fuzzy membership function to replace the traditional rigid threshold determination method, the defect features achieve a continuous transition between adjacent levels, effectively reducing the probability of misclassification caused by threshold thresholds. Combining the spatial relationship between defect location information and the load-bearing area, the defect area weight is dynamically adjusted, making the classification results more consistent with the actual failure risk distribution of prefabricated bag packaging. A comprehensive risk probability distribution is generated through a multi-factor comprehensive analysis model, and samples within the fuzzy interval are individually labeled and processed, improving the reliability of identifying complex, boundary-type defects. Evidence theory and expert knowledge base rules are introduced to resolve conflicts, making the system more robust and interpretable when facing contradictory information with multiple features.

[0029] Furthermore, by generating a defect classification mapping table with transition interval identifiers, not only are clear defect risk levels output, but confidence assessment results are also provided simultaneously, which is beneficial for production line quality control decisions, the rational allocation of manual review resources, and the continuous optimization of the subsequent defect sample library.

[0030] Specifically, S1 includes capturing images of pre-made bag packaging with a camera to obtain defect images of the pre-made bag packaging. The geometric features in S1 include defect length, defect area, and defect distribution density. For the defect image, Gaussian filtering is used to remove noise, resulting in a denoised defect image. Gaussian filtering smooths pixel values ​​through convolution operations to eliminate interference. Defect regions are extracted from the denoised defect image using a threshold segmentation method to determine the defect length and defect area of ​​the defect region. The defect length is obtained by measuring the boundary pixel distance, and the defect area is obtained by counting the number of pixels within the region. Based on the position of the defect region relative to the sealing region or the load-bearing region, the defect distribution density is determined, and position information is marked. The sealing region is the heat-sealed edge of the pre-made bag packaging, and the load-bearing region is the load-bearing support part of the pre-made bag packaging. The defect distribution density is obtained by calculating the number of pixels within the counting region per unit area.

[0031] In this embodiment, an industrial camera is first fixedly installed at the imaging station of the prefabricated bag packaging, ensuring the camera's optical axis is perpendicular to the packaging plane and maintains a fixed working distance. By calibrating the outer boundary of prefabricated bags of the same specification on the production line, a fixed pixel coordinate range of the effective packaging area in the image is determined. The camera's resolution, exposure time, gain, and shutter speed are set to fixed values ​​to ensure stable grayscale for each frame. Subsequently, a frame of the prefabricated bag packaging image is acquired each time shooting is triggered, and the aforementioned fixed pixel coordinate range is extracted from this image as the defect image input. When performing Gaussian filtering noise reduction on the defect image, a background area without printed text and defects is first selected as the noise evaluation area. The fluctuation range of the grayscale value of this background area is calculated as the noise level, and the standard deviation of the Gaussian kernel is determined to be the same value as this noise level. Simultaneously, the side length of the convolution window is determined to be 6 times the corresponding standard deviation. Rounding up to the nearest odd number, the convolution window is then slid across the defect image pixel by pixel. For each pixel, all pixel values ​​within its neighborhood window are multiplied by Gaussian weights, summed, and normalized to obtain a denoised defect image. This process eliminates random noise and local illumination jitter by smoothing pixel values. When extracting defect regions through threshold segmentation, a grayscale histogram is first generated by counting the number of pixels with each grayscale value from 0 to 255 in the denoised defect image. Then, for each candidate threshold, pixels are sequentially divided into a background group and a foreground group. The pixel percentage and grayscale mean of each group are calculated, and the separability between the two groups is calculated accordingly. Finally, the candidate threshold with the highest separability is selected as the segmentation threshold. Subsequently, pixels with grayscale values ​​below or above the threshold in the denoised defect image are uniformly identified as defect pixels, and a binarized defect region image is generated. The connectivity of the binarized result is then determined, and a set of interconnected defect pixels is defined as a defect region.

[0032] The defect length is calculated as follows: For each defect region, scan the binary boundary along the row and column directions to find the boundary pixel set formed by the adjacent defect pixels and non-defect pixels. Then, calculate the distance between any two pixels in the boundary pixel set and take the maximum value as the pixel value of the defect length. Then, use the pixel size obtained from camera calibration to convert the pixel value into the actual length. The pixel size is calculated by placing a ruler of known length on the imaging plane and measuring its pixel span in the image, and it remains fixed under the same specifications and installation conditions. The defect area is calculated as follows: For each defect region, directly count the number of all defect pixels in the region as the pixel value of the defect area. Then, use the same pixel size to convert the number of pixels into the actual area. During the conversion, the square of the actual side length corresponding to the pixel size is taken as the actual area of ​​a single pixel, and this value is fixed.

[0033] The process of determining location information marking and defect distribution density is as follows:

[0034] First, based on the prefabricated bag packaging structure, the sealing area is defined as the fixed strip area corresponding to the heat-sealed edge, and based on the packaging load-bearing structure, the load-bearing area is defined as the fixed area corresponding to the load-bearing support part. The pixel range of both is determined by converting the packaging outer boundary calibration results and the actual dimensions of the heat-sealed edge width and the load-bearing support range into pixel widths and remains fixed under the same specifications.

[0035] Then, the bounding rectangle of the pixel set of each defect area is calculated and the coordinates of its center pixel are obtained. The inclusion relationship between the center pixel coordinates and the pixel range of the sealing area and the pixel range of the load-bearing area is determined. If the center pixel coordinates fall into the sealing area, a sealing area position information mark is generated. If the center pixel coordinates fall into the load-bearing area, a load-bearing area position information mark is generated. If neither is included, a non-sealing and non-load-bearing position information mark is generated.

[0036] Finally, when calculating the defect distribution density, the effective imaging area is divided into several sub-regions according to a fixed unit area. The side length of the unit area is determined by converting the actual unit length into pixels and kept fixed under the same specifications. In each sub-region, the number of defect areas falling into that sub-region is counted and divided by the actual area of ​​that sub-region to obtain the defect distribution density of that sub-region. At the same time, the density value of the sub-region where the defect area is located is written into the location information marker of the defect area.

[0037] Specifically, S2 includes obtaining the color deviation of defects from the pre-made bag packaging defect image, extracting the color deviation region using a threshold segmentation method to obtain color deviation features; introducing a fuzzy membership function for continuous processing of the color deviation features, the fuzzy membership function maps the defect feature values ​​to the zero-to-one interval through linear interpolation to determine the membership value of the continuous features; if the continuous features are within a preset threshold interval of adjacent defect levels, calculating the membership weights of the features belonging to at least two defect levels respectively, and distributing the membership values ​​proportionally to obtain a weight distribution; determining the position marker of the defect relative to the sealing area or load-bearing area of ​​the pre-made bag packaging based on the weight distribution, and locating the defect center by weighted average.

[0038] In this embodiment, a reference area for calculating the color reference value is first determined in the image of the pre-made bag packaging defect. The rule for determining the reference area is to count the occurrence of color values ​​pixel by pixel in the entire image and select the color value with the most occurrences as the background main color of the image. Then, with the background main color as the center, a continuous set of pixels of the same color with the largest area is selected in the image and used as the reference area. This ensures that the reference area does not contain pixels with abnormal colors and that the selection process is uniquely determined by the statistical results. Subsequently, the color deviation value between each pixel in the image and the background main color of the reference area is calculated. The rule for calculating the color deviation value is to subtract the color value of the pixel from the background main color item by item, take the absolute value, and then sum them to obtain a single deviation value corresponding to each pixel and form a color deviation map.

[0039] It should be noted that a threshold segmentation method is then used to extract color deviation regions. The threshold is determined by sorting all pixel deviation values ​​in the color deviation map from smallest to largest and calculating the degree of dispersion of deviation within each possible threshold group and the difference between the means of the two groups after dividing the pixels into low deviation and high deviation groups. After traversing all thresholds, the threshold that maximizes the difference between the two groups and minimizes the dispersion within each group is selected as the segmentation threshold. Pixels with deviation values ​​greater than this segmentation threshold are all identified as color deviation pixels, resulting in a binarized result. Subsequently, the sets of interconnected color deviation pixels in the binarized result are defined as color deviation regions, and each color deviation region is further segmented into its corresponding region. The number of pixels within a region is used as the area of ​​the color deviation region in pixels. The maximum value of all pixel deviation values ​​within this region is taken as the color deviation feature value of that region, thus obtaining the color deviation feature, which is uniquely determined by the aforementioned deviation calculation result. Then, a fuzzy membership function is introduced into the color deviation feature for continuous processing. The parameters required for continuous processing include a lower threshold, an upper threshold, and a level boundary threshold and transition threshold range between adjacent defect levels. The rule for determining the lower threshold is to extract no less than 100 qualified pre-made bag packaging images under the same camera and lighting conditions before the equipment goes online, and calculate the color deviation of each image according to the aforementioned process. The color deviation feature values ​​are used to calculate the lower threshold, with the largest value being taken as the lower threshold to ensure that the qualified state corresponds to 0 in the continuous mapping. The upper threshold is determined by extracting no less than 100 pre-made bag packaging images that have been confirmed as having severe color deviation defects and calculating the color deviation feature values ​​using the same process. The smallest value among these is taken as the upper threshold to ensure that severe defects correspond to 1 in the continuous mapping. After obtaining the lower and upper thresholds, linear interpolation is performed on any color deviation feature value. The mapping rule is that when the feature value is less than or equal to the lower threshold, the continuous membership value is 0; when the feature value is greater than or equal to the lower threshold, the continuous membership value is 0. When the value equals the upper threshold, the continuous membership value is 1. When the feature value is between the lower threshold and the upper threshold, the continuous membership value is uniquely determined to be a value between 0 and 1 according to the ratio of the relative distance between the two thresholds. The rule for determining the threshold interval of adjacent defect levels is to statistically analyze the color deviation feature value distribution of moderate defect samples and severe defect samples in the same sampling data, take the maximum value of the feature value of the moderate defect sample as the upper boundary threshold of the moderate level, take the minimum value of the feature value of the severe defect sample as the lower boundary threshold of the severe level, and define the closed interval between the two as the transition threshold interval of adjacent defect levels.

[0040] When a continuous feature is within the transition threshold range, its membership weights belonging to at least two defect levels are calculated. The weight calculation rule is to proportionally allocate the weights based on the degree to which the continuous feature is close to the boundary threshold of the medium level and the boundary threshold of the severe level within the transition threshold range. The closer the continuous feature is to the boundary threshold of the medium level, the greater the medium weight and the smaller the severe weight. The closer the continuous feature is to the boundary threshold of the severe level, the greater the severe weight and the smaller the medium weight. Furthermore, the sum of the medium weight and the severe weight is fixed and equal to the continuous membership value, thus obtaining a uniquely determined weight distribution. Finally, the position of the defect relative to the pre-made bag packaging sealing area or load-bearing area is determined based on the weight distribution, and the defect distribution density is obtained.

[0041] Specifically, each color deviation pixel within the color deviation area is assigned a pixel weight. This pixel weight is the sum of the moderate and severe weights in the weight distribution corresponding to the defect, ensuring that the weight source completely corresponds to the weight distribution. Then, the horizontal and vertical pixel coordinates of all pixels within the color deviation area are weighted and summed, and divided by the total pixel weight to obtain the determined pixel coordinates of the defect center. The pixel ranges of the sealing area and the load-bearing area are uniquely determined by the pixel range of the prefabricated bag packaging's outer boundary in the image. The pixel range of the sealing area is a fixed strip of pixels corresponding to the width of the heat-sealed edge at the outer boundary, and the pixel range of the load-bearing area is a fixed pixel range corresponding to the load-bearing support portion. The width and position of both are determined according to the structural dimensions of the prefabricated bag packaging of this specification and the image's outer boundary. The range of pixels is calculated and remains fixed under the same specifications. The inclusion relationship between the pixel coordinates of the defect center and the pixel ranges of the sealing area and the load-bearing area is determined. If the defect center falls into the pixel range of the sealing area, the location mark of the sealing area is output. If the defect center falls into the pixel range of the load-bearing area, the location mark of the load-bearing area is output. If neither is included, the location mark of neither sealing nor load-bearing area is output. The calculation rule for defect distribution density is to divide the effective imaging area of ​​the pre-made bag packaging into 100 equal statistical units with equal areas by dividing it into 10 equal parts horizontally and 10 equal parts vertically. The number of color deviation areas in each statistical unit is counted and divided by the actual area of ​​the statistical unit to obtain the defect distribution density of the statistical unit. Then, the defect distribution density of the statistical unit where the defect center is located is output as the distribution density of the defect.

[0042] Example 2:

[0043] The difference between this embodiment and Embodiment 1 is that S3 includes obtaining defect location information and load-bearing area boundaries from the pre-made bag packaging defect image, calculating the spatial relationship measurement between the defect location information and the load-bearing area boundary through coordinate mapping, and obtaining a spatial relationship measurement value; using a preset threshold to determine non-load-bearing based on the spatial relationship measurement value, if the spatial relationship measurement value exceeds the preset threshold, it is determined that the defect is located in a non-load-bearing area, and a non-load-bearing judgment result is obtained; processing the defect area quantification based on the non-load-bearing judgment result, calculating the weight coefficient through proportional reduction, and determining the adjusted weight coefficient; obtaining the defect edge sharpness as a supplementary feature, fusing the adjusted weight coefficient to reduce the membership contribution of the defect area feature in defect classification, and obtaining a membership contribution value.

[0044] In this embodiment, firstly, defect location information and load-bearing area boundaries are obtained from the defect images of prefabricated bag packaging. The defect location information is obtained by accumulating the horizontal pixel coordinates of each extracted defect area pixel set and dividing by the number of defect area pixels to obtain the horizontal coordinate of the defect center. Simultaneously, the vertical pixel coordinates are accumulated pixel by pixel and divided by the number of defect area pixels to obtain the vertical coordinate of the defect center. The defect center pixel coordinates are then used as the defect location information. The load-bearing area boundaries are obtained by first determining the load-bearing area pixel range corresponding to the load-bearing support part of the prefabricated bag packaging in the same defect image. The rule for determining the load-bearing area pixel range is to use the standard structural dimensions of prefabricated bag packaging of the same specification as a basis before the equipment goes online, measure the actual position and actual width of the load-bearing support part on the packaging, and convert the actual position and actual width into a pixel range using the pixel size obtained from camera calibration. Thus, a fixed load-bearing area pixel range is obtained in each frame of the image. After obtaining the load-bearing area pixel range, the outer contour of the load-bearing area pixel range is then... The system scans pixel by pixel and identifies pixels on the outer contour that are adjacent to pixels inside the load-bearing area and pixels outside the load-bearing area as boundary pixels, thus obtaining the load-bearing area boundary composed of all boundary pixels. Subsequently, the spatial relationship measurement between the defect location information and the load-bearing area boundary is calculated through coordinate mapping. The calculation process of the spatial relationship measurement involves traversing each boundary pixel in the load-bearing area boundary, calculating the pixel distance between the defect center pixel coordinates and the boundary pixel coordinates, and selecting the smallest pixel distance from all pixel distances as the shortest distance from the defect center to the load-bearing area boundary. Then, the pixel size is used to convert the shortest distance into the actual distance, and the actual distance is used as the spatial relationship measurement value. The pixel size is a fixed parameter obtained from camera calibration. It is determined by placing a ruler of known length on the camera imaging plane, acquiring images, measuring the pixel span of the known length in the image, and calculating the actual length corresponding to each pixel. The pixel size remains unchanged under the conditions of fixed camera installation position, lens focal length, resolution, and working distance.

[0045] Specifically, a preset threshold is then used to determine non-load-bearing properties based on the spatial relationship metric. The preset threshold represents the safe distance extending outward from the boundary of the load-bearing area. This safe distance is determined by obtaining the effective load-bearing range of the load-bearing portion within the structural dimensions of the prefabricated bag packaging of the same specification, and using the outer edge of this load-bearing range as the starting boundary of the non-load-bearing area. A fixed-width safe distance is set outside the load-bearing range boundary to cover calibration errors and image jitter. The value of the safe distance is determined by repeatedly calibrating images of at least 100 defect-free samples and statistically analyzing the maximum offset of the load-bearing area boundary in pixel coordinates. The final safe distance is obtained by taking a determined magnification factor based on the actual distance corresponding to the maximum offset. This safe distance is then used as the preset threshold and directly compared with the spatial relationship metric. When the spatial relationship metric is greater than the preset threshold, the non-load-bearing property is output as a defect located in the non-load-bearing area. When the spatial relationship metric is less than or equal to the preset threshold, the non-load-bearing property is output as a defect located in the load-bearing area.

[0046] In this embodiment, after obtaining the non-load-bearing assessment result, the defect area is quantified based on the non-load-bearing assessment result, and the weight coefficient is calculated by proportional reduction. The defect area quantification value is obtained by counting the number of pixels in the defect area pixel set and converting the pixel size into the actual area. The parameters used for proportional reduction are the reduction ratio and the default maintenance ratio. The reduction ratio is determined by statistically analyzing the influence of the defect area quantification values ​​located in the load-bearing area and the defect area quantification values ​​located in the non-load-bearing area on the final classification in historical defect samples of pre-made bag packaging of the same specification, and selecting the area contribution of the non-load-bearing area defect. A fixed reduction ratio consistent with manual risk assessment is used as the reduction ratio and is fixed in the system. The default ratio is kept at 1 to ensure that the defect area contribution is not reduced when the defect is located in the load-bearing area. The calculation rule for the weight coefficient is as follows: when the non-load-bearing assessment result is that the defect is located in the non-load-bearing area, the quantified value of the defect area is first multiplied by the reduction ratio to obtain the quantified value of the reduced defect area. Then, the quantified value of the reduced defect area is divided by the quantified value of the defect area before reduction, and the resulting ratio is used as the adjusted weight coefficient, so that the weight coefficient is equal to the reduction ratio and is a fixed value. When the non-load-bearing assessment result is that the defect is located in the load-bearing area, the adjusted weight coefficient is directly set to the default ratio of 1.

[0047] In this embodiment, the defect edge sharpness is finally obtained as a supplementary feature and fused with the adjusted weight coefficient to reduce the membership contribution of the defect area feature in defect classification. The process of obtaining the defect edge sharpness is as follows: extract the boundary pixel sequence pixel by pixel on the boundary of the defect region, and take a fixed width pixel band in the normal direction of each boundary pixel to the inside and outside of the defect respectively. The width of the pixel band is determined by selecting a fixed pixel width according to the camera resolution and keeping it unchanged in the same specification of product. Then, calculate the average gray value in the pixel band and take the difference between the average gray values ​​inside and outside as the local sharpness value of the boundary pixel. Then, average the local sharpness values ​​of all boundary pixels to obtain the quantitative value of defect edge sharpness. The parameters used for fusion calculation are fusion weight and sharpness normalization threshold range. The sharpness normalization threshold range is determined by the same specification of prefabricated bags. The minimum value of the edge sharpness quantification in the sample set is used as the lower limit and the maximum value is used as the upper limit and fixed. Then, the edge sharpness quantification is mapped to a certain value from 0 to 1 according to the lower limit and upper limit and used as the sharpness contribution value. The fusion weight is determined by adjusting the fusion weight on the same batch of samples with the goal of hierarchical consistency and selecting the fixed value that makes the highest consistency as the fusion weight and fixing it. The membership contribution value is calculated by first weighting the adjusted weight coefficient and the sharpness contribution value according to the fusion weight to obtain the final area contribution adjustment value. Then, the original membership contribution of the defect area feature in the hierarchical calculation is reduced by using the final area contribution adjustment value. Thus, when the defect is located in a non-load-bearing area, the contribution of the defect area feature will be reduced. When the edge sharpness of the defect is high, the certain risk contribution is retained by supplementing features. Finally, a unique membership contribution value is output.

[0048] Example 3:

[0049] In this embodiment, S4 includes obtaining defect geometric quantization data and position weight fusion data from the defect image of the pre-made bag packaging; calculating the correlation between the defect geometric quantization data and the position weight fusion data through coordinate transformation to obtain a first correlation value; evaluating the distribution density using a preset threshold for the first correlation value; if the first correlation value is lower than the preset threshold, determining the distribution density evaluation result; fusing the distribution density evaluation result with edge sharpness supplementary data by weighted average to obtain a first fused feature set; obtaining area feature adjustment information from the first fused feature set; and calculating the membership degree of the area feature adjustment information using a fuzzy C-means clustering method, where fuzzy C-means clustering is a membership-based clustering method that iteratively optimizes the center point and... The membership matrix is ​​used to group data and determine the membership degree calculation results. The membership degree calculation results and non-load-bearing judgment data are processed by spatial relationship measurement to obtain the weight coefficient reduction value. The weight coefficient reduction value is then integrated with the defect color deviation data. The defect color deviation integration refers to calculating and normalizing the difference between the RGB color component values ​​of the defect area and the standard color to obtain the comprehensive integration set. A comprehensive model analysis is used on the comprehensive integration set. The comprehensive model analysis refers to generating a comprehensive risk probability distribution of pre-made bag packaging defects by weighted summation and fusion of defect geometric quantification, location weight fusion, and distribution density assessment of the corresponding membership degree results. The defect geometric quantification is defect geometric quantification data, including at least one of the defect area, defect length, and defect shape related parameters.

[0050] In this embodiment, firstly, defect geometric quantization data and position weight fusion data are obtained from the defect image of the pre-made bag packaging. The process of obtaining defect geometric quantization data is as follows: for each segmented defect region, the number of defect pixels is counted to obtain the defect area pixel count. Based on the pixel size obtained from camera calibration, the defect area pixel count is converted into an actual area quantization value. At the same time, the maximum pixel distance between boundary pixels of the defect region boundary pixel set is calculated to obtain the defect length pixel value, which is also converted into an actual length quantization value based on the pixel size, thus forming defect geometric quantization data. The process of obtaining position weight fusion data is as follows: the defect center pixel coordinates, the position marker of the sealing area or load-bearing area, the spatial relationship measurement value, the non-load-bearing judgment result, the distribution density quantization value, the edge sharpness supplementary data, and the adjusted weight coefficient of the defect area obtained under non-load-bearing conditions are read. The pixel size is obtained through scale calibration. Furthermore, under the conditions of fixed camera installation position, lens focal length, resolution, and working distance, the pixel range of the sealing area and the load-bearing area is fixed after being converted into pixel range by the structural dimensions of the prefabricated bag packaging of this specification. The spatial relationship measurement value is obtained by converting the minimum distance from the pixel coordinates of the defect center to the pixel set of the boundary of the load-bearing area into the actual distance. The non-load-bearing judgment result is obtained by comparing the spatial relationship measurement value with the non-load-bearing judgment threshold. The distribution density quantification value is obtained by dividing the effective imaging area into a fixed number of statistical units with equal area, counting the number of defects falling into each statistical unit, and dividing by the actual area of ​​the statistical unit. The edge sharpness supplementary data is obtained by calculating the average gray level difference of the fixed width pixel band inside and outside the defect boundary point by point and averaging all boundary points. The adjusted weight coefficient is obtained by reducing the defect area quantification value by a fixed reduction ratio when the non-load-bearing judgment is triggered, and using the reduction ratio as the weight coefficient.

[0051] Subsequently, the correlation between the defect geometric quantization data and the position weight fusion data is calculated through coordinate transformation. The coordinate transformation process is as follows: using the upper left corner pixel of the effective imaging area of ​​the pre-made bag packaging as the coordinate origin and the pixel size as the scale, the pixel coordinates of the defect center, the boundary pixel coordinates of the load-bearing area, and the sealing area are all converted to the same actual coordinate system. Based on this, the defect geometric quantization data and the position weight fusion data are aligned in the same coordinate system. The correlation value is calculated by first mapping the defect area quantization value to a normalized area value of 0 to 1 according to the minimum and maximum area quantization values ​​in the sample set of this specification. Then, the normalized area value is multiplied by the position weight value in the position weight fusion data corresponding to the defect to obtain the first correlation value. The minimum and maximum area quantization values ​​are obtained and fixed by statistically analyzing no less than 100 samples of this specification according to the same area calculation process before going online. The position weight value is taken from the determined synthesis result of the adjusted weight coefficient and the distribution density quantization value corresponding to the non-load-bearing judgment and adopts a fixed synthesis order under the same specification.

[0052] Specifically, the distribution density is then evaluated using a preset threshold based on the first correlation value. The threshold is determined by calculating the correlation value of the sample set labeled as "dense defect samples" and taking the minimum correlation value of the set as the threshold. This ensures that all dense defect samples meet the condition that the correlation value is not lower than the threshold. The comparison rule is as follows: when the first correlation value is lower than the threshold, the distribution density evaluation result is output as "low density" with a low density weight of 0; when the correlation value is not lower than the threshold, the distribution density evaluation result is output as "high density" with a high density weight of 1. This ensures that the distribution density evaluation result has a unique numerical expression. Then, the distribution density evaluation result is fused with edge sharpness supplementary data using a weighted average to obtain the first fused feature set. The weighted average process involves first mapping the edge sharpness quantification value to a sharpness normalization value of 0 to 1 in the sample set of this specification, based on the minimum and maximum sharpness quantification values. Then, the sharpness normalization value and the distribution density weight are weighted and averaged according to a fixed fusion weight to obtain a single fusion value. This fusion value, along with the defect area quantification value, the adjusted weight coefficient, and the defect length quantification value, forms a fusion feature set. The minimum and maximum sharpness quantification values ​​are obtained and fixed by statistically analyzing no less than 100 samples of this specification using the same sharpness calculation process before going live. The fusion weight is determined by iterating through the labeled samples between 0 and 1 with a step size of 0.01 and calculating the consistency rate between the fusion result and the labeled result when used for subsequent risk assessment. The weight with the highest consistency rate is taken as the fixed fusion weight.

[0053] Subsequently, the area feature adjustment information from the fused feature set is obtained and membership degree is calculated. The formation process of the area feature adjustment information is as follows: the quantified value of the defect area is multiplied by the adjusted weight coefficient to obtain the quantified value of the area adjustment; then, the quantified value of the area adjustment is multiplied by the aforementioned fused value to obtain the area feature adjustment value. The area feature adjustment value is used as the input data for the fuzzy mean clustering method to perform membership degree calculation. The rule for determining the number of cluster categories is to set the number of categories to the number of defect levels in the pre-made bag packaging and keep it unchanged in this specification of product. The initialization process is to sort all area feature adjustment values ​​in ascending order and then extract sample values ​​at equal intervals with the same number of categories as the initial center points, and then assign each sample to each cluster. The initial membership degree of the center points is set to an equal value. The iterative update process is to calculate the quantized distance value between each sample and each center point and update the membership degree of the sample to each center point according to the rule of "the smaller the distance, the larger the membership degree". At the same time, the sum of the membership degree of the sample to all center points is forced to be equal to 1. Then, the updated membership degree is used to re-evaluate each center point by weighted averaging of the sample values. The stopping condition is that the change of all center points in two adjacent iterations is less than the convergence threshold. The convergence threshold is determined by dividing the normalized range of 0 to 1 of the area feature adjustment value into 1000 equal parts and taking the value corresponding to one part as the convergence threshold and fixing it, so as to ensure that the number of iterations, center points and membership degree results can be reproduced under the same input data.

[0054] In this embodiment, after obtaining the membership degree calculation result, the membership degree calculation result and the non-load-bearing judgment data are processed by spatial relationship measurement to obtain the weight coefficient reduction value. The processing rule is as follows: when the non-load-bearing judgment result is that the defect is located in the non-load-bearing area, the spatial relationship measurement value is read and compared with the non-load-bearing judgment threshold in segments. When the spatial relationship measurement value is greater than twice the non-load-bearing judgment threshold, the membership degree of the "high-risk area group" is reduced to 0.5 of the original value, and 0.5 is used as the weight coefficient reduction value. When the spatial relationship measurement value is greater than the non-load-bearing judgment threshold but not greater than twice the non-load-bearing judgment threshold, the membership degree of the "high-risk area group" is reduced to 0.7 of the original value, and 0.7 is used as the weight coefficient reduction value. When the spatial relationship measurement value is not greater than the non-load-bearing judgment threshold, the weight coefficient reduction value is set to 1, so that the reduction value is uniquely determined by the spatial relationship measurement value. When the non-load-bearing judgment result is that the defect is located in the load-bearing area, the weight coefficient reduction value is set to 1.

[0055] Furthermore, the weighted coefficient reduction value and defect color deviation integration data are then integrated to obtain a comprehensive set. The calculation process for the color deviation integration data involves calculating the difference between the color value of each pixel in the defect area and the standard color pixel by pixel, and averaging the differences of all pixels in the defect area to obtain a quantized color difference value. This quantized color difference value is then mapped to a normalized color deviation value between 0 and 1, using the maximum value of the quantized color difference value of the qualified samples as the lower normalization limit and the minimum value of the quantized color difference value of the severely defective samples as the upper normalization limit. The standard color is taken from the background main color of the qualified samples and fixed under fixed camera and lighting parameters. The lower and upper normalization limits are obtained and fixed by statistically analyzing at least 100 qualified samples and at least 100 severely defective samples using the same color difference calculation process before going live. The formation process of the comprehensive set involves reducing the weighted coefficient... The values, normalized color deviation values, defect length quantification values, and distribution density weights are grouped into the same set of input data in a fixed order. Finally, a comprehensive model analysis is used to generate a comprehensive risk probability distribution for the integrated set. The implementation process of the comprehensive model analysis is as follows: the membership results corresponding to defect geometric quantification, the weight coefficient reduction values ​​corresponding to location weight fusion, and the distribution density weights corresponding to distribution density assessment are read from the integrated set. The three are multiplied by the geometric fusion weight, location fusion weight, and density fusion weight respectively, and then weighted and summed to obtain the risk score of each defect level. The process of determining the geometric fusion weight, location fusion weight, and density fusion weight is to traverse the weight value combinations on the labeled samples and select a unique set of weights with the highest level consistency rate as the target. Then, the risk scores of all defect levels are normalized to the probability of each level by summing and output as a comprehensive risk probability distribution.

[0056] S5 includes acquiring defect texture deviation integration data from pre-made bag packaging defect images, wherein the defect texture deviation integration data refers to the difference between the texture value of the defect area and the standard texture and normalized. The correlation between the defect texture deviation integration data and the position weight fusion is calculated through coordinate transformation, wherein the coordinate transformation refers to mapping the defect position coordinates to the weight space to obtain a second correlation value. A preset threshold is used to evaluate the distribution density of the second correlation value. If the correlation value is lower than the preset threshold, the distribution density evaluation result is determined. The distribution density evaluation result is fused with the defect geometric quantization by weighted average to obtain a second fused feature set. The membership degree calculation results of the second fusion feature set are obtained. The spatial relationship measurement processing of the membership degree calculation results is performed by the fuzzy C-means clustering method. The spatial relationship measurement processing refers to calculating the distance between cluster centers and adjusting the weights to obtain the weight coefficient reduction value. The weight coefficient reduction value and the defect color deviation are fused to obtain the comprehensive integration set. The comprehensive integration set is analyzed and judged by the comprehensive model to determine the fuzzy interval distribution trend. The comprehensive model analysis refers to generating a probability distribution by weighted summation of the membership degree results. When the fuzzy interval distribution trend covers the membership degree peak, the sample to be reviewed is marked and the risk probability distribution is output.

[0057] In this embodiment, defect texture deviation integration data is first obtained from the defect image of the pre-made bag packaging. Specifically, grayscale values ​​are read pixel by pixel within the defect area determined in the previous step, and texture values ​​are calculated for each pixel using a fixed neighborhood window. The rule for determining the texture value is to statistically analyze the grayscale variation within the neighborhood window of the pixel and output a single value. Then, the texture values ​​of all pixels within the defect area are averaged to obtain the texture value of the defect area. The process for determining the standard texture is to select a standard area in the same defect image according to a fixed rule. The fixed rule is to select a continuous background area within the effective imaging area of ​​the pre-made bag packaging that does not contain the defect area and does not contain the printing boundary, and to use the largest area of ​​the continuous background area as the sole selection condition, thereby obtaining the standard area. Then, the texture values ​​of all pixels within the standard area are calculated according to the same texture value calculation rule as the defect area, and the average is taken to obtain the standard texture.

[0058] The calculation process for the defect texture deviation difference is as follows: subtract the standard texture from the texture value of the defect area and take the absolute value to obtain the texture difference quantization value. The parameters used for normalization are the texture normalization lower limit and the texture normalization upper limit. The process for determining the texture normalization lower limit is as follows: under fixed camera, lighting, and shooting parameters, collect no less than 100 qualified samples and obtain a set of qualified sample texture difference quantization values ​​according to the aforementioned texture difference quantization value calculation process. Take the maximum value in this set as the texture normalization lower limit. The process for determining the texture normalization upper limit is as follows: collect no less than 100 samples marked as severe texture abnormalities and obtain a set of severe sample texture difference quantization values ​​according to the same process. Take the minimum value in this set as the texture normalization upper limit, thereby ensuring that qualified texture deviation is mapped to 0 and severe texture deviation is mapped to 1. The normalization implementation rule is that when the texture difference quantization value is less than or equal to the texture normalization lower limit, the normalized texture deviation value is 0; when the texture difference quantization value is greater than or equal to the texture normalization upper limit, the normalized texture deviation value is 1. When the texture difference quantization value is between the two, it is mapped to a definite value between 0 and 1 according to the ratio of its relative distance between the two, thus obtaining the defect texture deviation integration data. Then, the correlation between the defect texture deviation integration data and the position weight fusion is calculated through coordinate transformation. The coordinate transformation process is to read the pixel coordinates of the defect center and convert them into actual coordinates under the pre-made bag packaging coordinate system according to the pixel size. The pixel size is obtained by the scale calibration and remains unchanged under the conditions of fixed camera installation position, lens focal length, resolution and working distance. Then, the actual coordinates are mapped to the weight space used for position weight fusion. The mapping rule of the weight space is to divide the pre-made bag packaging coordinate system into a fixed number of weight units according to the grid consistent with the distribution density statistical unit, and assign a unique position weight value to each weight unit. The position weight value is determined by the weight coefficients corresponding to the sealing area position mark, the load-bearing area position mark and the non-load-bearing judgment result and is fixed in the same specification product.

[0059] In this embodiment, the correlation degree value is calculated by multiplying the normalized texture deviation value and the position weight value of the weight unit where the defect center is located to obtain the second correlation degree value. The second correlation degree value increases with the increase of texture deviation and position weight. Then, a preset threshold is used to evaluate the distribution density of the second correlation degree value. The preset threshold is the correlation degree boundary value for determining whether the defect exhibits low-density characteristics in the weight space. The threshold is determined by statistically analyzing the correlation degree value set of "low-density defect samples" and the correlation degree value set of "high-density defect samples" in the labeled sample set, and taking the maximum value in the correlation degree value set of the low-density defect samples and the correlation degree value set of the high-density defect samples. The median of the minimum values ​​in the correlation set is used as the unique threshold and fixed. The comparison rule is that when the second correlation value is lower than the threshold, the distribution density evaluation result is determined as low density and assigned a value of 0. When the correlation value is not lower than the threshold, the distribution density evaluation result is determined as high density and assigned a value of 1. Then, the second fused feature set is obtained by fusing the distribution density evaluation result with the defect geometric quantization through weighted average. The defect geometric quantization is derived from the defect area quantization value and the defect length quantization value. The area quantization value is obtained by counting the number of pixels in the defect area and converting it into the actual area according to the pixel size. The length quantization value is obtained by calculating the maximum pixel distance in the defect boundary pixel set and converting it into the actual length according to the pixel size.

[0060] Specifically, to ensure consistent input scale for weighted averaging, lower, upper, and lower limits for area normalization, as well as upper and lower limits for length normalization, are set. The lower limit for area normalization is the maximum value from the set of quantified area values ​​of qualified samples, and the upper limit is the minimum value from the set of quantified area values ​​of samples with severe area defects, and the lower limit for length normalization is the maximum value from the set of quantified length values ​​of qualified samples, and the upper limit is the minimum value from the set of quantified length values ​​of samples with severe length defects, and the normalization rules are consistent with the texture normalization rules, thus obtaining normalized area and normalized length values; the weighted average... The parameters are density fusion weight, area fusion weight, and length fusion weight. The process of determining these three parameters is to iterate through the combinations of weight values ​​on the labeled sample set and force the sum of the three to be equal to 1. The fusion feature is used to calculate the consistency rate with the label when it is to be reviewed and judged in the future. The set of weights with the highest consistency rate is selected as fixed values ​​and fixed. The calculation process of the fusion feature value is to multiply the 0 or 1 of the distribution density evaluation result by the density fusion weight, multiply the normalized area value by the area fusion weight, multiply the normalized length value by the length fusion weight, and then sum them to obtain the fusion feature value. The fusion feature value and the normalized texture deviation value are then used to form the second fusion feature set.

[0061] Furthermore, the membership calculation results of the second fused feature set are then obtained, and the spatial relationship measurement processing of the membership calculation results is performed using the fuzzy mean clustering method. Specifically, the fused feature set is used as input to perform fuzzy mean clustering iteration. The rule for determining the number of cluster categories is to set it to the number of defect levels and fix it. The rule for determining the initial cluster centers is to sort the fused feature values ​​from smallest to largest and extract sample values ​​at equal intervals with the same number of categories as the initial centers. The iterative update process is to calculate the quantized distance value between each sample and each cluster center and update the membership degree of the sample to each center according to the distance. Then, the updated membership degree is used to re-evaluate the cluster centers by weighted average of the sample values. The stopping condition is that the change in all cluster centers in two adjacent iterations is less than the convergence threshold. The rule for determining the convergence threshold is to divide the fused feature value range of 0 to 1 into 1000 equal parts and take the result. One corresponding value is used as the convergence threshold and fixed to obtain the membership degree calculation result for each defect sample. The spatial relationship measurement process is to calculate the quantified distance between all cluster centers and find the minimum inter-center distance. At the same time, an inter-center distance threshold is set to determine the degree of center overlap. The process of determining the inter-center distance threshold is to statistically analyze the distribution of inter-center distances after clustering on the labeled samples and take the median of the distribution as the threshold and fix it. When the minimum inter-center distance is less than the threshold, the two cluster centers corresponding to the minimum inter-center distance are regarded as overlapping and their corresponding weights are reduced by a fixed reduction ratio. The process of determining the fixed reduction ratio is to traverse the reduction ratio between 0.1 and 0.9 on the labeled samples with a step size of 0.1 and select the ratio that makes the subsequent probability distribution consistent with the labeling rate and fix it to obtain the weight coefficient reduction value.

[0062] After obtaining the weighted coefficient reduction values, the weighted coefficient reduction values ​​and defect color deviations are fused to obtain a comprehensive set. The defect color deviation is obtained by calculating the difference between the pixel color value of the defect area and the standard color pixel by pixel and averaging the difference to obtain a quantized color difference value. Then, the maximum value of the quantized color difference value set of qualified samples is used as the lower limit of color normalization, and the minimum value of the quantized color difference value set of severe color defect samples is used as the upper limit of color normalization to obtain a normalized color deviation value. The standard color is taken from the background main color of qualified samples and fixed under fixed camera and lighting parameters. The formation rule of the comprehensive set is to combine the weighted coefficient reduction values, normalized color deviation values ​​and membership calculation results into the same set of input data in a fixed order. Finally, a comprehensive model is used to analyze and judge the distribution trend of fuzzy intervals and output the risk probability distribution for the comprehensive set. The implementation process of the comprehensive model analysis is to multiply each membership result in the comprehensive set by the corresponding comprehensive model weight. The risk scores for each defect level are obtained by summing the sums, and the risk scores for each level are normalized to a probability distribution for output. The process of determining the weights of the comprehensive model is to traverse the weight combinations on the labeled samples and select a unique set of weights with the highest level consistency rate as the target and fix it. The process of determining the fuzzy interval is to statistically analyze the probability difference distribution between moderate and severe defects in the labeled samples, take the upper quartile of the difference distribution as the difference threshold and fix it. Samples whose probability difference between moderate and severe defects is less than or equal to the difference threshold are defined as being in the fuzzy interval. The process of determining the membership peak coverage is to find the defect level with the highest probability in the output probability distribution as the peak level. At the same time, it is determined that the probability distribution simultaneously covers the membership peak coverage of moderate and severe defects when both the probability of moderate and severe defects is not less than 0.9 of their respective peak probabilities. When this condition is met, the defect sample is marked as a sample to be reviewed and the risk probability distribution of the sample is output.

[0063] Example 4:

[0064] In this implementation, S6 includes obtaining the defect area feature membership degree and location weight membership degree from the sample to be reviewed, determining the degree of conflict by calculating the absolute value of the difference between the two, and obtaining the conflict index value; using DS evidence theory to integrate multiple defects for the conflict index value, where evidence theory merges evidence sources by assigning a trust function to obtain the basic probability distribution after fusion and determine the unified membership degree after resolution; if the unified membership degree exceeds a preset threshold, a preset expert knowledge rule is triggered to reason about the color deviation integration, where the expert knowledge rule is a pre-established defect reasoning library, and an adjusted geometric quantization fusion result is obtained; by combining the geometric quantization fusion result with the fusion features of the sample to be reviewed, the correction value of the risk distribution output is determined, and the optimized sample label is obtained; based on the optimized sample label integration preset threshold evaluation, the final defect conflict resolution state is determined.

[0065] In this implementation, firstly, for each sample to be reviewed, the defect area feature membership degree and location weight membership degree are read simultaneously. The reading rule is to take the corresponding level values ​​from the "area feature membership degree results" and the "location weight membership degree results" of the sample under the same defect level dimension, respectively, to ensure that the two values ​​come from the same level caliber and are both definite values. Then, a conflict index value is calculated to determine the degree of conflict. The specific calculation process is to calculate the difference between the "area feature membership degree value and the location weight membership degree value" for each defect level, take the absolute value of the difference, and then select the maximum value from the absolute value differences of all levels as the conflict index value, so that the conflict index value is uniquely determined under the same sample input, and the larger the value, the stronger the contradiction between the two types of evidence. Next, the sample to be reviewed corresponding to the conflict index value is subjected to multiple defect integration based on evidence theory to obtain a unified membership degree after resolution. Specifically, the defect area feature membership degree is regarded as the first source of evidence, the location weight membership degree is regarded as the second source of evidence, and other existing membership degree results of the sample to be reviewed are added as supplementary. For each evidence source, a trust function is assigned, generating a basic probability allocation for that evidence source across various defect levels. The parameters of the trust function are the credibility weights of the evidence sources. These credibility weights are determined by statistically analyzing the consistency rate between each evidence source's individual judgment and its labeled level using an annotated sample set for review before deployment. The evidence source with the highest consistency rate is assigned the maximum credibility weight, and the credibility weights of the remaining evidence sources are determined proportionally to the consistency rate. All credibility weights are then normalized to a sum equal to 1 and fixed, ensuring that the basic probability allocation for each evidence source is uniquely determined by its original membership result and credibility weight. The evidence fusion calculation process involves first calculating the consistency support among evidence sources for the same level and accumulating it into a consistency term. Simultaneously, the cross-support among evidence sources for different levels is calculated and accumulated into a conflict term. The conflict term is normalized to obtain a conflict coefficient. Then, the consistency term is normalized by subtracting the conflict coefficient from 1 to obtain the fused basic probability allocation. Finally, the fused basic probability allocation values ​​for each defect level are directly used as the unified membership degree, thus completing the multi-evidence source conflict resolution and outputting the unified membership degree.

[0066] Subsequently, a threshold trigger judgment is performed on the unified membership degree to determine whether to invoke expert knowledge rules for reasoning on color deviation integration. The preset threshold is the unified membership degree trigger threshold. The threshold is determined by statistically analyzing the distribution of unified membership degree values ​​corresponding to samples "requiring manual review and judged as high-risk level" in the historical sample set awaiting review, taking the minimum value of this distribution as the trigger threshold and fixing it. The comparison rule is that when the unified membership degree value at the target high-risk level is greater than this trigger threshold, the expert knowledge rule is triggered. The expert knowledge rules come from a pre-established defect reasoning library, which is established by compiling "color deviation integration and final risk level" data from labeled samples packaged in prefabricated bags of the same specification. The correspondence between the color deviation and the geometric quantization fusion is determined and a specific rule entry is formed. Each rule entry contains the color deviation integration value range and the corresponding geometric quantization fusion adjustment conclusion. Once a rule entry is established, it is fixed and the adjustment conclusion is uniquely output according to the matching result during operation. The implementation process of reasoning for color deviation integration after triggering is to read the color deviation integration value of the sample to be reviewed, compare the value with the rule entries in the reasoning library one by one and hit the unique rule entry, and output the adjusted geometric quantization fusion result corresponding to the rule entry. The adjusted geometric quantization fusion result is formed by applying the determined adjustment coefficient given by the rule entry to the original geometric quantization fusion result, so that the adjustment result can be repeatedly obtained under the same input.

[0067] Subsequently, the geometric quantization fusion result is combined with the fusion features of the sample to be reviewed to calculate the corrected value of the risk distribution output. Specifically, this involves reading the original fusion features of the sample to be reviewed and the adjusted geometric quantization fusion result, performing a weighted summation according to preset combination weights to obtain the corrected risk score, and normalizing the corrected risk score to a corrected risk probability distribution for each defect level. The absolute value of the probability difference between the corrected risk probability distribution and the original risk probability distribution at the target level is then used as the corrected risk distribution output value. The combination weights are preset parameters, determined by iterating through the labeled sample set to be reviewed and selecting a unique set of values ​​with the highest consistency rate between the final level and the label, and then fixing it. The process of updating the sample label based on the corrected risk distribution output value involves comparing the corrected risk distribution output value with a correction threshold. The correction threshold is determined by statistically analyzing the distribution of correction values ​​corresponding to samples whose "level changed after correction" in the labeled sample set to be reviewed, and taking the minimum value of this distribution as the corrected value. A positive threshold is set and fixed. When the correction value is greater than the correction threshold, the sample label is updated to the optimized sample label and the corrected risk probability distribution is used as the output. Otherwise, the original label remains unchanged. Finally, the optimized sample label is integrated with the preset threshold evaluation to determine the final defect conflict resolution status. The preset threshold evaluation includes a conflict threshold, a consistency threshold, and a correction threshold. The conflict threshold is determined by statistically analyzing the distribution of conflict index values ​​corresponding to samples that are "manually confirmed to have no evidence contradictions" in the labeled sample set and taking the maximum value as the conflict threshold and fixing it. The consistency threshold is determined by statistically analyzing the distribution of unified membership degrees corresponding to samples that are "consistent with the label after evidence fusion" in the labeled sample set and taking the minimum value as the consistency threshold and fixing it. The judgment rule is that when the conflict index value is less than or equal to the conflict threshold, the unified membership degree is greater than or equal to the consistency threshold, and the risk distribution output correction value is less than or equal to the correction threshold, the final defect conflict resolution status is determined to be resolved. Otherwise, the final defect conflict resolution status is determined to be unresolved.

[0068] S7 includes obtaining packaging grade labels from defect resolution results, integrating preset historical defect data for packaging grade labels to obtain an updated label library; generating transition interval identifiers based on the updated label library, constructing a graded mapping table for the transition interval identifiers, and determining the mapping table construction; judging the risk level of pre-made bag defects by combining the mapping table construction with defect type classification, and obtaining a risk level output; obtaining the risk level output for confidence assessment, integrating the interval identifiers based on the assessment results, and determining the final risk level of pre-made bag packaging defects and its confidence assessment results.

[0069] In this embodiment, the packaging level label is first obtained from the defect resolution results. Specifically, for each defect sample that has completed conflict resolution, its final defect level output is read, and the final defect level is written into the packaging level label field of the sample by a determined enumeration value. The final defect level output comes from the unified membership degree and risk distribution correction judgment result of the previous stage and is a unique conclusion. Subsequently, the label library is updated by integrating preset historical defect data for the packaging level label. The components of the preset historical defect data are the packaging level label of the historical sample, the defect type classification of the historical sample, the defect feature quantification value of the historical sample, and the maximum probability value of the comprehensive risk probability distribution corresponding to the historical sample. The source of the historical defect data is the continuously saved judged sample records since the system went online and stored according to defect type. The integration is implemented by adding the packaging level label, defect type classification, defect feature quantification value, and the maximum probability value of the comprehensive risk probability distribution of the current sample to the historical data set of the same defect type, and retaining the most recent 10,000 records in the set in chronological order as the effective historical data window, so that the label library update has a defined data range.

[0070] Furthermore, transition interval identifiers are generated based on the updated tag library. The generation target of these identifiers is the feature boundary interval between two adjacent packaging levels. The parameters used for generation include the lower and upper bounds of the features for each packaging level under each defect type classification, as well as the minimum sample size threshold for the interval. The determination of the lower and upper bounds involves summarizing and sorting the quantified defect feature values ​​of all samples for the same defect type and packaging level within the valid historical data window. The feature value corresponding to the first 5% of the sorted sequence is selected as the lower bound for that level, and the feature value corresponding to the first 95% of the sequence is selected as the upper bound. This suppresses the influence of extreme outliers on boundary determination and ensures that the boundary is uniquely determined by historical data. The minimum sample size threshold for the interval is fixed at 50 to ensure that at least 50 samples are used for boundary statistics for each level.

[0071] After obtaining the lower and upper bounds of the features of two adjacent levels, the calculation process of the transition interval identifier is as follows: take the closed interval between the upper bound of the lower level feature and the lower bound of the higher level feature as the transition interval. When the upper bound of the lower level feature is less than the lower bound of the higher level feature, the closed interval is a valid transition interval and its start and end values ​​are recorded. When the upper bound of the lower level feature is greater than or equal to the lower bound of the higher level feature, it indicates that there is an overlap between the feature distributions of the two levels. At this time, the overlapping interval is determined as the transition interval and its start and end values ​​are recorded. Finally, the start and end values ​​of the transition interval corresponding to each pair of adjacent levels and the level pair information corresponding to the transition interval are written into the transition interval identifier table to ensure that each defect type classification obtains a uniquely determined transition interval identifier.

[0072] Then, a hierarchical mapping table is constructed based on the transition interval identifier to determine the mapping table construction. The input of the hierarchical mapping table is a combination of defect type classification and defect feature quantification value, and the output is a packaging grade label or transition interval identifier. The mapping table construction process is to create a mapping table for each defect type classification, and write the defined interval of each packaging grade and the transition interval between adjacent grades in the table in ascending order of defect feature quantification value. It is stipulated that when the input feature quantification value falls into the defined interval of a certain packaging grade, the packaging grade label is output, and when the input feature quantification value falls into a certain transition interval, the transition interval identifier is output, so that each input corresponds to a unique output. Subsequently, the risk level output is obtained by judging the risk level of prefabricated bag defects by combining the mapping table construction with the defect type classification.

[0073] Specifically, the implementation involves reading the defect type classification and the corresponding quantitative value of the defect feature of the sample to be judged. These two values ​​are then used as input to look up a mapping table. If the output is a packaging grade label, this label is used as the risk level output. If the output is a transition interval identifier, the level with the higher probability among the two adjacent levels corresponding to the transition interval identifier is determined as the risk level output. The higher probability level is taken from the comprehensive risk probability distribution of the sample. Finally, a confidence assessment is performed on the risk level output, and an integrated interval identifier is generated. The input parameters for the confidence assessment are the maximum and second-highest probability values ​​of the comprehensive risk probability distribution, the confidence threshold, and the transition judgment threshold. The maximum and second-highest probability values ​​of the comprehensive risk probability distribution are directly read from the calculated probability distribution of the sample and are fixed values. The process of determining the confidence threshold is as follows: within the effective historical data window, the maximum probability value distribution corresponding to the sample set that "does not require manual review after automatic judgment" is statistically analyzed. The value corresponding to the first 5% position in the ordered sequence of this distribution is selected as the confidence threshold and fixed. The process for determining the transition threshold is as follows: Within the valid historical data window, statistically analyze the distribution of the difference between the "maximum probability value minus the second-highest probability value" corresponding to the sample set outputting the transition interval identifier. Then, select the value corresponding to the first 95% of the ordered sequence of this difference distribution as the transition threshold and solidify it. The calculation process for the confidence level is as follows: The maximum probability value is directly output as the confidence level value and retained to two decimal places. When the maximum probability value is less than the confidence threshold, the output of this sample is simultaneously generated with an integration interval identifier, and the integration interval identifier is fixedly marked as "low confidence". When the mapping table output is a transition interval identifier and the difference between the maximum probability value and the second-highest probability value is less than or equal to the transition threshold, the output of this sample is simultaneously generated with an integration interval identifier, and the integration interval identifier is fixedly marked as "transition interval". In other cases, only the risk level and confidence level are output.

[0074] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for intelligent detection and grading of defects in prefabricated bag packaging images, characterized in that, include: S1. Obtain defect images of prefabricated bag packaging, and extract geometric features and location information of defects in prefabricated bag packaging based on the defect images; S2. Introduce fuzzy membership functions to the various features of the defect for continuous processing. When the defect features are within the preset threshold range of adjacent defect levels, calculate the membership weights of each feature belonging to at least two defect levels. S3. Based on the spatial relationship between the defect location information and the load-bearing area of ​​the pre-made bag packaging, the weight coefficient corresponding to the defect area is dynamically adjusted. When the defect is located in a non-load-bearing area, the membership contribution of the defect area feature in the defect classification is reduced. S4. Through a multi-factor comprehensive analysis model, the geometric features, location weights, and membership results corresponding to the defect distribution density are fused and calculated to generate a comprehensive risk probability distribution of pre-made bag packaging defects. S5. Determine the distribution trend of the comprehensive risk probability within the preset fuzzy interval. When the comprehensive risk probability simultaneously covers the membership peaks of both moderate and severe defects, mark the corresponding defect sample as a sample to be reviewed and output the corresponding risk probability distribution curve. S6. Using a decision fusion method based on evidence theory, the conflict of multiple defect features of the sample to be reviewed is resolved. When there is a conflict between the membership degree of the defect area feature and the membership degree of the position weight, the preset expert knowledge base rules are triggered to make inference judgment. S7. Update the prefabricated bag packaging defect level label library based on the resolution results, generate a defect level mapping table with transition interval identifiers, and output the final prefabricated bag packaging defect risk level and its confidence assessment results. S1 includes: Images of pre-packaged bags are captured by a camera to obtain defect images of the pre-packaged bags. The geometric features in S1 include defect length, defect area, and defect distribution density. For the defect image, Gaussian filtering is used to remove noise to obtain a denoised defect image. Gaussian filtering smooths pixel values ​​through convolution operation to eliminate interference. Defect regions are extracted from denoised defect images using a threshold segmentation method. The defect length and defect area of ​​each region are then determined. The defect length is obtained by measuring the distance between boundary pixels, and the defect area is obtained by counting the number of pixels within the region. Based on the position of the defect area relative to the sealing area or the load-bearing area, the defect distribution density is determined and the location information is marked. The sealing area is the heat-sealed edge of the pre-made bag packaging, and the load-bearing area is the load-bearing support part of the pre-made bag packaging. The defect distribution density is obtained by calculating the number of pixels in the counting area per unit area. S3 includes: Defect location information and load-bearing area boundary are obtained from the defect image of pre-made bag packaging. The spatial relationship measurement between the defect location information and the load-bearing area boundary is calculated by coordinate mapping to obtain the spatial relationship measurement value. A preset threshold is used to determine non-load-bearing properties based on the spatial relationship measurement value. If the spatial relationship measurement value exceeds the preset threshold, the defect is determined to be located in a non-load-bearing area, and a non-load-bearing property determination result is obtained. The defect area is quantified based on the non-load-bearing judgment results, and the weighting coefficient is calculated by proportional reduction to determine the adjusted weighting coefficient. The sharpness of the defect edge is obtained as a supplementary feature, and the adjusted weight coefficient is fused to reduce the membership contribution of the defect area feature in the defect classification, thus obtaining the membership contribution value. S4 includes: Defect geometric quantization data and position weight fusion data are obtained from the defect images of pre-made bag packaging. The correlation between defect geometric quantization data and position weight fusion data is calculated through coordinate transformation to obtain the first correlation value. The distribution density is evaluated using a preset threshold for the first correlation value. If the first correlation value is lower than the preset threshold, the distribution density evaluation result is determined. The distribution density evaluation result is then fused with edge sharpness supplementary data by weighted averaging to obtain the first fused feature set. The area feature adjustment information of the first fused feature set is obtained, and the membership degree of the area feature adjustment information is calculated by fuzzy C-means clustering method. Fuzzy C-means clustering is a membership degree-based clustering method that achieves data grouping by iteratively optimizing the centroid and membership matrix, and determines the membership degree calculation result. S4 further includes: By processing the membership calculation results and non-load-bearing judgment data through spatial relationship measurement, the weight coefficient reduction value is obtained. The weight coefficient reduction value is then integrated with the defect color deviation data. The defect color deviation integration refers to calculating the difference between the RGB color component values ​​of the defect area and the standard color and normalizing it to obtain the comprehensive integration set. A comprehensive model analysis is adopted for the integrated set. The comprehensive model analysis refers to generating a comprehensive risk probability distribution of pre-made bag packaging defects by weighted summation and fusion of defect geometric quantification, location weight fusion and distribution density assessment of the corresponding membership results. Defect geometric quantification refers to defect geometric quantification data, including at least one of the parameters related to defect area, defect length and defect shape.

2. The method for intelligent detection and grading of defects in prefabricated bag packaging images according to claim 1, characterized in that: S2 includes: Color deviations of defects are obtained from images of pre-made bag packaging defects. Color deviation regions are extracted using a threshold segmentation method to obtain color deviation features. A fuzzy membership function is introduced to process the color deviation feature into a continuous form. The fuzzy membership function maps the defect feature value to the interval between zero and one through linear interpolation, thereby determining the membership value of the continuous feature. If the continuous feature is within the preset threshold range of adjacent defect levels, then calculate the membership weights of each of the at least two defect levels, and obtain the weight distribution by proportionally allocating the membership values. The location of the defect relative to the sealing area or load-bearing area of ​​the pre-made bag packaging is determined based on the weight distribution, and the center of the defect is located by weighted average.

3. The method for intelligent detection and grading of defects in prefabricated bag packaging images according to claim 1, characterized in that: S5 includes: Defect texture deviation integration data is obtained from the defect images of pre-made bag packaging. The defect texture deviation integration data refers to the difference between the texture value of the defect area and the standard texture and normalizes it. The correlation between the defect texture deviation integration data and the position weight fusion is calculated by coordinate transformation. The coordinate transformation refers to mapping the defect position coordinates to the weight space to obtain the second correlation value. The distribution density is evaluated using a preset threshold for the second correlation value. If the correlation value is lower than the preset threshold, the distribution density evaluation result is determined. The distribution density evaluation result is then fused with the defect geometric quantization by weighted averaging to obtain the second fused feature set.

4. The method for intelligent detection and grading of defects in prefabricated bag packaging images according to claim 3, characterized in that: The S5 also includes: The membership degree calculation results of the second fusion feature set are obtained, and the spatial relationship measurement processing of the membership degree calculation results is performed by the fuzzy C-means clustering method. The spatial relationship measurement processing refers to calculating the distance between cluster centers and adjusting the weights to obtain the weight coefficient reduction value. By integrating the reduced value of the weighting coefficient with the defect color deviation, a comprehensive set is obtained. A comprehensive model is then used to analyze and judge the distribution trend of the fuzzy intervals. The comprehensive model analysis refers to generating a probability distribution by weighted summation and fusion of the membership results. When the distribution trend of the fuzzy intervals covers the membership peak, the sample to be reviewed is marked, and the risk probability distribution is output.

5. The method for intelligent detection and grading of defects in prefabricated bag packaging images according to claim 1, characterized in that, S6 includes: The membership degree of defect area features and the membership degree of location weight are obtained from the sample to be reviewed. The degree of conflict is determined by calculating the absolute value of the difference between the two, and the conflict index value is obtained. For conflict index values, DS evidence theory is used to integrate multiple defects. The evidence theory merges evidence sources by assigning a trust function, obtains the basic probability distribution after fusion, and determines the unified membership degree after resolution. If the uniform membership degree exceeds the preset threshold, the preset expert knowledge rules are triggered to reason about the color deviation integration. The expert knowledge rules are a pre-established defect reasoning library, which yields the adjusted geometric quantization fusion result. By combining the geometric quantization fusion results with the fusion features of the samples to be reviewed, the correction value of the risk distribution output is determined, and the optimized sample label is obtained. Based on the optimized sample labeling and the integration of preset thresholds, the final defect conflict resolution status is determined.

6. The method for intelligent detection and grading of defects in prefabricated bag packaging images according to claim 1, characterized in that, S7 includes: Obtain packaging grade labels from defect resolution results, integrate preset historical defect data for packaging grade labels, and obtain an updated label library; The transition interval identifier is updated and generated based on the tag library. A hierarchical mapping table is constructed for the transition interval identifier, and the mapping table construction is determined. By constructing a mapping table and combining defect type classification, the risk level of prefabricated bag defects is determined, and the risk level output is obtained. The risk level output is obtained for confidence assessment. Based on the assessment results, an integrated interval identifier is generated to determine the final prefabricated bag packaging defect risk level and its confidence assessment result.