Multi-angle complex background non-woven bag opening misalignment detection method and device

CN122820671APending Publication Date: 2026-09-25WEIKU (XIAMEN) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611108954.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-24
Publication Date
2026-09-25

AI Technical Summary

Technical Problem

若中缝两侧的袋口边缘在高度方向上未能对齐,便会产生“错位”(又称错边),错位过大会导致袋口封合不牢、漏装、外观不良等质量问题,因此需要在生产线上对袋口错位量进行在线检测

Benefits of technology

本发明针对无纺布袋口检测环境的复杂背景、多角度、边缘弱的特点,通过投影降维将二维边缘检测降为一维突变点检测,大幅抑制了复杂背景噪声;再利用高斯一阶导数核求取亚像素梯度边缘,配合阈值化与非极大值抑制精确定位边缘点;并通过对单侧检测区二等分求取各侧边缘倾角,自适应地补偿了多角度摆放带来的边缘倾斜;最后通过三角分解将边缘连线投影到基准法线方向求取错位量,消除了角度误差。各步骤环环相扣,使本发明在复杂背景与多角度拍摄条件下仍能高效、准确地检测出无纺布袋口的错位量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122820671A_ABST
    Figure CN122820671A_ABST
Patent Text Reader

Abstract

The application provides a multi-angle complex background non-woven fabric bag opening misalignment detection method and device, the device comprises a preset module, an image acquisition module, a positioning rectangle module, a reference point module, a structure module, a projection dimension reduction module, a calculation module and a judgment module. By determining the positioning rectangle, determining the reference point, setting the rectangular detection area, and dividing it into the left detection region of interest, the middle ignored region and the right detection region of interest along the width direction, the one-dimensional projection vector of the left detection region of interest and the right detection region of interest is respectively calculated, the one-dimensional Gaussian first derivative kernel is constructed, the gradient response curve representing the gray gradient of each row is obtained, and the left and right edge points are positioned. The left edge inclination and the right edge inclination are calculated, and the misalignment amount of the bag opening edges on both sides of the middle seam is obtained. The application can still efficiently and accurately detect the misalignment amount of the non-woven fabric bag opening under the conditions of complex background and multi-angle shooting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial visual inspection technology, and in particular to a method and device for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles. Background Technology

[0002] Non-woven bags are widely used in packaging, medical, and daily chemical industries. During the production of non-woven bags, the bag opening is typically formed by ultrasonically welding or sewing two pieces of non-woven fabric together at the center seam. This center seam is straight and roughly perpendicular to the edge of the bag opening, dividing the edge into left and right sections on either side. If the bag opening edges on both sides of the center seam are not aligned vertically, misalignment (also known as edge misalignment) occurs. Excessive misalignment can lead to quality problems such as insecure bag sealing, missing items, and poor appearance. Therefore, online detection of bag opening misalignment is necessary on the production line.

[0003] However, the detection of misalignment at the opening of non-woven bags presents the following difficulties: First, the background is complex. Non-woven fabric itself has fiber texture, and factors such as wrinkles, uneven lighting, conveyor belts, and surrounding debris generated during production all contribute to strong background interference. Second, the shooting angle is variable. The angle at which the bags are placed on the conveyor belt is not fixed, and the edge of the bag opening is often tilted relative to the image coordinate system, presenting a multi-angle state. Third, the edge contrast of non-woven fabric is low, and the edge signal is weak. If traditional edge detection operators such as Canny and Sobel are used directly, they are easily affected by background noise, leading to false detections and missed detections of edge points. It is difficult to stably and accurately locate the edge of the bag opening, let alone accurately calculate the amount of misalignment.

[0004] Based on this, the present invention provides a method for detecting misalignment of nonwoven bag openings in complex backgrounds from multiple angles, in order to solve the above-mentioned problems. Summary of the Invention

[0005] The technical problem to be solved by the present invention is to provide a method and device for detecting misalignment of nonwoven bag openings under complex backgrounds from multiple angles, which can efficiently and accurately detect the amount of misalignment of nonwoven bag openings under complex backgrounds and multi-angle shooting conditions.

[0006] In a first aspect, the present invention provides a method for detecting misalignment of the opening of a nonwoven bag against a complex background from multiple angles, comprising the following steps: Step S1: Preset a fixed rectangle, acquire an image of the non-woven bag opening, and determine whether the fixed rectangle deviates from the center seam. When the fixed rectangle does not deviate from the center seam, it is used as the positioning rectangle. When the fixed rectangle deviates from the center seam, the coarse outline of the center seam is obtained by using an image segmentation model or grayscale threshold segmentation. The circumscribed rectangle of the coarse outline of the center seam is used to obtain the positioning rectangle. The part of the positioning rectangle near the bag opening with a height of height is named the end strip. The height value ranges from 100 to 200 pixels. The center of the end strip is named the reference point. Step S2: Construct a rectangular detection region with the reference point as the center point of the upper edge of the rectangular detection region. Divide the rectangular detection region into a left detection region of interest, a middle ignored region, and a right detection region of interest along the width direction. The left and right detection regions of interest are the same size. Divide the left and right detection regions of interest into an inner half and an outer half along the width direction, respectively. Step S3: Project the left and right regions of interest along the horizontal direction of the nonwoven bag opening image to reduce their dimensions, and calculate the gray value of each row of pixels in the left and right regions of interest to obtain a one-dimensional projection vector distributed along the vertical direction of the image. Step S4: Construct a one-dimensional Gaussian first derivative kernel, perform convolution filtering on the one-dimensional projection vector, and obtain the gradient response curve characterizing the gray-level gradient of each row. Step S5: Threshold the gradient response curve and suppress non-maximum values ​​to locate the left and right edge points; Step S6: Interpolate the pixel row numbers of the left and right edge points on the rectangular detection area to construct the left and right edge lines. Calculate the left edge tilt angle, the right edge tilt angle, and the mean of the left and right edge tilt angles based on the difference in pixel row numbers between the edge points of the left and right detection areas of interest and the outer half of the detection area. Step S7: Using the average of the left and right edge inclination angles as the reference angle, calculate the misalignment of the bag opening edges on both sides of the center seam based on the normal projection of the line connecting the left and right edge points relative to the reference angle.

