Machine vision-based test paper bag packaging detection system

By cropping the security margin area of ​​the seal, extracting the edge gradient values ​​of high-brightness pixels, constructing the edge contour path, and evaluating the closure and direction, the problem of inaccurate image area selection and discontinuous edges in the existing test paper bag packaging inspection is solved, and refined packaging quality inspection is achieved.

CN120598915BActive Publication Date: 2025-12-30CHENGDU RAILWAY ERJU WING KING TONG PRINTING LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510736276.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-12-30
Estimated Expiration
2045-06-04

AI Technical Summary

Technical Problem

The existing test paper bag packaging inspection system lacks a dynamic recognition mechanism for edge security parameters, resulting in inaccurate image region selection, insufficient grayscale processing, discontinuous edge extraction, imprecise direction consistency judgment, and non-specific defect output, making it difficult to achieve refined recognition.

Method used

The image acquisition module is used to crop the security margin area of ​​the seal, extract the edge gradient value based on the bright pixel area, construct the edge contour path, evaluate the contour closure and direction, and generate the packaging quality inspection result by comparing with the standard template.

Benefits of technology

It improves image focus and target feature saliency, ensures edge path continuity and structural regularity, enhances the accuracy of directional consistency assessment, and achieves refined identification and defect localization in test paper bag packaging inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120598915B_ABST
    Figure CN120598915B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of packaging detection, in particular to a test paper bag packaging detection system based on machine vision, which comprises an image acquisition module, a boundary construction module, a closure inspection module, a direction evaluation module and a quality judgment module.In the present application, the safe margin area of the seal is cut in image acquisition, the focusing of the effective image is improved, the edge contrast is strengthened by gray threshold screening, the target feature saliency is enhanced, the edge connection is constructed based on coordinate gradient, the path continuity and structure rules are ensured, the contour point column is generated in topological order, the breakpoint identification and closed state quantitative analysis are supported, the angle sequence is constructed by the direction difference of adjacent points, the direction consistency evaluation precision is improved by comparing with the standard template bit by bit, the defect positioning is output by combining the breakpoint coordinates and the direction deviation, the visualized directional marker is formed, the abnormal marker is clearly processed, and the test paper bag packaging detection fine identification is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of packaging and inspection technology, and in particular to a test paper bag packaging and inspection system based on machine vision. Background Technology

[0002] The field of packaging inspection technology encompasses the identification and judgment of the state of products during the packaging or encapsulation process. It primarily involves detecting whether packaging is complete, compliant with regulations, and whether there are defects in the packaging structure. The core content involves acquiring data from the packaged object through physical, optical, or imaging methods, and then using image analysis techniques for identification and analysis to determine whether the packaging state meets established standards. It has wide applications in industries such as logistics, manufacturing, and document management, and typically includes multiple stages such as image acquisition, image feature extraction, target area identification, data comparison, and output decision-making. In recent years, image recognition-based packaging inspection has gradually replaced manual visual inspection, becoming the mainstream technology in this field.

[0003] Among them, the machine vision-based test paper bag packaging inspection system refers to a system that acquires packaging image information of test paper bags through image acquisition equipment, and analyzes and judges key areas in the image to identify whether the packaging meets the specifications. This includes identifying and judging whether there is a seal on the sealing part of the test paper bag, whether the seal position is correct, and whether the seal stamp is clear. Specifically, it uses an industrial camera to acquire images, extracts edge features in the image through edge recognition methods, combines image morphology analysis methods to determine the seal coverage area, and then uses texture comparison methods to identify whether there are stamp marks. The packaging status is judged by comparing the structural features between the target area extracted in the image and the standard template.

[0004] In the current process of sealing and inspecting test paper bags, image region selection is usually based on a general area preset, lacking a dynamic recognition mechanism for edge security parameters. This easily leads to irrelevant areas being mistakenly included in the recognition scope, causing edge feature interference. In the grayscale processing stage, most only perform full-image threshold binarization, lacking strategies to enhance the grayscale features of the target area, resulting in unclear boundaries between effective seal feature signals and image noise. Edge extraction does not incorporate coordinate gradient and structural continuity judgments, relying solely on boundary contrast intensity, leading to difficulties in tracing breakpoints and non-structural closure of paths. There is a lack of quantitative detection methods for seal edge continuity, often relying solely on overall visual perception to assess seal integrity, failing to identify subtle structural defects. Directional consistency judgment is mainly based on overall texture or stamp area morphology, lacking an analysis mechanism for the direction angle of edge direction, limiting recognition accuracy to the tolerance range of texture matching. In the defect output stage, overall image anomaly identification is often used, without providing coordinates or structural references for specific defect locations, resulting in generalized output content and hindering defect tracing and subsequent correction. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of existing technologies and propose a machine vision-based test paper bag packaging and inspection system.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a machine vision-based test paper bag sealing and inspection system includes:

[0007] The image acquisition module acquires image information within the test paper bag seal detection area. The acquisition area is cropped by the safety margin parameter of the upper and lower edges of the seal strip, and the coordinates of pixels with gray values ​​greater than the binarization threshold are filtered to obtain the bright pixel area.

[0008] The boundary construction module extracts the gradient values ​​of all pixels in the X and Y axes based on the bright pixel region, filters point pairs to form effective edge connections, and arranges the path point coordinates in topological order to obtain the edge contour path.

[0009] The closure test module sets the first node of the path according to the edge contour path, searches point by point to see if adjacent directions form a continuous connection, marks the contour discontinuity points, counts all discontinuity points in the path and generates the coordinate index of the discontinuity area, determines the distribution of the discontinuity area, and obtains the contour closure analysis result.

[0010] The orientation evaluation module extracts the coordinate difference of adjacent point pairs based on the pixel connection order of the edge contour path, calculates the orientation angle sequence of each vector in sequence, extracts equal-length edge segments from the standard template image and constructs a reference orientation angle sequence, compares the angle difference of each position in the two sets of orientation sequences, and counts the proportion of sequence point pairs that meet the angle tolerance threshold to obtain the orientation comparison evaluation result.

[0011] As a further aspect of the present invention, the high-brightness pixel region includes high grayscale pixel distribution records, grayscale edge transition features, and brightness abrupt change structure points in the test paper bag seal image; the edge contour path includes pixel connection sequence structure, topological continuous point sequence, and edge closure direction information; the contour closure analysis results include the number of edge discontinuities, discontinuity coordinate distribution, and closure integrity level; and the direction comparison evaluation results include direction angle difference sequence, angle deviation statistical distribution, and registration angle matching rate.

[0012] As a further aspect of the present invention, the image acquisition module includes:

[0013] The image cropping submodule acquires image information within the test paper bag seal detection area, performs coordinate matching based on the safety margin parameters of the upper and lower edges of the seal strip, calculates the start and end positions of horizontal and vertical image cropping respectively, and performs matrix cropping operation in the original image matrix according to the start and end positions to generate a seal image matrix.

[0014] The grayscale analysis submodule calculates the corresponding grayscale value based on the RGB channel values ​​of all pixels in the seal image matrix, generates a grayscale histogram based on the distribution frequency of all grayscale values ​​in the interval, constructs a grayscale difference coefficient by calculating the difference between the peak position of the grayscale histogram and the concentrated distribution interval, and compares the grayscale difference coefficient with the standard reference value of the image grayscale interval to obtain the binarization threshold.

[0015] The highlight extraction submodule compares the gray values ​​of each pixel in the seal image matrix with the binarization threshold point by point, filters out pixels with gray values ​​greater than the binarization threshold, and collects the coordinates of all the filtered pixels in horizontal and vertical order. It then calculates the outermost boundary range of all pixel coordinates to obtain the highlight pixel region.

[0016] As a further aspect of the present invention, the boundary range of the outermost region is defined by the formula:

[0017] ;

[0018] Calculations are performed, in which, Represents the boundary area index. Indicates the first The horizontal coordinates of the highlighted pixels Indicates the first The vertical coordinates of the highlighted pixels This represents the total number of highlighted pixels obtained after threshold filtering. This represents the maximum x-coordinate among all pixels. This represents the minimum x-coordinate among all pixels. This represents the maximum value of the y-coordinate among all pixels. This represents the minimum ordinate value among all pixels. This indicates the horizontal expansion compensation term. This indicates a vertical expansion compensation term.

[0019] As a further aspect of the present invention, the boundary construction module includes:

[0020] The gradient calculation submodule calculates the difference in gray values ​​between adjacent pixels based on the coordinate positions of each pixel in the highlighted pixel region and the gray values ​​of adjacent pixels in the X and Y axes of the corresponding pixel in the seal image matrix. The difference result is then filled into the two-dimensional matrix according to the original coordinate positions of the pixel to generate the edge gradient matrix.

[0021] The edge filtering submodule determines the coordinates of all non-zero gradient points based on the edge gradient matrix, determines whether the 8-neighborhood connection condition is met based on the coordinate difference between each pair of points, and performs a merging operation on all point pairs that meet the condition to obtain a set of valid connection points.

[0022] The path construction submodule constructs a continuous path sequence according to the start and end coordinates of all point pairs in the effective connection point set, and performs topological sorting on the connection order of each point in the path sequence based on their relative positions in the image. The sorted path point set is then uniformly merged into a single directed coordinate path set to obtain the edge contour path.

[0023] As a further aspect of the present invention, the sealing inspection module includes:

[0024] The node retrieval submodule uses the first node in the edge contour path as the starting pixel point, reads the coordinate value of each node in the path in sequence, performs coordinate difference calculation on the coordinates of each node and the coordinates of subsequent nodes, and determines whether the difference falls within the standard set of coordinate differences in the X and Y directions. If the coordinate differences of subsequent nodes all meet the adjacency condition, they are confirmed as continuously connected nodes. If the connection condition is not met, the current node position is recorded and a set of connection interruption coordinates is generated.

[0025] The discontinuity marking submodule performs discontinuity marking operations at the corresponding coordinate positions in the image region based on the coordinates of all nodes in the connection interruption coordinate set. It constructs a two-dimensional coordinate index array according to the X and Y coordinates of the marked points, performs horizontal and vertical matching judgment on the continuity in the coordinate index array, and merges the coordinates of the start and end points of the continuous interruption segments to obtain the discontinuity region index set.

[0026] The closure analysis submodule expands the coordinate range of all coordinate index positions in the image coordinate plane based on the number and location distribution of all coordinate index positions in the discontinuous region index set. It calculates the maximum span value of the horizontal and vertical coordinate expansion intervals, and proportionally converts the span of the discontinuous interval according to the total path length to obtain the contour closure analysis result.

[0027] As a further aspect of the present invention, the direction evaluation module includes:

[0028] The direction extraction submodule, based on the coordinate positions of each pair of consecutive points in the edge contour path, sequentially counts the difference between each pair of points in the X-axis and Y-axis directions, calculates the direction angle value of the corresponding vector for each set of coordinate differences, and arranges all direction angle values ​​in the order of point pairs to generate a path direction sequence.

[0029] The template construction submodule extracts a set of continuous edge points of equal length according to the length of the path direction sequence based on the marked edge region path in the standard template image, calculates the coordinate difference between adjacent point pairs in the point set, and performs direction and angle transformation on each difference according to the point order to generate a reference direction sequence.

[0030] The angle matching submodule calculates the difference between two angle values ​​at the same position in the path direction sequence and the reference direction sequence, determines whether the difference is within the angle tolerance threshold range, counts all angle pairs that meet the conditions, and converts the number of angle pairs that meet the conditions to the total length of the direction sequence to obtain the direction comparison evaluation result.

[0031] As a further aspect of the present invention, the direction angle value is expressed by the formula:

[0032] ;

[0033] Calculations are performed, in which, Represents the direction angle value. Indicates the first The difference in lateral coordinates between consecutive edge points in a group. Indicates the first The difference in longitudinal coordinates between consecutive edge points in a group. This represents the average of the differences between the horizontal coordinates of all edge points. This is the adjustment coefficient in the lateral direction. For the direction of the denominator, the stable compensation term, This represents the constant value of pi.

[0034] As a further aspect of the present invention, the system further includes:

[0035] The quality judgment module determines whether the edge contour meets the closure standard and whether the direction sequence meets the registration tolerance requirements based on the contour closure analysis result and the direction comparison evaluation result. If either item is not met, the corresponding image is marked as having an anomaly. The defect area is marked by combining the coordinates of the discontinuous area and the position of the angle deviation segment, and the test paper bag sealing quality inspection result is generated.

[0036] The test paper bag sealing quality inspection results include test paper bag sealing status judgment information, defect marking area index, and abnormal image recognition label.

[0037] As a further aspect of the present invention, the quality determination module includes:

[0038] The closure judgment submodule compares the contour closure analysis results with the closure judgment benchmark value set in the closure standard. If the closure judgment benchmark is not met, the corresponding image is recorded as an abnormal test paper bag packaging image. If it is met, it is recorded as an initial qualified sample image. The recorded status is bound to the image index to generate the closure judgment result.

[0039] The orientation tolerance submodule extracts the corresponding orientation comparison evaluation result and compares it with the registration tolerance standard based on the initial qualified sample image in the closure judgment result. If the proportion value is less than the set benchmark value, the corresponding image is updated to an abnormal test paper bag packaging image. If the proportion value is greater than or equal to the benchmark value, the packaging is determined to be qualified. The orientation error index segment is obtained by recording the start and end range of the angle offset segment based on the position index of the abnormal image in the orientation sequence.

[0040] The defect annotation submodule cross-references the corresponding discontinuous region index set and directional offset segment position in the image based on the closure judgment result and the abnormal test paper bag packaging image recorded in the directional error index segment. It then combines and merges the corresponding regions in the image coordinate plane, marks the merged region with pixel regions, and obtains the test paper bag seal packaging quality inspection result.