[0007] Furthermore, the projection dimensionality reduction calculation formula in step S3 is as follows: ; Where I(i,j) is the grayscale value of the pixel in the i-th row and j-th column of the region of interest, W is the width of the region of interest on one side, and P(i) is the projection value of the pixel in the i-th row.

[0008] Furthermore, the formula for calculating the one-dimensional Gaussian first derivative kernel in step S4 is as follows: ; Where r is the kernel radius; σ is the standard deviation and σ = r / 4; x is the kernel coordinate; The formula for calculating the gradient response curve is: ; Where k is the kernel offset; i is the pixel row; P is the one-dimensional projection vector obtained in step S3; and E(i) is the gradient response value of the i-th row.

[0009] Further, step S5 specifically involves: setting the threshold as thr, and locating edge points in two ways according to the polarity parameter mode: When mode is 1, locate the positive edge from dark to light, that is, the local maximum point that satisfies E(i)>thr and E(i)≥E(i−1) and E(i)≥E(i+1); When mode is 2, the negative edge from bright to dark is located, that is, the local minimum point that satisfies E(i)<−thr and E(i)≤E(i−1) and E(i)≤E(i+1); Non-maximum suppression is applied to the obtained edge points: when the row number spacing between two adjacent edge points is less than 0.5×nms_size, only the one with the larger absolute value of the gradient response is retained; finally, according to the direction parameter, the uppermost or lowermost edge point in the edge point sequence is taken as the edge point of the region of interest.

[0010] Further, in step S6, linear interpolation is first performed on the corresponding sides of the left and right detection rectangles using the row numbers of the left and right edge points to obtain the endpoints of the left and right edge lines. The interpolation calculation formula is: ; Where P L0 ~P L3 P R0 ~P R3 These are the four corner points of the left and right detection rectangles, respectively; left_val and right_val are the row numbers of the left and right edge points, respectively; E L1 E L2 E represents the two endpoints of the constructed left edge line. R1 E R2 These are the two endpoints of the constructed right edge line; height is the height of the rectangular detection area. Then, using the difference in row numbers between the edge points of the left and outer halves of the region of interest and the right and outer halves of the region of interest, the left edge inclination angle (angle_left) and the right edge inclination angle (angle_right) are calculated respectively. The calculation formula is as follows: ; Where left_val_1 and left_val_2 are the row numbers of the edge points in the left half and outer half of the region of interest, respectively; right_val_1 and right_val_2 are the row numbers of the edge points in the right half and outer half of the region of interest, respectively; and width is the width of the left or right region of interest.

[0011] Furthermore, the formula for calculating the misalignment in step S7 is as follows: ; Where left_pt and right_pt are the left and right edge points respectively; their coordinates are (width / 2, left_val) and (loc_width−width / 2, right_val) respectively; loc_width is the total width of the rectangular detection area; L is the length of the line connecting the left and right edge points; angle_point is the angle of inclination of the line connecting them; and angle_diff is the average angle of inclination of the left and right edges, i.e., the reference angle. ; Angle; angle_diff is the average of the left edge tilt angle_left and the right edge tilt angle_right; that is, the misalignment is the projection length of the line connecting the left and right edges in the direction of the reference angle normal.

[0012] Furthermore, it also includes anomaly detection: when the left or right detection region of interest fails to locate an edge point, it is judged as a detection failure; when the absolute value of the difference between the left edge tilt angle and the right edge tilt angle is greater than the angle threshold, it is judged as a misalignment anomaly.

[0013] Furthermore, in step S5, the threshold thr, polarity parameter mode, and direction parameter direction are all given in the form of parameter groups. Each parameter group contains two values ​​corresponding to the left and right detection regions of interest, respectively. When locating the left edge point, the left value (thresh_l, mode_l, direction_l) is used, and when locating the right edge point, the right value (thresh_r, mode_r, direction_r) is used. When only one value is given for a parameter group, it is shared when locating the left and right edge points. Thus, for left and right edge points with inconsistent brightness contrast, edge polarity, or detection direction on both sides of the midline, independent detection parameters are used to locate the edge points.