[0041] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0042] In this invention, the safety margin area of ​​the seal is cropped during image acquisition to improve the focus of the effective image; grayscale threshold screening enhances edge contrast and increases the saliency of target features; edge connections are constructed based on coordinate gradients to ensure path continuity and structural regularity; contour point sequences are generated in topological order to support interruption point identification and closure state quantitative analysis; angle sequences are constructed by the direction difference between adjacent point pairs and compared with standard templates position by position to improve the accuracy of direction consistency assessment; and the combination of interruption coordinates and direction deviations outputs defect location, forming a visual directional label, which fully clarifies abnormal labels and achieves refined identification of test paper bag packaging inspection. Attached Figure Description

[0043] Figure 1 This is a system flowchart of the present invention;

[0044] Figure 2 This is a system module diagram of the present invention;

[0045] Figure 3 This is a flowchart of the image acquisition module of the present invention;

[0046] Figure 4 This is a flowchart of the boundary construction module of the present invention;

[0047] Figure 5 This is a flowchart of the closed inspection module of the present invention;

[0048] Figure 6 This is a flowchart of the orientation evaluation module of the present invention;

[0049] Figure 7 This is a flowchart of the quality judgment module of the present invention. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0051] In the description of this invention, it should be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, in the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0052] Please see Figure 1 and Figure 2 The machine vision-based test paper bag sealing and inspection system includes:

[0053] The image acquisition module acquires image information within the test paper bag seal detection area. The acquisition area is cropped by the safety margin parameters of the upper and lower edges of the seal strip (the edge allowance determined according to the test paper bag seal size standard GB / T 7705), the image matrix of the seal area is extracted, and combined with the image grayscale histogram, a binarization threshold is set, and the coordinates of pixels with grayscale values ​​greater than the binarization threshold are filtered to obtain the bright pixel area.

[0054] The boundary construction module extracts the gradient values ​​of all pixels in the X and Y axes based on the bright pixel region, constructs the edge gradient matrix, selects point pairs that meet the 8-neighborhood connection condition (the pixel adjacency relationship standard defined in digital image processing, with a coordinate difference of ±1 or ±√2) to form effective edge connections, and arranges the path point coordinates in topological order to obtain the edge contour path.

[0055] The closure test module sets the starting pixel as the first node of the path based on the edge contour path, and searches for whether adjacent directions form a continuous connection point by point. If a node does not have a subsequent connection direction, it is marked as a contour discontinuity point. All discontinuities in the path are counted and a discontinuity region coordinate index is generated. The distribution of discontinuity regions is determined based on the index set, and the contour closure analysis results are obtained.

[0056] The orientation evaluation module extracts the coordinate difference of adjacent point pairs based on the pixel connection order in the edge contour path, calculates the orientation angle sequence of each vector in sequence, extracts equal-length edge segments from the standard template image and constructs a reference orientation angle sequence, compares the angle difference of each position in the two sets of orientation sequences, and counts the proportion of sequence point pairs that meet the angle tolerance threshold (the allowable angle deviation set according to the detection accuracy requirements (usually ±5°)) to obtain the orientation comparison evaluation result.

[0057] The quality judgment module determines whether the edge contour meets the ISO2859-1 closure standard (international standard for sampling inspection procedures) and whether the direction sequence meets the registration tolerance requirements based on the contour closure analysis results and the direction comparison evaluation results. If any one of them is not met, the corresponding image is marked as having an anomaly. The module also marks the defect area by combining the coordinates of the discontinuous area and the position of the angle deviation segment, and generates the test paper bag sealing quality inspection results.

[0058] The high-brightness pixel area includes the high grayscale pixel distribution record, grayscale edge transition features, and brightness abrupt change structure points in the test paper bag seal image. The edge contour path includes the pixel connection sequence structure, topological continuous point sequence, and edge closure direction information. The contour closure analysis results include the number of edge discontinuities, discontinuity coordinate distribution, and closure integrity level. The direction comparison evaluation results include the direction angle difference sequence, angle deviation statistical distribution, and registration angle matching rate. The test paper bag seal packaging quality inspection results include test paper bag seal packaging status judgment information, defect annotation area index, and abnormal image recognition label.

[0059] Please see Figure 3 The image acquisition module includes:

[0060] The image cropping submodule acquires image information within the test paper bag seal detection area, performs coordinate matching based on the safety margin parameters of the upper and lower edges of the seal strip, calculates the start and end positions of horizontal and vertical image cropping respectively, and performs matrix cropping operation in the original image matrix according to the start and end positions to generate a seal image matrix.

[0061] The image cropping submodule acquires image information within the seal detection area of ​​the exam paper bag. First, it extracts the upper and lower edge positions of the seal strip from the overall image. Then, by scanning the grayscale gradient changes of each row of pixels in the image matrix, it detects the starting row of the upper boundary and the ending row of the lower boundary of the seal strip, and marks their row numbers accordingly. and Then, combined with the safety margin parameter (for example, set to 20 pixels), the starting cropping position is shifted upwards by this margin value. The cut position is shifted downwards by this margin value to terminate the cut. If the image height range is 1080 pixels, the top edge detection is at row 300, and the bottom edge detection is at row 500, then the final vertical cropping start and end actions will be determined accordingly. Then, horizontal boundary cropping is performed. By observing the variation range of pixel intensity in the seal area, the start and end columns of the seal content are identified and set as follows: and And generate by adding 20 pixels of margin on each side. , Assuming the actual detected area of ​​the seal strip is located between columns 150 and 900, the horizontal cutting range should be [missing information]. After obtaining the start and end crop coordinates, the image matrix slicing operation function is called to extract submatrices, that is, through matrix slicing as follows: The rectangular region of the original image is extracted into a seal image matrix.

[0062] The grayscale analysis submodule calculates the corresponding grayscale value based on the RGB channel values ​​of all pixels in the seal image matrix, generates a grayscale histogram based on the distribution frequency of all grayscale values ​​within the interval, constructs a grayscale difference coefficient by calculating the difference between the peak position of the grayscale histogram and the concentrated distribution interval, and compares the grayscale difference coefficient with the standard benchmark value of the image grayscale interval to obtain the binarization threshold.

[0063] The grayscale analysis submodule first calculates the grayscale value of each pixel based on the RGB channel values ​​of all pixels in the seal image matrix, and then uses a weighted average method with the formula... Calculate the grayscale value for each point, and round all grayscale values ​​to the nearest integer and then classify them into the grayscale value range. For integer values, count the frequency of each grayscale value, construct a grayscale histogram, and represent it as an array, such as... Then, the gray value containing the highest frequency in the histogram is determined as the peak position. For example, if the peak frequency is the highest value appearing in... The peak gray level is 82. To define the concentrated distribution range, the standard deviation method can be used, extending one standard deviation σ to the left and right of the mean gray level μ of the entire image as the center to form the range. If the image mean μ=85 and standard deviation σ=20, then the concentration interval is... Next, the difference between the peak value and the center value of the concentration interval is calculated, and the difference is expressed as an absolute difference. After normalization, it is expressed as the coefficient of difference. And set a grayscale difference standard benchmark value. If the two are compared This indicates that the grayscale difference is small, and a lower binarization threshold should be used. The specific threshold... The setting can be based on the upper bound of the set interval minus the difference value, i.e. Finally, the binarization threshold for this image is determined to be 102.