[0014] Furthermore, step S2 also includes: finding the intersection of the detection area and the boundary of the non-woven bag opening image; if the area of ​​the obtained area is zero, it is determined that the parameter setting is incorrect and the process returns to step S1; if the area of ​​the obtained area is not zero, step S3 is executed.

[0015] Secondly, the present invention provides a non-woven bag opening misalignment detection device with a complex background from multiple angles, including an image acquisition module, a positioning rectangle module, a reference point module, a construction module, a projection dimension reduction module, a calculation module, and a judgment module. The image acquisition module is used to acquire images of the opening of the non-woven bag; The positioning rectangle module is used to obtain the coarse outline of the middle seam by using an image segmentation model or grayscale threshold segmentation, and to obtain the positioning rectangle by calculating the bounding rectangle of the coarse outline of the middle seam. The reference point module is used to name the part of the positioning rectangle near the bag opening with a height of height as the end strip, where the height value ranges from 100 to 200 pixels, and to name the center of the end strip as the reference point. The construction module is responsible for constructing a rectangular detection region with the reference point as the center point of the upper edge of the rectangular detection region. The rectangular detection region is divided into a left detection region of interest, a middle ignored region, and a right detection region of interest along the width direction. The left and right detection regions of interest are the same size. The left and right detection regions of interest are divided into an inner half and an outer half along the width direction, respectively. The projection dimension reduction module is used to perform projection dimension reduction on the left and right regions of interest along the horizontal direction of the non-woven bag opening image, and to calculate the gray value of each row of pixels in the left and right regions of interest to obtain a one-dimensional projection vector distributed along the vertical direction of the image. The calculation module is responsible for constructing a one-dimensional Gaussian first-order derivative kernel, performing convolution filtering on the one-dimensional projection vector to obtain gradient response curves representing the gray-level gradients of each row, thresholding and non-maximum suppression on the gradient response curves, locating the left and right edge points, interpolating the pixel row numbers of the left and right edge points on the rectangular detection area to construct the left and right edge lines, and calculating the left and right edge tilt angles and the mean of the left and right edge tilt angles based on the difference in pixel row numbers of the edge points in the left and right detection areas of interest and the outer half of the detection area. The mean of the left and right edge tilt angles is used as the reference angle, and the misalignment of the bag opening edges on both sides of the center seam is calculated based on the normal projection of the line connecting the left and right edge points relative to the reference angle. The determination module is responsible for detecting whether the left or right detection region of interest has been located at the edge point. When determining whether the absolute value of the difference between the left edge inclination angle and the right edge inclination angle is greater than the angle threshold, the detection area is intersected with the boundary of the non-woven bag opening image, and it is determined whether the parameter setting is incorrect.

[0016] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages: This invention addresses the challenges of complex backgrounds, multiple angles, and weak edges in non-woven bag opening detection environments. It reduces two-dimensional edge detection to one-dimensional abrupt change point detection through projection dimensionality reduction, significantly suppressing background noise. Sub-pixel gradient edges are then calculated using a Gaussian first-order derivative kernel, combined with thresholding and non-maximum suppression for precise edge point localization. Furthermore, the edge tilt angles on each side of the detection area are adaptively compensated for edge tilt caused by multi-angle placement by bisecting the detection area. Finally, triangulation projects the edge lines onto the reference normal direction to calculate the misalignment, eliminating angular errors. These interconnected steps enable the invention to efficiently and accurately detect the misalignment of non-woven bag openings even under complex backgrounds and multi-angle shooting conditions.

[0017] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description

[0018] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0019] Figure 1 This is a flowchart of a method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles, as disclosed in an embodiment of the present invention. Figure 2 This is a schematic diagram showing the overall detection area and the left and right detection regions of interest for a multi-angle complex background nonwoven bag opening misalignment detection method disclosed in an embodiment of the present invention; Figure 3 The one-dimensional projection curve obtained after dimension reduction by region of interest projection in a multi-angle complex background nonwoven bag opening misalignment detection method disclosed in the embodiments of the present invention is a method.

[0020] Figure 4 The gradient response curve and threshold line are obtained by filtering the projection curve of a nonwoven bag opening misalignment detection method with a complex background from multiple angles, as disclosed in the embodiments of the present invention, after applying Gaussian first derivative kernel filtering.

[0021] Figure 5 This is a schematic diagram of the left and right edge point positioning and left and right edge line construction of a multi-angle complex background nonwoven bag opening misalignment detection method disclosed in an embodiment of the present invention.

[0022] Figure 6 This is a geometrical diagram illustrating the triangular decomposition of the misalignment amount in a multi-angle complex background nonwoven bag opening misalignment detection method disclosed in an embodiment of the present invention.

[0023] The attached diagram lists the components represented by each number as follows: 1-Center seam, 2-Positioning rectangle, 3-End strip, 4-Reference point, 5-Left detection outer half of the region of interest, 6-Left detection inner half of the region of interest, 7-Center ignored area, 8-Right detection inner half of the region of interest, 9-Right detection outer half of the region of interest, 10-Left edge of the bag opening, 11-Right edge of the bag opening. Detailed Implementation