[0064] The highlight extraction submodule compares the gray values ​​of each pixel in the seal image matrix with the binarization threshold point by point, filters out pixels with gray values ​​greater than the binarization threshold, and collects the coordinates of all the filtered pixels in the order of horizontal and vertical positions. It then calculates the outermost boundary range of all pixel coordinates to obtain the highlight pixel region.

[0065] The outermost boundary of the region is defined by the formula:

[0066] ;

[0067] Calculations are performed, in which, Represents the boundary area index. Indicates the first The horizontal coordinates of the highlighted pixels Indicates the first The vertical coordinates of the highlighted pixels This represents the total number of highlighted pixels obtained after threshold filtering. This represents the maximum x-coordinate among all pixels. This represents the minimum x-coordinate among all pixels. This represents the maximum value of the y-coordinate among all pixels. This represents the minimum ordinate value among all pixels. This represents the horizontal expansion compensation term, and its value is the square root of the variance of the horizontal coordinates of all highlighted pixels in the image. This represents the vertical expansion compensation term, which is the average of the absolute values ​​of the deviations between the vertical coordinates of all highlighted pixels in the image and their average value.

[0068] For example, if the current image width is 1920 pixels and the height is 1080 pixels, after extracting the image seal area and performing binarization, the number of highlighted pixels is: Data analysis shows that the horizontal coordinates of all highlighted pixels range from 130 to 918, and the vertical coordinates range from 260 to 722. Therefore:

[0069] ;

[0070] ;

[0071] Horizontal expansion compensation item The setting is based on the standard deviation of the horizontal coordinate set, that is, the degree to which the horizontal coordinates deviate from the average position, and the formula is:

[0072] ;

[0073] Among them, the average value of the horizontal axis The image detection system statistically determined the value to be 525. Using a normalized coordinate sample calculation method, the x-coordinate of each point was read, and after batch processing and calculation with the sample values, the result was:

[0074] ;

[0075] Vertical expansion compensation item The setting is based on the average absolute deviation of the ordinate set, and its quantification standard is the average absolute value of the deviations of the ordinates of all highlighted pixels from the ordinate mean. The calculation formula is:

[0076] ;

[0077] Among them, the vertical average coordinate The data processing result is 485, from which the following calculations are made:

[0078] ;

[0079] Substitute all the obtained values ​​into the boundary area calculation formula:

[0080] ;

[0081] Expand the calculation:

[0082] ;

[0083] The result shows that the boundary area is 427438.32 pixels, which represents the minimum envelope region of the overall distribution of all selected bright pixels. The result will be used as the outer boundary of the bright region and used for subsequent image cropping rectangular region generation.

[0084] The boundary area metric represents the size of the smallest rectangular envelope region formed by all the bright pixels in an image. It quantifies the size of the outer boundary of the distribution range of such pixels in the image space. This metric reflects not only the concentration and diffusion of bright pixels in the image but also their span and cluster density in both horizontal and vertical dimensions. A larger boundary area indicates a more dispersed distribution or wider coverage of bright pixels, while a smaller boundary area indicates stronger clustering or denser distribution of these pixels. This metric can be used for subsequent image cropping region localization, shape description of target region detection, and spatial structure analysis in image feature extraction, providing a quantitative basis for the structured processing of image content.

[0085] The calculation logic in the formula originates from modeling the geometric envelope features of the spatial distribution of pixels in a two-dimensional image. The outermost boundary range needs to be determined based on the difference between the maximum and minimum values ​​of the horizontal and vertical coordinates to determine the overall expansion interval. The difference between the maximum and minimum values ​​is used to represent the original span of the pixel in the corresponding direction. An expansion compensation term is added to introduce the discreteness of the coordinate distribution. The horizontal and vertical boundary lengths are obtained by adding a horizontal compensation term to the difference between the maximum and minimum horizontal coordinates, and adding a vertical compensation term to the difference between the maximum and minimum vertical coordinates, respectively. The corresponding addition operation reflects the merging of the main span of the coordinates and the discrete expansion. The multiplication operation represents the combination of the horizontal and vertical envelope boundaries into an area, reflecting the two-dimensional coverage of the boundary range. The horizontal compensation term includes the square root operation of the coordinate variance to express the average dispersion of the pixel distribution, reflecting the influence range of the coordinate point density change. The vertical compensation term uses the sum of absolute deviations to measure the looseness of the vertical central tendency, emphasizing the contribution of outliers in the vertical axis direction to the expansion of the boundary, thereby achieving a reasonable combination of different types of dispersion in the horizontal and vertical directions. The overall formula uses the maximum and minimum value operation to define the coordinate range boundary, and combined with the compensation parameters, it improves the ability to depict the true envelope of the actual bright area, logically realizing a reasonable mapping from the discrete point set to the rectangular boundary region.

[0086] Please see Figure 4 The boundary construction module includes:

[0087] The gradient calculation submodule calculates the difference in gray values ​​between adjacent pixels based on the coordinates of each pixel in the highlighted pixel region and the gray values ​​of adjacent pixels in the X and Y axes of the corresponding pixel in the seal image matrix. The difference result is then filled into the two-dimensional matrix according to the original coordinates of the pixel to generate the edge gradient matrix.

[0088] The gradient calculation submodule extracts the current grayscale value from the seal image matrix for each pixel's coordinates (x, y) within the highlighted pixel region. And the adjacent gray values ​​on the left and right sides in the X-axis direction. , and adjacent gray values ​​in the Y-axis direction , The gradient values ​​of the X-axis are calculated using a difference method. The gradient value of the Y-axis is To avoid index out-of-bounds errors, when (x, y) is at an edge, the point must be skipped or filled with a mirrored boundary value. Then, the absolute values ​​of the differences between the X and Y axes are calculated and combined to obtain the final gradient value for that point, which is set as follows: For example, if the gray value of a certain point is 112, and the gray values ​​on the left and right are 130 and 100 respectively, then the difference on the X-axis is 30, the gray values ​​on the Y-axis are 115 and 90, and the difference on the Y-axis is 25. Therefore, the gradient value of this point is 55. The gradient values ​​of all pixels in the highlighted area are filled into a two-dimensional matrix with the same size as the image according to their (x, y) positions. The gradient values ​​of pixels not in the highlighted area are set to 0. After filling point by point in this way, a complete edge gradient matrix is ​​generated.

[0089] The edge filtering submodule determines the coordinates of all non-zero gradient points based on the edge gradient matrix, determines whether the 8-neighborhood connection condition is met based on the coordinate difference between each pair of points, and performs a merging operation on all point pairs that meet the condition to obtain a set of valid connection points.

[0090] The edge filtering submodule, based on the edge gradient matrix, first iterates through all pixels in the matrix, checking if the gradient value of each point is greater than 0. If it is, its coordinates (x, y) are added to the list of non-zero gradient points. Then, it pairs these points together and calculates the difference between the horizontal and vertical coordinates of each pair. , If satisfied and If the condition is met, the pair of points is determined to be a pair of points with the 8-neighborhood connection condition. For pairs of points that meet the condition, the smaller coordinate value is used as the starting point and the larger coordinate value is used as the ending point. The connection set is expanded and merged in groups, and all connection point sets are gradually expanded into one or more continuous connection segments. The disjoint-set data structure is used to gradually group the point sets in the same segment into one class. When a point has a connection relationship with multiple merged points, the point is added to the current segment set and the segment boundary is expanded. For example, if points A = (150, 200), B = (151, 200), and C = (151, 201), then A and B satisfy the 8-neighborhood connection condition, and B and C also satisfy the connection condition. Therefore, the three points are merged into the same connection point set, thereby obtaining a valid connection point set.

[0091] The path construction submodule constructs a continuous path sequence according to the start and end coordinates of all point pairs in the effective connection point set, and performs topological sorting on the connection order of each point in the path sequence based on their relative positions in the image. The sorted path point set is then uniformly merged into a single directed coordinate path set to obtain the edge contour path.

[0092] The path construction submodule first establishes a mapping structure from coordinate pairs to connection order based on the start and end coordinates of all point pairs in the valid connection point set. Each point pair uses the start point as the key and the end point as the value. Then, starting from any unvisited start point, it searches for the next connection point according to the mapping, advancing point by point to form a continuous path sequence. It records the coordinate position of each node in the path, constructing a directed path chain from the start point to the end point. For cases where there are multiple branches or intersections in the path sequence, it calculates the in-degree and out-degree of each node. The intermediate node with an in-degree of 1 and an out-degree of 1 is selected as the stable continuation node of the path. The topology is sorted from left to right and top to bottom according to the starting coordinates. The sorting is based on the vertical priority of the node coordinates, followed by the horizontal comparison. For example, when there are points (150, 200), (150, 201), and (151, 201), (150, 200) is sorted first, then (150, 201), and finally (151, 201). After sorting, all path segments are merged into a directed coordinate path set in order to obtain the edge contour path.

[0093] Please see Figure 5 The closed-loop inspection module includes:

[0094] The node retrieval submodule uses the first node in the edge contour path as the starting pixel point, reads the coordinate value of each node in the path in sequence, performs coordinate difference calculation on the coordinates of each node and the coordinates of subsequent nodes, and determines whether the difference falls within the standard set of coordinate differences in the X and Y directions. If the coordinate differences of subsequent nodes all meet the adjacency condition, they are confirmed as continuously connected nodes. If the connection condition is not met, the current node position is recorded and a set of connection interruption coordinates is generated.

[0095] The node retrieval submodule uses the first node in the edge contour path as the starting pixel. It reads the coordinates (x1, y1) of each node in the path sequence and calculates the difference between the horizontal and vertical coordinates of each node and its subsequent node (x2, y2). The calculations are Δx = |x2−x1| and Δy = |y2−y1|, respectively. The Δx and Δy are then paired into a coordinate difference pair (Δx, Δy) and compared one by one with the standard adjacency set S. The standard set S is defined as S = {(0, 1), (1, 0), (1, 1), (1, −1), (−1, 1), (−1, 0), (0, −1), (−1, −1)}, representing the allowed directional combinations of 8 adjacencies. If the difference pair belongs to S, the current node and the next node are considered continuous nodes; otherwise, they are considered connected. Therefore, the current node (x1, y1) is marked as a connection interruption node and stored in the connection interruption coordinate set. In the example, if there are nodes (200, 300), (201, 300), and (202, 301) in the path sequence, then the difference between (200, 300) and (201, 300) is (1, 0), which belongs to S and is determined to be continuous. The difference between (201, 300) and (202, 301) is (1, 1), which is also in S. However, if there is (204, 303) afterward, and the difference between it and the previous point (202, 301) is (2, 2), then the adjacency condition is not met. Therefore, (202, 301) is recorded as an interruption node. After iterating through the entire path, the connection interruption coordinate set C is obtained, and its elements constitute the path interruption point set.

[0096] The discontinuity marking submodule performs discontinuity marking operations at the corresponding coordinate positions in the image region based on the coordinates of all nodes in the connection interruption coordinate set. It constructs a two-dimensional coordinate index array according to the X and Y coordinates of the marked points, performs horizontal and vertical matching judgment on the continuity in the coordinate index array, and merges the coordinates of the start and end points of the continuous interruption segments to obtain the discontinuity region index set.

[0097] The discontinuity marking submodule, based on the coordinates of all nodes in the connection break coordinate set, sequentially accesses each coordinate point (x, y) in the set and marks the corresponding pixel value in the original image matrix. For example, the pixel grayscale value at that position can be set to a special marker value such as 255 to indicate that the point is a discontinuity. After marking, a two-dimensional coordinate index array A is constructed, where A[i][j]=1 indicates that the position (x=i, y=j) is a discontinuity, and A[i][j]=0 indicates that it is not a discontinuity. Then, the array A is scanned and matched. In the horizontal direction, for a fixed row i, column index j is traversed from left to right. If multiple positions with A[i][j]=1 appear consecutively, the matching is performed. If a line is considered to have a continuous interruption segment, the starting column j1 and the ending column j2 are recorded. The same applies to the vertical line. For a fixed column j, the row index i is traversed. If A[i][j] = 1 continuously, then i1 and i2 are recorded as the vertical boundary of the interruption segment. All coordinate segments that meet the horizontal or vertical continuity conditions are assigned to a new set of discontinuous regions R. Each region records its starting and ending coordinates. For example, if a segment has continuous discontinuities in columns j=450 to j=470 in row i=310, then its region index is (310, 450) - (310, 470). All such regions are merged one by one to obtain a complete set of discontinuous region indexes.

[0098] The closure analysis submodule expands the coordinate range of all coordinate index positions in the image coordinate plane based on the number and location distribution of all coordinate index positions in the discontinuous region index set. It calculates the maximum span value of the horizontal and vertical coordinate expansion intervals, and proportionally converts the span of the discontinuous interval according to the total path length to obtain the contour closure analysis result.