[0024] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0025] This invention provides a method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles. Its working principle involves suppressing background noise through projection dimensionality reduction; then, calculating the sub-pixel gradient using a Gaussian first derivative kernel; further, accurately locating edge points through edge detection, thresholding, and non-maximum suppression; adaptively estimating the edge tilt angle through unilateral bisection; and finally, calculating the vertical misalignment amount through triangulation. This invention enables efficient and accurate detection of misalignment of nonwoven bag openings even under complex backgrounds and multi-angle shooting conditions. The invention will be further described in detail below with reference to embodiments and specific implementation methods. Example 1

[0026] like Figures 1 to 6 As shown, this invention provides a method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles, comprising the following steps: Step S1: Preset a fixed rectangle, acquire an image of the non-woven bag opening, and determine whether the fixed rectangle deviates from the center seam. When the fixed rectangle does not deviate from the center seam, it is used as the positioning rectangle. When the fixed rectangle deviates from the center seam, the coarse outline of the center seam is obtained by using an image segmentation model or grayscale threshold segmentation. The circumscribed rectangle of the coarse outline of the center seam is used to obtain the positioning rectangle. The part of the positioning rectangle near the bag opening with a height of height is named the end strip. The height value ranges from 100 to 200 pixels. The center of the end strip is named the reference point. Step S2: Construct a rectangular detection region with the reference point as the center point of the upper edge of the rectangular detection region. Divide the rectangular detection region into a left detection region of interest, a middle ignored region, and a right detection region of interest along the width direction. The left and right detection regions of interest are the same size. Divide the left and right detection regions of interest into an inner half and an outer half along the width direction, respectively. Step S3: Project the left and right regions of interest along the horizontal direction of the nonwoven bag opening image to reduce their dimensions, and calculate the gray value of each row of pixels in the left and right regions of interest to obtain a one-dimensional projection vector distributed along the vertical direction of the image. Step S4: Construct a one-dimensional Gaussian first derivative kernel, perform convolution filtering on the one-dimensional projection vector, and obtain the gradient response curve characterizing the gray-level gradient of each row. Step S5: Threshold the gradient response curve and suppress non-maximum values ​​to locate the left and right edge points; Step S6: Interpolate the pixel row numbers of the left and right edge points on the rectangular detection area to construct the left and right edge lines. Calculate the left edge tilt angle, the right edge tilt angle, and the mean of the left and right edge tilt angles based on the difference in pixel row numbers between the edge points of the left and right detection areas of interest and the outer half of the detection area. Step S7: Using the average of the left and right edge inclination angles as the reference angle, calculate the misalignment of the bag opening edges on both sides of the center seam based on the normal projection of the line connecting the left and right edge points relative to the reference angle.

[0027] First, an image of the center seam of the non-woven fabric bag opening is acquired to obtain a positioning rectangle. The center seam is the welded seam of the two pieces of non-woven fabric at the bag opening, forming a straight line and extending approximately perpendicular to the edge of the bag opening. Since the position of the inspection machine is fixed and the incoming material is stable, the positioning rectangle can be directly preset as a fixed rectangle without the need for frame-by-frame contour segmentation and minimum bounding rectangle fitting. The center of the end strip is used as a reference point. A rectangular inspection area is constructed with this reference point as the center of the upper edge of the rectangular inspection area. The rectangular inspection area is divided into a left inspection region of interest, a middle ignored region, and a right inspection region of interest along the width direction. The left and right inspection regions of interest are the same size. Then, the left and right inspection regions of interest are each divided into an inner half and an outer half along the width direction, respectively. For each inspection region of interest... The image is projected horizontally to reduce dimensionality, and the grayscale values ​​of each row are averaged and compressed into a one-dimensional projection vector distributed vertically to suppress interference from complex backgrounds such as non-woven fabric textures, wrinkles, uneven lighting, and conveyor belt debris. Then, the projection vector is convolved with a one-dimensional Gaussian first derivative kernel to obtain the grayscale gradient response curve. Sub-pixel edge points are located by thresholding and non-maximum suppression, and the left and right edges can use independent threshold, polarity, and direction parameters to adapt to the differences in brightness and polarity on both sides of the seam. The tilt angle of each side edge is calculated by the difference between the edge points in the left and right detection regions of interest and the outer half region, thus adapting to the situation where the bags are placed at multiple angles on the conveyor belt. Finally, the misalignment of the bag opening edges on both sides of the seam is calculated based on the normal projection of the line connecting the left and right edges relative to the reference angle.

[0028] Since the detection device of the present invention has a fixed position and the incoming material and shooting field of view are stable, the position of the slit in the acquired image remains basically unchanged. Therefore, in this embodiment, a fixed rectangle is directly preset as the positioning rectangle ctr_rect (when the fixed rectangle deviates from the slit, the rough outline of the slit can also be obtained by image segmentation model or grayscale threshold segmentation, and then the bounding rectangle is obtained to obtain the positioning rectangle). This eliminates the need for frame-by-frame deep learning contour segmentation and minimum bounding rectangle fitting, thereby improving positioning efficiency and stability.