[0099] The closure analysis submodule calculates the horizontal span Sx = |x2−x1| and the vertical span Sy = |y2−y1| for each discontinuous region index interval (e.g., start point (x1, y1), end point (x2, y2)) based on the number and distribution of all coordinate index positions in the discontinuous region index set. If the start and end points of a discontinuous segment are (310, 450) - (310, 470), then Sx = 0 and Sy = 20, and the current discontinuous region span value S = Sx + Sy = 20 is recorded. The module iterates through all discontinuous regions to obtain the maximum span value Smax. In this example, if the maximum span is 32, then Smax = 32. At the same time, the total path length L is called. p is determined by the total number of points in the contour path. Assuming the total number of nodes in the path is 768, then Lp = 768. The closure degree is then calculated proportionally as D = Smax / Lp = 32 / 768 ≈ 0.0417. This value is defined as the contour closure degree analysis result. The closer the closure degree value is to 0, the shorter the broken part in the contour path. If a reasonable threshold Tclosure = 0.05 is set as the judgment benchmark, then when D ≤ Tclosure, the path is considered basically closed. If D > Tclosure, the path is considered to have an unclosed problem. In this example, D ≈ 0.0417 < 0.05, indicating that the contour closure degree meets the standard. Finally, the contour closure degree analysis result is obtained.

[0100] Please see Figure 6 The direction evaluation module includes:

[0101] The direction extraction submodule is based on the coordinate positions of each pair of consecutive points in the edge contour path. It counts the difference between each pair of points in the X-axis and Y-axis directions in sequence, calculates the direction angle value of the corresponding vector for each set of coordinate differences, and arranges all direction angle values ​​in the order of point pairs to generate a path direction sequence.

[0102] The direction angle value is calculated using the formula:

[0103] ;

[0104] Calculations are performed, in which, Represents the direction angle value. Indicates the first The difference in lateral coordinates between consecutive edge points in a group. Indicates the first The difference in longitudinal coordinates between consecutive edge points in a group. This represents the average of the differences between the horizontal coordinates of all edge points. This is the horizontal adjustment coefficient, whose value is derived from the maximum percentage difference in the horizontal differences of all edge segments, and its value is... , The directional denominator is a stability compensation term, the value of which is extracted from the variance of the rate of change of direction at the image resolution. , This represents the constant value of pi, and its value is... .

[0105] The coordinates of the 5th pair of points on a certain path are as follows: and The difference is:

[0106] ;

[0107] ;

[0108] Mean of the horizontal difference between all points in this segment Substituting into the formula, we get:

[0109] ;

[0110] Intermediate calculation process:

[0111] ;

[0112] ;

[0113] ;

[0114] The result shows that the directional angle feature value is 36.85 degrees, which represents the orientation angle characteristics of the current edge point pair. After being arranged in the order of point pairs, it forms a complete directional angle sequence for subsequent alignment and angle matching with the template direction information.

[0115] The directional angle value represents the spatial direction of the vector formed between two consecutive edge path points. It is used to quantitatively describe the local direction change of the path at that point segment. The angle value is determined based on the horizontal direction in the Cartesian coordinate system as the reference starting point, and the angle is determined by calculating counterclockwise from the positive X-axis direction. It reflects the specific directional trend of the path extending along the edge in the two-dimensional image. When the angle value is close to 0 degrees or 180 degrees, it indicates that the path tends to extend horizontally. When it is close to 90 degrees or 270 degrees, it indicates that the path extends vertically or in the opposite vertical direction. The continuous distribution sequence of different angle values ​​can characterize the morphological features, boundary trends and local change patterns of the image contour. It is an important geometric feature quantity used to describe morphological differences in the process of image directionality recognition and path matching.

[0116] The formula's operational logic centers on the relative geometric changes between consecutive point pairs. The numerator uses a weighted sum of vertical and horizontal deviations from the mean, reflecting the vertical trend of each point pair and correcting for anomalies in horizontal changes. Therefore, for... Introducing adjustment coefficient Added later In this process, the dominance of the longitudinal component over the direction and angle is enhanced; the denominator constructs the overall length modulus of a set of point-to-vector pairs, and through... This represents the Euclidean distance between two-dimensional vectors, plus a constant term. To control angular fluctuations along short vectors, a square root is taken after summing the squares to form a normalized length of the direction vector, avoiding drastic angular fluctuations within small ranges. The overall fractional structure forms a direction ratio primarily correcting for longitudinal changes, which is then multiplied by... The radian value is converted into an angle, and the angle range is controlled by modulo 360 to fall within the standard period interval, thus obtaining the standard direction angle value for each pair of points.

[0117] The template construction submodule extracts a set of continuous edge points of equal length according to the length of the path direction sequence based on the marked edge region path in the standard template image, calculates the coordinate difference between adjacent point pairs in the point set, and performs direction and angle transformation on each difference according to the point order to generate a reference direction sequence.

[0118] The template construction submodule, based on the marked edge region paths in the standard template image, first obtains the set of edge path coordinate points P_t={(x1, y1), (x2, y2), ..., (x_m, y_m)} in the template image. Following the principle of having the same length n as the original path direction sequence A, it selects n consecutive point pairs starting from the marked path origin to form a sub-path P_s={(x1, y1), ..., (x_{n+1}, y_{n+1})}, constructing n sets of adjacent point pairs. Then, it repeatedly performs the direction difference extraction operation on each set of point pairs, calculating Δx_i=x_{i+1}−x_i and Δy_i=y_{i+1}−y_i, and calculating the direction angle θ_i=arctan2(Δy_i, Δx_i) for each set, converting it to the angle value θ_i'=θ_i×180 / π, forming the standard direction angle sequence B=[θ1', θ2', ..., θ n For example, if the starting coordinates in the template path are selected as (50, 100), and the subsequent points are (53, 103) and (56, 106), then the difference between the first two points is Δx=3, Δy=3, and the angle is 45°, forming the first item of the sequence. After traversing, the standard path direction angle sequence is generated. The length of this sequence is the same as the direction sequence of the image to be inspected.

[0119] The angle matching submodule calculates the difference between two angle values ​​at the same position in the path direction sequence and the reference direction sequence, determines whether the difference is within the angle tolerance threshold range, counts all angle pairs that meet the conditions, and converts the number of angle pairs that meet the conditions to the total length of the direction sequence to obtain the direction comparison evaluation result.

[0120] The angle matching submodule matches the path direction sequence A=[θ1, θ2, ..., θ... n ] and the reference direction sequence B=[φ1, φ2, ..., φ n For each group (i), the angle values ​​at the same position are calculated. The difference is calculated as δi = |θi−φi|. It is determined whether the difference is within the preset angle tolerance threshold T_θ. The threshold T_θ is set to 15°. If δi ≤ T_θ, the angle pair is determined to be a matching angle pair. The initial design variable C is 0. For each matching angle pair, C = C + 1 is executed. After traversing all n angles, the total number of matches C is obtained. For example, if n = 30 and the number of matching angle pairs is 26, then C = 26. Then, the matching ratio R = C / n = 26 / 30 = 0.867 is calculated proportionally. The ratio R is output as the direction evaluation result. The evaluation value range is [0, 1]. According to the actual judgment standard, the matching ratio R ≥ 0.85 is considered to be consistent in direction. Otherwise, it is considered to be a deviation in direction. This ratio is the final direction comparison evaluation result.

[0121] Please see Figure 7 The quality assessment module includes:

[0122] The closure judgment submodule compares the contour closure analysis results with the closure judgment benchmark value set in the ISO2859-1 closure standard. If the closure judgment benchmark is not met, the corresponding image is recorded as an abnormal test paper bag packaging image. If it is met, it is recorded as an initial qualified sample image. The recorded status is bound to the image index to generate the closure judgment result.

[0123] The closure judgment submodule compares the contour closure analysis results with the closure judgment benchmark value set in the ISO2859-1 closure standard. First, it extracts the closure value Dclosure corresponding to the image. The closure value is calculated by the previous module and is expressed as the ratio of the maximum discontinuity span in the path to the total path length. Let Dclosure = 0.0417. Then, it sets the judgment benchmark value Tclosure under the ISO2859-1 standard to 0.05. Then, it performs the judgment operation: if Dclosure > Tclosure, it means that the closure degree of the seal contour of the current image does not meet the standard judgment requirements. Record the index number of the current image and its corresponding status as "abnormal test paper bag sealing image". If Dclosure ≤ Tclosure, it is judged as an initial qualified sample image. Record its index number and assign it the "qualified" status. Then, bind the image index ID with its closure status to form a data pair structure such as (image ID_i, status identifier). Finally, it generates a set of closure judgment results for all images in batches: Rclosure = {(ID_1, "qualified"), (ID_2, "abnormal"), ...}.

[0124] The direction tolerance sub-module extracts the corresponding direction comparison evaluation result based on the initial qualified sample image in the closed determination result and compares it with the registration tolerance standard. If the ratio is less than the set reference value, the corresponding image identification status is updated to an abnormal test paper bag packaging image. If the ratio is greater than or equal to the reference value, it is determined that the packaging is qualified. According to the position index of the abnormal image in the direction sequence, the start and end ranges of the angle offset segment are recorded to obtain the direction error index segment.

[0125] The direction tolerance sub-module filters out the image set with the status flag of "qualified" according to the initial qualified sample image in the closed determination result. For each image in this set, its direction comparison evaluation ratio Rdir is extracted. This ratio represents the proportion of the angle pairs that match the standard template direction in the direction sequence of the image path. The direction registration tolerance reference value Tdir = 0.85 is set, and the comparison operation is performed on each qualified image in turn. If Rdir < Tdir, the current image status is updated to "abnormal test paper bag packaging image". If Rdir ≥ Tdir, the "qualified" status is maintained. At the same time, for the image whose status is updated to abnormal, the list of angle pairs of its direction sequence A = [θ1, θ2,..., θ n and the standard template direction sequence B = [φ1, φ2,..., φ n are read. The difference δi = |θi - φi| is calculated for all serial numbers i. When δi > Tθ (assuming Tθ = 15°), this serial number is recorded as an offset item, and the continuous offset serial number paragraph is used as the angle offset segment. The abnormal start and end serial number positions of this image in the direction sequence are further marked. For example, if δ8 to δ 12 all exceed the threshold, the offset segment index [8, 12] is recorded, and the mapping relationship Mdir = {ID_j: [start_k, end_k]} is constructed between the image ID and its direction offset segment. Finally, the set of direction error index segments of all direction abnormal images is obtained.

[0126] The defect annotation sub-module cross-references the discontinuous region index set corresponding to the image and the position of the direction offset segment recorded in the closed determination result and the direction error index segment for the abnormal test paper bag packaging image, combines and merges the corresponding region ranges of the two in the image coordinate plane, fills and marks the pixel region of the merged region, and obtains the test paper bag seal packaging quality detection result.

[0127] The defect annotation submodule, based on the closure judgment result and the abnormal test paper bag packaging image recorded in the direction error index segment, cross-references the corresponding discontinuous region index set Rgap and the direction offset segment position index Rdir in the image. First, it reads the image ID corresponding to the "abnormal" status in Rclosure, and extracts its discontinuous region index range as multiple start and end coordinate segments, such as Rgap=[(x1, y1)-(x2, y2), (x3, y3)-(x4, y4)]. Then, it reads the direction offset segment index in Rdir, and combines it with the coordinate point position corresponding to each angle in the image path sequence to determine the pixel position coordinates corresponding to the offset segment angle. For example, the path coordinate points corresponding to index segment [8, 12] are [(x8, y8), ..., (x...). 12 y 12 By cross-referencing the path coordinates with the coordinates of the discontinuous regions, it is determined which regions have spatial overlap or adjacent pixel regions. All overlapping regions or regions with an interval of no more than 3 pixels are identified as joint defect regions. A merging operation is performed on these joint regions to extract the coordinate boundary of the smallest bounding rectangle and construct the border of the sealing defect region. Then, the region is marked with pixel filling. The mark value can be set to grayscale 255 or a specific color code value (255, 0, 0). Finally, the image matrix with defect markings is output as the test paper bag sealing quality inspection result.

[0128] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A machine vision based test paper bag packaging detection system, characterized in that: The system comprises: The image acquisition module acquires image information in the test paper bag seal detection area, the collection area is cut by the safety margin parameters of the upper and lower edges of the seal strip, and pixel point coordinates with a gray value greater than a binary threshold value are screened to obtain a highlight pixel area; The image acquisition module comprises: The image cutting submodule acquires image information in the test paper bag seal detection area, performs coordinate matching based on the safety margin parameters of the upper and lower edges of the seal strip, calculates the start and end positions of the horizontal and vertical image cutting respectively, and performs matrix cutting operation in the original image matrix according to the start and end positions to generate a seal image matrix; The gray scale analysis submodule calculates corresponding gray values according to the RGB channel values of all pixel points in the seal image matrix, generates a gray scale histogram according to the distribution frequency of all gray values in the interval, constructs a gray difference coefficient by counting the difference between the peak value position and the concentrated distribution interval of the gray scale histogram, and compares the gray difference coefficient with a standard reference value of the image gray interval to obtain a binary threshold value; The highlight extraction submodule performs point-by-point comparison between the binary threshold value and the gray values of each pixel in the seal image matrix, screens the pixel points with a gray value greater than the binary threshold value, collects the coordinate positions of all screened pixel points in the order of horizontal and vertical positions, calculates the outermost boundary range of all pixel coordinates, and acquires a highlight pixel area; The boundary construction module extracts the gradient values of all pixel points in the X and Y axis directions based on the highlight pixel area, screens the point pairs to form effective edge connections, arranges the path point coordinates in topological order to obtain an edge contour path; The closed inspection module sets a path first node according to the edge contour path, point by point inspects whether the adjacent direction constitutes a continuous connection, marks the contour discontinuity points, counts all the discontinuity points in the path and generates a discontinuity region coordinate index, determines the discontinuity region distribution, and obtains a contour closure degree analysis result; The closed inspection module comprises: The node retrieval submodule takes the first node in the edge contour path as the starting pixel point, reads the coordinate values of each node in the path in turn, performs coordinate difference value operation on each node coordinate and the coordinate of the subsequent node, judges whether the difference value falls into the standard set of X direction and Y direction coordinate difference values, if the coordinate difference values of the subsequent nodes all satisfy the adjacency condition, it is confirmed as a continuous connection node, if the connection condition is not satisfied, the current node position is recorded to generate a connection interruption coordinate set; The discontinuity marking submodule performs discontinuity marking operation on the corresponding coordinate position in the image area according to all node coordinates in the connection interruption coordinate set, constructs a two-dimensional coordinate index array according to the X and Y coordinates of the marking points, matches and judges the continuity in the coordinate index array in the horizontal and vertical directions, merges the starting point and ending point coordinates of the continuous interruption paragraph to obtain an interruption region index set; The closure analysis submodule performs coordinate expansion in the distribution range in the image coordinate plane according to the number and position distribution of all coordinate index positions in the interruption region index set, calculates the maximum span value of the coordinate expansion interval in the horizontal and vertical directions, proportionally converts the interruption interval span according to the total length of the path to obtain a contour closure degree analysis result. The direction evaluation module extracts coordinate difference values of adjacent point pairs based on the edge contour path pixel connection order, sequentially calculates direction angle sequences of vectors, extracts equal-length edge segments from a standard template image and constructs a reference direction angle sequence, compares angle difference at each position in the two direction sequences, and obtains a direction comparison evaluation result by counting the proportion of sequence point pairs that meet an angle tolerance threshold. The quality judgment module judges whether the edge contour meets the closure standard and whether the direction sequence meets the registration tolerance requirement based on the contour closure degree analysis result and the direction comparison evaluation result, marks the corresponding image as abnormal if any of the conditions is not met, labels a defect area based on the coordinates of the discontinuous area and the position of the angle deviation segment, and generates a test paper bag seal packaging quality detection result.

2. The machine vision-based test paper bag packaging detection system according to claim 1, wherein: The highlight pixel region includes high gray pixel distribution records, gray edge transition features, and brightness mutation structure points in the test paper bag seal image. The edge contour path includes pixel connection order structures, topological continuous point columns, and edge closure trend information. The contour closure degree analysis result includes edge discontinuity number, discontinuity coordinate distribution, and closure integrity level. The direction comparison evaluation result includes direction angle difference sequence, angle deviation statistical distribution, and registration angle matching rate.

3. The machine vision-based test paper bag packaging detection system according to claim 1, wherein: The outermost connection area boundary range is calculated using the formula: B = (x - x area represents the boundary area index, x i represents the horizontal coordinate of the i-th highlight pixel, y i represents the vertical coordinate of the i-th highlight pixel, n represents the total number of highlight pixels after threshold screening, represents the maximum horizontal coordinate of all pixels, represents the minimum horizontal coordinate of all pixels, represents the maximum vertical coordinate of all pixels, represents the minimum vertical coordinate of all pixels, δ x represents the horizontal expansion compensation term, δ y represents the vertical expansion compensation term.

4. The machine vision-based test paper bag packaging detection system according to claim 1, wherein: The boundary construction module includes: The gradient calculation submodule calculates the difference between the gray values of adjacent pixels in the X and Y axes based on the coordinate positions of each pixel in the highlight pixel region, fills the difference results into a two-dimensional matrix according to the original coordinate positions of the pixel points, and generates an edge gradient matrix. The edge screening submodule determines the coordinate positions of all non-zero gradient points based on the edge gradient matrix, judges whether each pair of points meets the 8-neighbor connection condition based on the coordinate difference between them, and merges all points that meet the condition to obtain an effective connection point set. The path construction submodule constructs a continuous path sequence based on the start and end coordinates of all point pairs in the effective connection point set, topologically sorts the connection order of each point in the path sequence, and merges the sorted path point set into a single directed coordinate path set to obtain an edge contour path.

5. The machine vision-based test paper bag packaging detection system according to claim 1, wherein: The direction evaluation module includes: The direction extraction submodule sequentially calculates the difference between each pair of points in the X and Y axes based on the coordinate positions of each continuous point pair in the edge contour path, calculates the direction angle value of the corresponding vector for each group of coordinate difference values, and arranges all direction angle values in order to generate a path direction sequence. The template construction submodule extracts equal-length continuous edge point sets from the standard template image based on the calibrated edge region path, calculates the coordinate difference between adjacent point pairs in the point set, and converts each difference into a direction angle based on the point sequence to generate a reference direction sequence. The angle matching submodule calculates the difference between the angle values in the same sequence position of the path direction sequence and the reference direction sequence, judges whether the difference is within the angle tolerance threshold interval, counts all angle pairs that meet the condition, converts the number of angle pairs that meet the condition and the total length of the direction sequence by ratio, and obtains the direction comparison evaluation result.

6. The machine vision-based test paper bag packaging detection system according to claim 5, wherein: The direction angle value adopts the formula: The calculation is made, where θ' i represents the direction angle value, Δx i * represents the lateral coordinate difference value in the i-th set of consecutive edge point pairs, Δy i * represents the longitudinal coordinate difference value in the i-th set of consecutive edge point pairs, represents the average value of the lateral coordinate difference values of all edge point pairs, α is the lateral direction adjustment coefficient, β is the direction denominator stability compensation term, and π represents the constant of the circular ratio.

7. The machine vision-based test paper bag packaging detection system according to claim 1, wherein: The test paper bag seal packaging quality detection result includes test paper bag seal packaging state judgment information, defect labeling area index, and abnormal image recognition label.

8. The machine vision-based test paper bag packaging detection system according to claim 1, wherein: The quality judgment module includes: The closure judgment submodule compares the contour closure degree analysis result with the closure judgment reference value set in the closure standard, records the corresponding image as an abnormal test paper bag packaging image if the closure judgment reference is not met, and records it as an initial qualified sample image if the closure judgment reference is met, binds the record state and the image index, and generates a closure judgment result; The direction tolerance submodule compares the initial qualified sample image in the closure judgment result with the registration tolerance standard according to the direction comparison evaluation result, updates the corresponding image identification state to an abnormal test paper bag packaging image if the ratio value is less than the set reference value, and determines that the packaging is qualified if the ratio value is greater than or equal to the reference value, records the angle deviation segment start and end range according to the position index of the abnormal image in the direction sequence, and obtains the direction error index segment; The defect labeling submodule cross-references the abnormal test paper bag packaging image recorded in the closure judgment result and the direction error index segment according to the corresponding discontinuous area index set and the direction deviation segment position in the image, combines and merges the corresponding area ranges of the two in the image coordinate plane, performs pixel area filling marking on the merged area, and obtains the test paper bag seal packaging quality detection result.

Citation Information

Patent Citations

  • Cigarette packet seal defect detecting system based on image identification technology

    CN103512888A

  • Image cutting method and device, electronic equipment, storage medium and program product

    CN119648720A