[0029] The x-coordinate of the reference point is equal to the sum of the x-coordinate of the upper left corner of the positioning rectangle and half of its width, and the y-coordinate is equal to the sum of the y-coordinate of the upper left corner of the positioning rectangle and its height, minus half of the height of the detection area.

[0030] Taking the top left corner of the image as the origin of the coordinate system, the formula for calculating the coordinates of the reference point can be derived as follows: loc_center.x = ctr_rect.x + ctr_rect.width / 2; loc_center.y = ctr_rect.y + ctr_rect.height - height / 2; Where ctr_rect.x and ctr_rect.y are the x and y coordinates of the top left corner of the positioning rectangle; ctr_rect.width is the width of the positioning rectangle; ctr_rect.height is the height of the positioning rectangle; height is the height of the detection area; and loc center is the coordinate of the reference point to be obtained.

[0031] The height value follows the principle of "as small as possible while reliably covering edge fluctuations." If it is too large, the search will be slow and easily affected by non-woven fabric textures and wrinkles; if it is too small, the edge of the bag opening may fall outside the detection area when the bag shakes slightly up and down or tilts. Therefore, the lower bound should ensure that height ≥ the sum of the maximum edge shaking amount and the tilt height difference plus the detection margin, while the upper bound is limited by speed and anti-interference.

[0032] In this embodiment, the width of the middle ignored region is on the order of 100 pixels, the width of the left and right detected regions of interest is on the order of 300 pixels, and the height of the rectangular detection region and the end strip is on the order of 200 pixels.

[0033] Preferably, the projection dimensionality reduction calculation formula in step S3 is: ; Where I(i,j) is the grayscale value of the pixel in the i-th row and j-th column of the region of interest; W is the width of the region of interest on one side; and P(i) is the projection value of the pixel in the i-th row.

[0034] Since the edge of the nonwoven bag opening is approximately a straight line in the horizontal direction, taking the average grayscale value for each row can effectively suppress random noise introduced by complex backgrounds such as nonwoven fabric texture, wrinkles, uneven lighting, and conveyor belt debris while preserving edge transition information. This reduces the two-dimensional edge detection problem to a one-dimensional abrupt change point detection problem. It should be noted that the projection direction in this step is fixed to the horizontal direction of the image, compressing the two-dimensional region of interest into a one-dimensional projection vector distributed along the vertical direction of the image. Subsequently, the gradient is calculated in the vertical direction and the edge points are located (i.e., the edge points are represented by row numbers). This projection direction does not depend on the actual tilt angle of the bag opening edge. The tilt angle of the bag opening edge is adaptively calculated in subsequent step S6 from the difference in row numbers of the edge points in the inner and outer halves of each side, rather than being pre-assumed in this step.

[0035] Preferably, the formula for calculating the one-dimensional Gaussian first derivative kernel in step S4 is: ; Where r is the kernel radius; σ is the standard deviation and σ = r / 4; x is the kernel coordinate; The formula for calculating the gradient response curve is: ; Where k is the kernel offset; i is the pixel row; P is the one-dimensional projection vector obtained in step S3; and E(i) is the gradient response value of the i-th row. The positive peak of E(i) corresponds to the edge from dark to light, and the negative peak corresponds to the edge from light to dark.

[0036] Preferably, step S5 specifically involves: setting the threshold as thr, and locating edge points in two ways according to the polarity parameter mode: When mode is 1, locate the positive edge from dark to light, that is, the local maximum point that satisfies E(i)>thr and E(i)≥E(i−1) and E(i)≥E(i+1); When mode is 2, the negative edge from bright to dark is located, that is, the local minimum point that satisfies E(i)<−thr and E(i)≤E(i−1) and E(i)≤E(i+1); Non-maximum suppression is applied to the obtained edge points: when the row number spacing between two adjacent edge points is less than 0.5×nms_size, only the one with the larger absolute value of the gradient response is retained; finally, according to the direction parameter, the uppermost or lowermost edge point in the edge point sequence is taken as the edge point of the region of interest.

[0037] To address the varying contrast and edge polarity on both sides of the center seam due to differences in background, lighting, or material, independent threshold, polarity, and direction parameters can be applied to the left and right edges respectively, thereby further improving the robustness and adaptability of edge positioning under complex backgrounds and multi-angle conditions.

[0038] Preferably, in step S6, linear interpolation is first performed on the corresponding sides of the left and right detection rectangles using the row numbers of the left and right edge points to obtain the endpoints of the left and right edge lines. The interpolation calculation formula is as follows: ; Where P L0 ~P L3 P R0 ~P R3 These are the four corner points of the left and right detection rectangles, respectively; left_val and right_val are the row numbers of the left and right edge points, respectively; E L1 E L2 E represents the two endpoints of the constructed left edge line. R1 E R2 These are the two endpoints of the constructed right edge line; height is the height of the rectangular detection area. Then, using the difference in row numbers between the edge points of the left and outer halves of the region of interest and the right and outer halves of the region of interest, the left edge inclination angle (angle_left) and the right edge inclination angle (angle_right) are calculated respectively. The calculation formula is as follows: ; Where left_val_1 and left_val_2 are the row numbers of the edge points in the left half and outer half of the region of interest, respectively; right_val_1 and right_val_2 are the row numbers of the edge points in the right half and outer half of the region of interest, respectively; and width is the width of the left or right region of interest.

[0039] By dividing the single-sided detection area into two equal parts and calculating the row number of the edge points respectively, the tilt angle of each edge can be estimated without relying on external posture information, thus adapting to the situation where bags are placed at multiple angles on the conveyor belt.

[0040] Preferably, the formula for calculating the misalignment in step S7 is: ; Where left_pt and right_pt are the left and right edge points respectively; their coordinates are (width / 2, left_val) and (loc_width−width / 2, right_val) respectively; loc_width is the total width of the rectangular detection area; L is the length of the line connecting the left and right edge points; angle_point is the angle of inclination of the line connecting them; and angle_diff is the average angle of inclination of the left and right edges, i.e., the reference angle. ; Where L is the length of the line connecting the left and right edge points; angle_point is the angle of inclination of the line connecting the left and right edge points; angle_diff is the average of the left edge angle_left and the right edge angle_right; that is, the misalignment is the projection length of the line connecting the left and right edges in the direction of the reference angle normal.

[0041] Because the line connecting the left and right edge points has an angle relative to the reference direction of the bag opening when shooting from multiple angles, directly using the difference in row number as the misalignment amount will introduce angular error. Therefore, this invention projects the length of the line connecting to the normal direction of the reference angle, and the resulting projected length is the true vertical misalignment amount, which can effectively eliminate the measurement deviation caused by multiple angles.

[0042] Ideally, it also includes anomaly detection: if the edge point is not located in the left or right detection region of interest, it is judged as a detection failure; if the absolute value of the difference between the left edge tilt angle and the right edge tilt angle is greater than the angle threshold, it is judged as a misalignment anomaly.

[0043] Preferably, in step S5, the threshold thr, polarity parameter mode, and direction parameter direction are all given in the form of parameter groups. Each parameter group contains two values ​​corresponding to the left and right detection regions of interest, respectively. When locating the left edge point, the left value (thresh_l, mode_l, direction_l) is used, and when locating the right edge point, the right value (thresh_r, mode_r, direction_r) is used. When only one value is given for a parameter group, it is shared when locating the left and right edge points. Thus, for left and right edge points with inconsistent brightness contrast, edge polarity, or detection direction on both sides of the midline, independent detection parameters are used to locate the edge points.

[0044] Preferably, step S2 further includes: finding the intersection of the detection area and the boundary of the nonwoven bag opening image; if the area of ​​the obtained area is zero, it is determined that the parameter setting is incorrect and the process returns to step S1; if the area of ​​the obtained area is not zero, step S3 is executed.

[0045] Based on the same inventive concept, this application also provides an apparatus corresponding to the method in Embodiment 1, as detailed in Embodiment 2. Example 2

[0046] This embodiment provides a multi-angle complex background non-woven bag opening misalignment detection device, including an image acquisition module, a positioning rectangle module, a reference point module, a construction module, a projection dimension reduction module, a calculation module, and a judgment module; The image acquisition module is used to acquire images of the opening of the non-woven bag; The positioning rectangle module is used to obtain the coarse outline of the middle seam by using an image segmentation model or grayscale threshold segmentation, and to obtain the positioning rectangle by calculating the bounding rectangle of the coarse outline of the middle seam. The reference point module is used to name the part of the positioning rectangle near the bag opening with a height of height as the end strip, where the height value ranges from 100 to 200 pixels, and to name the center of the end strip as the reference point. The construction module is responsible for constructing a rectangular detection region with the reference point as the center point of the upper edge of the rectangular detection region. The rectangular detection region is divided into a left detection region of interest, a middle ignored region, and a right detection region of interest along the width direction. The left and right detection regions of interest are the same size. The left and right detection regions of interest are divided into an inner half and an outer half along the width direction, respectively. The projection dimension reduction module is used to perform projection dimension reduction on the left and right regions of interest along the horizontal direction of the non-woven bag opening image, and to calculate the gray value of each row of pixels in the left and right regions of interest to obtain a one-dimensional projection vector distributed along the vertical direction of the image. The calculation module is responsible for constructing a one-dimensional Gaussian first-order derivative kernel, performing convolution filtering on the one-dimensional projection vector to obtain gradient response curves representing the gray-level gradients of each row, thresholding and non-maximum suppression on the gradient response curves, locating the left and right edge points, interpolating the pixel row numbers of the left and right edge points on the rectangular detection area to construct the left and right edge lines, and calculating the left and right edge tilt angles and the mean of the left and right edge tilt angles based on the difference in pixel row numbers of the edge points in the left and right detection areas of interest and the outer half of the detection area. The mean of the left and right edge tilt angles is used as the reference angle, and the misalignment of the bag opening edges on both sides of the center seam is calculated based on the normal projection of the line connecting the left and right edge points relative to the reference angle. The determination module is responsible for detecting whether the left or right detection region of interest has been located at the edge point. When determining whether the absolute value of the difference between the left edge inclination angle and the right edge inclination angle is greater than the angle threshold, the detection area is intersected with the boundary of the non-woven bag opening image, and it is determined whether the parameter setting is incorrect.

[0047] Since the apparatus described in Embodiment 2 of the present invention is an apparatus used to implement the method of Embodiment 1 of the present invention, those skilled in the art can understand the specific structure and variations of the apparatus based on the method described in Embodiment 1 of the present invention, and therefore will not be described again here. All apparatuses used in the method of Embodiment 1 of the present invention fall within the scope of protection of the present invention.

[0048] In summary, the advantages of this invention are as follows: Addressing the complex background, multi-angle, and weak edge characteristics of non-woven bag opening detection environments, this invention reduces two-dimensional edge detection to one-dimensional abrupt change point detection through projection dimensionality reduction, significantly suppressing background noise. Furthermore, it utilizes a Gaussian first-order derivative kernel to calculate sub-pixel gradient edges, combined with thresholding and non-maximum suppression to accurately locate edge points. By bisecting the single-sided detection area to calculate the edge tilt angles on each side, it adaptively compensates for edge tilt caused by multi-angle placement. Finally, it uses triangulation to project the edge connection lines onto the reference normal direction to calculate the misalignment, eliminating angular errors. Each step is interconnected, enabling this invention to efficiently and accurately detect the misalignment of non-woven bag openings even under complex backgrounds and multi-angle shooting conditions.

[0049] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles, characterized in that, Includes the following steps: Step S1: Preset a fixed rectangle, acquire an image of the non-woven bag opening, and determine whether the fixed rectangle deviates from the center seam. When the fixed rectangle does not deviate from the center seam, it is used as the positioning rectangle. When the fixed rectangle deviates from the center seam, the coarse outline of the center seam is obtained by using an image segmentation model or grayscale threshold segmentation. The circumscribed rectangle of the coarse outline of the center seam is used to obtain the positioning rectangle. The part of the positioning rectangle near the bag opening with a height of height is named the end strip. The height value ranges from 100 to 200 pixels. The center of the end strip is named the reference point. Step S2: Construct a rectangular detection region with the reference point as the center point of the upper edge of the rectangular detection region. Divide the rectangular detection region into a left detection region of interest, a middle ignored region, and a right detection region of interest along the width direction. The left and right detection regions of interest are the same size. Divide the left and right detection regions of interest into an inner half and an outer half along the width direction, respectively. Step S3: Project the left and right regions of interest along the horizontal direction of the nonwoven bag opening image to reduce their dimensions, and calculate the gray value of each row of pixels in the left and right regions of interest to obtain a one-dimensional projection vector distributed along the vertical direction of the image. Step S4: Construct a one-dimensional Gaussian first derivative kernel, perform convolution filtering on the one-dimensional projection vector, and obtain the gradient response curve characterizing the gray-level gradient of each row. Step S5: Threshold the gradient response curve and suppress non-maximum values ​​to locate the left and right edge points; Step S6: Interpolate the pixel row numbers of the left and right edge points on the rectangular detection area to construct the left and right edge lines. Calculate the left edge tilt angle, the right edge tilt angle, and the mean of the left and right edge tilt angles based on the difference in pixel row numbers between the edge points of the left and right detection areas of interest and the outer half of the detection area. Step S7: Using the average of the left and right edge inclination angles as the reference angle, calculate the misalignment of the bag opening edges on both sides of the center seam based on the normal projection of the line connecting the left and right edge points relative to the reference angle.

2. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: The projection dimensionality reduction calculation formula in step S3 is as follows: ; Where I(i,j) is the grayscale value of the pixel in the i-th row and j-th column of the region of interest; W is the width of the region of interest on one side; and P(i) is the projection value of the pixel in the i-th row.

3. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: The formula for calculating the one-dimensional Gaussian first derivative kernel in step S4 is as follows: ; Where r is the kernel radius; σ is the standard deviation and σ = r / 4; x is the kernel coordinate; The formula for calculating the gradient response curve is: ; Where k is the kernel offset; i is the pixel row; P is the one-dimensional projection vector obtained in step S3; and E(i) is the gradient response value of the i-th row.

4. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: Step S5 specifically involves: setting the threshold as thr, and locating edge points in two ways according to the polarity parameter mode: When mode is 1, locate the positive edge from dark to light, that is, the local maximum point that satisfies E(i)>thr and E(i)≥E(i−1) and E(i)≥E(i+1); When mode is 2, the negative edge from bright to dark is located, that is, the local minimum point that satisfies E(i)<−thr and E(i)≤E(i−1) and E(i)≤E(i+1); Non-maximum suppression is applied to the obtained edge points: when the row number spacing between two adjacent edge points is less than 0.5×nms_size, only the one with the larger absolute value of the gradient response is retained; finally, according to the direction parameter, the uppermost or lowermost edge point in the edge point sequence is taken as the edge point of the region of interest.

5. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: In step S6, linear interpolation is first performed on the corresponding sides of the left and right detection rectangles using the row numbers of the left and right edge points to obtain the endpoints of the left and right edge lines. The interpolation calculation formula is as follows: ; Where P L0 ~P L3 P R0 ~P R3 These are the four corner points of the left and right detection rectangles, respectively; left_val and right_val are the row numbers of the left and right edge points, respectively; E L1 E L2 E represents the two endpoints of the constructed left edge line. R1 E R2 These are the two endpoints of the constructed right edge line; height is the height of the rectangular detection area. Then, using the difference in row numbers between the edge points of the left and outer halves of the region of interest and the right and outer halves of the region of interest, the left edge inclination angle (angle_left) and the right edge inclination angle (angle_right) are calculated respectively. The calculation formula is as follows: ; Where left_val_1 and left_val_2 are the row numbers of the edge points in the left half and outer half of the region of interest, respectively; right_val_1 and right_val_2 are the row numbers of the edge points in the right half and outer half of the region of interest, respectively; and width is the width of the left or right region of interest.

6. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: The formula for calculating the misalignment in step S7 is as follows: ; Where left_pt and right_pt are the left and right edge points respectively; their coordinates are (width / 2, left_val) and (loc_width−width / 2, right_val) respectively; loc_width is the total width of the rectangular detection area; L is the length of the line connecting the left and right edge points; angle_point is the angle of inclination of the line connecting them; and angle_diff is the average angle of inclination of the left and right edges, i.e., the reference angle. ; Where L is the length of the line connecting the left and right edge points; angle_point is the angle of inclination of the line connecting the left and right edge points; angle_diff is the average of the left edge angle_left and the right edge angle_right; that is, the misalignment is the projection length of the line connecting the left and right edges in the direction of the reference angle normal.

7. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: It also includes anomaly detection: if the edge point is not located in the left or right detection region of interest, it is judged as a detection failure; if the absolute value of the difference between the left edge tilt angle and the right edge tilt angle is greater than the angle threshold, it is judged as a misalignment anomaly.

8. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: In step S5, the threshold thr, polarity parameter mode, and direction parameter direction are all given in the form of parameter groups. Each parameter group contains two values ​​corresponding to the left and right detection regions of interest, respectively. When locating the left edge point, the left value (thresh_l, mode_l, direction_l) is used, and when locating the right edge point, the right value (thresh_r, mode_r, direction_r) is used. When a parameter group is given only one value, it is shared when locating the left and right edge points. Thus, for left and right edge points with inconsistent brightness contrast, edge polarity, or detection direction on both sides of the midline, independent detection parameters are used to locate the edge points.

9. The method for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles according to claim 1, characterized in that: Step S2 further includes: finding the intersection of the detection area and the boundary of the non-woven bag opening image; if the area of ​​the obtained area is zero, it is determined that the parameter setting is incorrect and the process returns to step S1; if the area of ​​the obtained area is not zero, step S3 is executed.

10. A device for detecting misalignment of nonwoven bag openings against complex backgrounds from multiple angles, characterized in that: It includes a preset module, an image acquisition module, a positioning rectangle module, a reference point module, a construction module, a projection dimensionality reduction module, a calculation module, and a judgment module; The preset module is responsible for presetting a fixed rectangle; The image acquisition module is used to acquire images of the opening of the non-woven bag; The positioning rectangle module is used to determine the positioning rectangle. When the fixed rectangle does not deviate from the center slit, the fixed rectangle is used as the positioning rectangle. When the fixed rectangle deviates from the center slit, the center slit coarse outline is obtained by segmenting the fixed rectangle using an image segmentation model or grayscale thresholding. The positioning rectangle is obtained by finding the circumscribed rectangle of the center slit coarse outline. The reference point module is used to name the part of the positioning rectangle near the bag opening with a height of height as the end strip, where the height value ranges from 100 to 200 pixels, and to name the center of the end strip as the reference point. The construction module is responsible for constructing a rectangular detection region with the reference point as the center point of the upper edge of the rectangular detection region. The rectangular detection region is divided into a left detection region of interest, a middle ignored region, and a right detection region of interest along the width direction. The left and right detection regions of interest are the same size. The left and right detection regions of interest are divided into an inner half and an outer half along the width direction, respectively. The projection dimension reduction module is used to perform projection dimension reduction on the left and right regions of interest along the horizontal direction of the non-woven bag opening image, and to calculate the gray value of each row of pixels in the left and right regions of interest to obtain a one-dimensional projection vector distributed along the vertical direction of the image. The calculation module is responsible for constructing a one-dimensional Gaussian first-order derivative kernel, performing convolution filtering on the one-dimensional projection vector to obtain gradient response curves representing the gray-level gradients of each row, thresholding and non-maximum suppression on the gradient response curves, locating the left and right edge points, interpolating the pixel row numbers of the left and right edge points on the rectangular detection area to construct the left and right edge lines, and calculating the left and right edge tilt angles and the mean of the left and right edge tilt angles based on the difference in pixel row numbers of the edge points in the left and right detection areas of interest and the outer half of the detection area. The mean of the left and right edge tilt angles is used as the reference angle, and the misalignment of the bag opening edges on both sides of the center seam is calculated based on the normal projection of the line connecting the left and right edge points relative to the reference angle. The determination module is responsible for determining whether the fixed rectangle deviates from the center seam, whether the left or right detection region of interest is located at the edge point, and whether the absolute value of the difference between the left and right edge inclination angles is greater than the angle threshold. If so, the detection area is intersected with the boundary of the non-woven bag opening image, and it is determined whether the parameter settings are incorrect.