A visual positioning method and system for cardboard box palletizing

By calculating the gradient angle histogram and entropy value of the carton image, candidate windows are identified. Clustering is performed using the corner existence index and the harmonic mean of the eigenvalues ​​of the structure tensor matrix. Combined with the NCC algorithm, the problem of low positioning efficiency of template matching algorithm in carton palletizing is solved, realizing real-time positioning for high-speed and continuous operation and improving palletizing efficiency.

CN121661594BActive Publication Date: 2026-06-30GUANGZHOU LIANWANG PAPER

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU LIANWANG PAPER
Filing Date
2025-12-12
Publication Date
2026-06-30

Smart Images

  • Figure CN121661594B_ABST
    Figure CN121661594B_ABST
Patent Text Reader

Abstract

This application relates to the field of visual positioning technology, and in particular to a visual positioning method and system for cardboard box palletizing. The method includes: uniformly dividing a cardboard box image into multiple windows; calculating the entropy value of the angle histogram within each window; selecting windows with entropy values ​​less than a first threshold as candidate windows; calculating a corner presence index for the angle histogram of the candidate windows; selecting candidate windows with corner presence indices greater than a second threshold as corner windows; for any pixel within a corner window, constructing a structure tensor matrix around the pixel as a sub-window and calculating the harmonic mean of multiple eigenvalues; clustering the harmonic means of all pixels within each corner window to obtain multiple clusters; and executing different cardboard box positioning strategies based on different clusters. The technical solution of this application can improve the efficiency of cardboard box positioning during the cardboard box palletizing process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of visual positioning technology. More specifically, this application relates to a visual positioning method and system for cardboard box palletizing. Background Technology

[0002] Carton palletizing refers to the process of automatically, neatly, and tightly stacking cartons onto pallets according to a predetermined arrangement and number of layers. It is an indispensable key link in modern production and warehousing logistics, widely used in industries such as food and beverage, electronics, and pharmaceuticals. Its purpose is to improve the automation level of production lines, reduce labor costs, and ensure the stability and safety of goods stacking, thus facilitating subsequent warehousing and transportation. During automated palletizing, in order for robots to accurately grasp and place cartons, it is necessary to obtain precise position and orientation information of the cartons in real time. Therefore, visual positioning for carton palletizing—that is, using machine vision technology to automatically identify cartons on the conveyor belt and determine their coordinates—is a prerequisite for achieving automated and intelligent palletizing.

[0003] In existing visual positioning technologies, template matching based on normalized cross-correlation (NCC) is a classic and effective image processing method. This algorithm determines the position of the target carton by sliding a predefined carton template across the image and calculating the cross-correlation values ​​at each location to find the region most similar to the template. Its main advantage lies in its insensitivity to changes in illumination, resisting linear brightness variations to a certain extent, making it well-suited for industrial environments where lighting conditions may be unstable. However, carton palletizing typically requires high-speed, continuous operations to match the overall efficiency of the production line. Traditional NCC algorithms require numerous floating-point operations on each pixel in the search image. When the image and template sizes are large, the computational complexity increases dramatically, resulting in slow positioning speeds. This makes it difficult to meet the real-time requirements of palletizing systems, thus becoming a technical bottleneck restricting the overall improvement of palletizing efficiency. Summary of the Invention

[0004] This application provides a visual positioning method and system for carton palletizing, aiming to solve the problem of low efficiency of template matching algorithms for carton positioning.

[0005] In a first aspect, this application provides a visual positioning method for cardboard box palletizing. The positioning method includes: calculating the gradient angle of pixels within each window and generating an angle histogram; calculating the entropy value of the angle histogram; and selecting windows with entropy values ​​less than a first threshold as candidate windows. The method also includes calculating a corner presence index for the angle histogram of the candidate windows, including: selecting columns with heights greater than a preset threshold as main columns in the angle histogram; merging adjacent main columns into merged columns; and specifying that the corner presence index is positively correlated with the number of merged columns and the sum of the probabilities of all merged columns, and negatively correlated with the sum of the probabilities of all non-merged columns. The method further includes selecting windows with corner presence indices greater than a second threshold. The candidate window for the threshold is used as the corner window; for any pixel within the corner window, a structure tensor matrix is ​​constructed with the pixel as the center, and multiple eigenvalues ​​are calculated, and the harmonic mean of the multiple eigenvalues ​​is calculated; the harmonic means of all pixels within each corner window are clustered to obtain multiple clusters, and the mean of the harmonic means of pixels within each cluster is calculated; for clusters with a mean greater than the high threshold, the pixels within the cluster are directly used as the positioning result of the cardboard box; for clusters with a mean greater than the low threshold and less than or equal to the high threshold, the NCC algorithm is executed to position the cardboard box; for clusters with a mean less than or equal to the low threshold, no positioning is performed.

[0006] By uniformly dividing a cardboard box image into multiple windows, the entropy value calculated from the gradient direction histogram of pixels within the window reflects the degree of disorder in the gradient direction within the window, thus obtaining candidate windows. Merged bars are extracted from the gradient direction histogram, and the corner presence index is calculated based on the number and probability of merged bars and the probability of non-merged bars, which is used to identify corner windows in the candidate windows. The harmonic mean is calculated by analyzing the eigenvalues ​​of the structure tensor matrix of the sub-window corresponding to any pixel in the corner window. Based on the harmonic mean, all pixels in each corner window are clustered, and different positioning strategies are adopted for different clusters to improve the cardboard box positioning efficiency during the cardboard box palletizing process.

[0007] Furthermore, the window size is either 33×33 or 65×65.

[0008] Furthermore, generating the angle histogram includes: using the Sobel operator to calculate the gradient values ​​of pixels within the window in the horizontal and vertical directions, forming a gradient vector. ,in This represents the gradient value of a pixel in the horizontal direction. This represents the gradient value of a pixel in the vertical direction, and the gradient angle of the pixel is obtained through the arctangent function; The angle range is evenly divided into a preset number of angle intervals, and the probability of the gradient corner of all pixels in the window falling in each angle interval is calculated to obtain the gradient direction histogram of the window.

[0009] By constructing a gradient direction histogram of the window and analyzing the concentration of gradient direction distribution within the window, it is possible to reflect the degree to which the pixels within the window conform to the outline features of the carton.

[0010] Furthermore, the first threshold includes: taking the entropy values ​​of all windows in the cardboard box image as input to the Otsu thresholding method and outputting the first threshold.

[0011] Furthermore, the low threshold is obtained as follows: during the historical cardboard box stacking process, an image of a cardboard box when no cardboard box exists is acquired, the harmonic mean of all pixels in the cardboard box image is calculated, and the harmonic mean of each pixel is used as the input of the Otsu threshold segmentation method to output the low threshold.

[0012] By setting a low threshold, it is possible to initially determine whether there are cartons in the carton images collected during the carton stacking process, so that subsequent steps only locate the carton images containing cartons, thereby improving the accuracy of carton location.

[0013] Furthermore, the high threshold is obtained as follows: during the historical cardboard box stacking process, a cardboard box image is acquired when the cardboard box is present, and Gaussian noise is added to blur the cardboard box image. The harmonic mean of each pixel in the cardboard box image is calculated. For pixels whose harmonic mean is greater than the low threshold, the harmonic mean of each pixel is used as the input of the Otsu threshold segmentation method, and the high threshold is output.

[0014] By setting a high threshold, it is possible to initially determine whether there are clear cartons in the carton images collected during the carton stacking process, so that clear cartons can be directly located in subsequent steps, and the NCC algorithm can be used to locate cartons in blurry carton images.

[0015] Furthermore, the size of the sub-window is either 5×5 or 7×7.

[0016] Furthermore, the step of clustering the harmonic mean of all pixels within each corner window to obtain multiple clusters includes: using the harmonic mean of all pixels within each corner window as input to the K-means clustering algorithm, and outputting multiple clusters.

[0017] By clustering all pixels within each corner window, pixels with similar corner features are grouped together, which facilitates the application of different carton positioning methods to different clusters and improves positioning efficiency.

[0018] Furthermore, the NCC algorithm for locating the cardboard box includes: based on the position of pixels in clusters with a mean greater than a low threshold and less than or equal to a high threshold in the cardboard box image, performing non-maximum suppression processing on the pixels; filtering for maxima among spatially adjacent pixels within the cluster; and extracting a preset number of pixels with the highest harmonic mean as feature points to be verified; using each feature point to be verified as the center, cropping a sub-image to be matched from the cardboard box image with the same size as a preset standard cardboard box corner template; and calculating the correlation coefficient between the sub-image to be matched and the standard cardboard box corner template using a normalized cross-correlation algorithm; if the correlation coefficient is greater than a preset matching threshold, then confirming that the feature point to be verified is a real cardboard box outline corner point, and retaining its coordinates as the positioning result of the cardboard box.

[0019] By performing the NCC algorithm only on pixels within clusters whose mean is greater than the low threshold and less than or equal to the high threshold, the visual positioning efficiency during the carton palletizing process can be improved.

[0020] In a second aspect, this application also provides a visual positioning system for carton palletizing, including a processor and a memory, wherein the memory stores computer program instructions that, when executed by the processor, implement a visual positioning method for carton palletizing according to the first aspect of this application.

[0021] This application has the following technical advantages:

[0022] By uniformly dividing the cardboard box image into multiple windows, the entropy value calculated based on the gradient direction histogram of pixels within the window reflects the degree of disorder in the gradient direction within the window, thereby identifying candidate edge regions containing long straight edges and obtaining candidate windows. Adjacent main bars in the gradient direction histogram that exceed a preset threshold are merged into merged bars. A corner presence index is calculated based on the number and probability of merged bars and the probability of non-merged bars, used to identify the window containing the cardboard box outline within the candidate windows, i.e., the corner window. The harmonic mean is calculated by analyzing the eigenvalues ​​of the structure tensor matrix corresponding to any pixel within the corner window. Based on the harmonic mean, all pixels within each corner window are clustered, and different positioning strategies are adopted for different clusters to improve the cardboard box positioning efficiency during the cardboard box palletizing process. Attached Figure Description

[0023] Figure 1 This is a flowchart of a visual positioning method for carton palletizing according to an embodiment of this application.

[0024] Figure 2 This is a positioning result diagram of a cardboard box image according to an embodiment of this application.

[0025] Figure 3 This is a structural block diagram of a visual positioning system for carton palletizing according to an embodiment of this application. Detailed Implementation

[0026] Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] The first aspect of this application provides a visual positioning method for carton palletizing. Figure 1 This is a flowchart of a visual positioning method for carton palletizing according to an embodiment of this application. The specific implementation process of this method will be described in detail below.

[0028] S101: Obtain images of cardboard boxes during the palletizing process.

[0029] In this embodiment, during the stacking of cartons, an industrial-grade CMOS area scan camera is fixedly installed directly above the conveyor belt, perpendicular to the conveyor belt plane. The camera's field of view completely covers the area through which a single carton passes. To ensure the stability and consistency of image quality, a ring of LED industrial light sources is arranged around the camera to provide a uniform, shadowless lighting environment, eliminating the interference of ambient light variations on image quality. When a carton enters the camera's field of view, a photoelectric sensor installed on the side of the conveyor belt triggers the camera to perform a single exposure, capturing a complete image of the carton.

[0030] It should be noted that after acquiring the original cardboard box image, preprocessing is required to enhance the accuracy and robustness of subsequent feature extraction. The preprocessing steps include: converting the acquired RGB color image into an 8-bit single-channel grayscale image to reduce data dimensionality and simplify calculations; and using a Gaussian filtering algorithm to smooth the grayscale image to suppress random noise that may be introduced during acquisition and transmission. Gaussian filtering can effectively remove noise while preserving the edge details of the cardboard box.

[0031] At this point, we have obtained the preprocessed image of the cardboard box.

[0032] S102: Divide the carton image into multiple windows evenly; calculate the gradient angle of each pixel in each window and generate an angle histogram; calculate the entropy value of the angle histogram; and select windows with entropy values ​​less than a first threshold as candidate windows.

[0033] In this embodiment, the carton image acquired during the palletizing process shows that the outline of the carton is composed of long and straight structured edges. On a straight physical outline, the gradient orientation of all pixels is highly consistent and stable; while in printed patterns or noise areas, the gradient orientation is disordered and randomly distributed.

[0034] Therefore, this step calculates the entropy value of the angle histogram to reflect the degree of disorder in the gradient orientation within any window in the cardboard box image.

[0035] Specifically, the cardboard box image is divided into multiple sizes. For non-overlapping windows, the Sobel operator is used to calculate the gradient values ​​of pixels within any window in the horizontal and vertical directions, and these gradients are used to construct the gradient vector. ,in This represents the gradient value of a pixel in the horizontal direction. This represents the gradient value of a pixel in the vertical direction, and the gradient angle of the pixel is obtained through the arctangent function; The angle range is evenly divided into In this embodiment, the gradient direction histogram of the window is obtained by calculating the probability of the gradient corner of each pixel within each angle interval. The value is 33. The value is 12.

[0036] The entropy value of the angle histogram of the window is constructed based on the above features, and the calculation method is as follows:

[0037] In the formula This represents the entropy value of the angle histogram of the window. Indicates the number of angle intervals. The gradient angle of the pixels within the window is represented at the th... The probability of occurrence within a certain angle interval This represents a logarithmic function with the natural constant as its base. This indicates a preset parameter used to avoid... A value of zero prevents the logarithm from being calculated; in this embodiment, the value is 0.01.

[0038] When the window covers the straight edge of the cardboard box, the gradient orientation of most pixels will be concentrated in one or a few adjacent angle intervals, resulting in a probability close to 1 for that angle interval and a probability close to 0 for other angle intervals. In this case, the calculated entropy value is small, and the gradient direction shows significant orderliness. If the window contains a complex pattern or noise, the gradient orientation will be distributed in multiple angle intervals, with each probability being small. The calculated entropy value is large, and the gradient direction shows significant disorderliness.

[0039] Therefore, candidate edge regions containing long, straight edges can be identified using entropy values. Specifically, the entropy values ​​of the angle histograms of all windows in the cardboard box image are calculated and used as input to the Otsu thresholding method. A first threshold value is output, and windows with entropy values ​​less than the first threshold value are considered candidate windows. The Otsu thresholding method is a well-known technique and will not be elaborated upon here.

[0040] S103: Calculate the corner presence index for the angle histogram of the candidate window, including: in the angle histogram, taking the column with a height greater than a preset threshold as the main column, merging adjacent main columns into a merged column, the corner presence index is positively correlated with the number of merged columns and the sum of the probabilities of all merged columns, and negatively correlated with the sum of the probabilities of all non-merged columns; taking the candidate window with a corner presence index greater than a second threshold as the corner window.

[0041] In this embodiment, for the outline of a cardboard box, under real 3D perspective, the corner of the cardboard box may be the intersection of the two edges of the top surface or the intersection of the three edges of the top surface and the side surface. The gradient energy of the corner area will be highly concentrated in a few two or three directions, while the energy in most other directions is very weak; that is, for straight edges, the energy is more extremely concentrated in one direction, while for textured areas, the energy is dispersed in multiple directions.

[0042] Therefore, this step constructs a corner existence index, which is used to identify the window containing the corner points of the carton outline in the candidate window.

[0043] Specifically, for any candidate window obtained in the above steps, columns with a gradient direction greater than a preset threshold are filtered in the gradient direction histogram of the candidate window. Among the filtered columns, adjacent columns are merged to obtain merged columns, and the frequency of the merged columns is the sum of the frequencies of the columns before merging. For non-adjacent columns, they are treated as separate merged columns. In this embodiment, the preset threshold is 0.25.

[0044] Based on the above features, the corner presence index of the candidate window is constructed, and the calculation method is as follows:

[0045] In the formula This indicates that the corner points of the candidate window have an index. This indicates the number of merged bars in the gradient direction histogram of the candidate window. The gradient direction histogram of the candidate window represents the first... The frequency of each merged column This represents a preset parameter used to avoid the denominator being zero, which would prevent calculation. In this embodiment, the value is 0.01.

[0046] Within the candidate window, if corner points of the carton outline exist, there will be a large number of similar gradient directions in a few two or three directions. This results in two or three bars in the gradient direction histogram exceeding a preset threshold, thus forming two or three merged bars. Furthermore, the sum of the probabilities of the merged bars should be significantly greater than the sum of the probabilities of the other bars. Significantly greater than At the same time, to avoid the calculation being incorrect when only the outline of the carton exists in the window and not the corner points of the carton. The size is relatively large, which affects the recognition of corner points on the outline of the cardboard box. As a magnification factor, it improves the accuracy of identifying corner points within the candidate window.

[0047] Following the steps above, the corner presence index of all candidate windows in the cardboard box image is obtained. The corner presence index of all candidate windows is used as the input of Otsu's threshold segmentation method, and the second threshold is output. Candidate windows with values ​​greater than the second threshold are taken as corner windows.

[0048] S104: For any pixel within the corner window, construct a structure tensor matrix with the pixel as the center and calculate multiple eigenvalues, and calculate the harmonic mean of the multiple eigenvalues.

[0049] In this embodiment, the corner point window obtained through the above steps can determine the area where the corner point is located as a whole. In order for the robot or robotic arm to grasp the carton more accurately during the automated palletizing process, it is necessary to further identify the specific location of the corner point in the corner point window.

[0050] From a camera's perspective, the corners of a cardboard box typically appear as a "Y" shape with three edges intersecting or an "L" shape with two edges intersecting. As the relative positions of the camera and the cardboard box change, the edges that are actually perpendicular will show a significant angle in the cardboard box image. That is, the gradient direction of the pixels near the corner will be significantly distributed in two or more non-collinear directions.

[0051] Based on the above analysis, for any corner window, this application constructs the harmonic mean of any pixel in the corner window to reflect the degree of matching between the pixel and the corner.

[0052] Specifically, for any pixel within the corner window, a selection of size [value] is made centered on that pixel. The sub-window is used to construct a structure tensor matrix based on the gradient of the pixels within the sub-window, and the eigenvalues ​​of the structure tensor matrix are calculated. The construction process of the structure tensor matrix is ​​a well-known technique and will not be elaborated here. In this embodiment... The value is 5.

[0053] Based on the above features, the harmonic mean of the eigenvalues ​​of the structural tensor matrix within the sub-window corresponding to the pixel is constructed. The calculation method is as follows:

[0054] In the formula This represents the harmonic mean. and Let these represent the first and second eigenvalues ​​of the structure tensor matrix, respectively. This represents a preset parameter used to avoid the denominator being zero, which would prevent calculation. In this embodiment, the value is 0.01.

[0055] Within the sub-window corresponding to the pixel, if the sub-window is a flat region, the first and second eigenvalues ​​calculated from the structure tensor matrix are both close to 0. If the sub-window is on an edge of the cardboard box, the gradient changes only in one direction, causing the first eigenvalue to be significantly greater than the second eigenvalue, and the second eigenvalue to be close to 0. If the sub-window contains corners, due to the existence of at least two edges with significantly different directions, the gradient within the sub-window will exhibit significant dispersion, resulting in both eigenvalues ​​of the corresponding structure tensor matrix being significantly greater than 0. Based on the above analysis, the harmonic mean constructed by the ratio of the product of the two eigenvalues ​​to the sum of the two eigenvalues ​​can reflect the degree of matching between the pixel and the corner; that is, the larger the value of the harmonic mean, the more likely the pixel is to be a corner. The set of pixels within all corner windows is denoted as the candidate corner set.

[0056] S105: Cluster the harmonic mean of all pixels within each corner window to obtain multiple clusters, and calculate the mean of the harmonic mean of pixels within each cluster; for clusters with a mean greater than the high threshold, directly use the pixels within the cluster as the positioning result of the carton; for clusters with a mean greater than the low threshold and less than or equal to the high threshold, execute the NCC algorithm to position the carton; for clusters with a mean less than or equal to the low threshold, do not perform positioning.

[0057] In this embodiment, the specific corner position within the corner window is located based on the harmonic mean of the candidate corner point set, including: taking the harmonic mean of all pixels in the candidate corner point set as the input of the K-means clustering algorithm, with the number of clusters set to 5, and outputting the clustered pixels, and calculating the mean of the harmonic mean of pixels in each cluster.

[0058] Clusters with a mean greater than the high threshold are denoted as corner clusters. The corner features of the cardboard box outline within these clusters are the most obvious. The positions of the pixels within the corner clusters can be directly used as the positions of the cardboard box outline points in the cardboard box image to achieve the localization of the cardboard box.

[0059] Clusters with a mean greater than the low threshold and less than or equal to the high threshold are denoted as fuzzy corner point clusters. The corner points of the carton outline within these clusters may be affected by factors such as light interference, resulting in a certain degree of fuzziness in the corner point features. In this case, the NCC algorithm is executed to locate the carton.

[0060] Clusters with a mean less than or equal to the low threshold are denoted as cornerless clusters. The corners in these clusters exhibit the weakest saliency of the carton outline corner features, and are treated as background without further processing.

[0061] The NCC algorithm for locating the cardboard box includes: performing non-maximum suppression processing on pixels within a cluster of blurred corner points in the cardboard box image; filtering for maxima among spatially adjacent pixels within the cluster; and extracting several pixels with the highest local harmonic mean as feature points to be verified. Centered on each of these feature points, a sub-image of the cardboard box image with the same size as a preset standard cardboard box corner template is extracted. A normalized cross-correlation algorithm is used to calculate the correlation coefficient between the sub-image and the standard cardboard box corner template. If the correlation coefficient is greater than a preset matching threshold, the feature point is confirmed as a genuine cardboard box corner point, and its coordinates are retained as the cardboard box's location result. If the correlation coefficient is less than or equal to the matching threshold, the feature point is determined to be a false corner point and is removed, thus effectively filtering out background interference while ensuring no genuine weak corner points are missed. In this embodiment, the matching threshold is set to 0.8.

[0062] The low threshold is obtained as follows: during the historical cardboard box stacking process, the cardboard box image when there is no cardboard box is obtained, the harmonic mean of all pixels in the cardboard box image is calculated, and the harmonic mean of each pixel is used as the input of Otsu threshold segmentation method to output the low threshold.

[0063] The high threshold is obtained as follows: during the historical cardboard box stacking process, the cardboard box image is acquired when the cardboard box is present, and Gaussian noise is added to blur the cardboard box image. The harmonic mean of each pixel in the cardboard box image is calculated. For pixels whose harmonic mean is greater than the low threshold, the harmonic mean of each pixel is used as the input of the Otsu threshold segmentation method, and the high threshold is output.

[0064] According to a second aspect of this application, this application also provides a visual positioning system for carton palletizing. Figure 3 This is a structural block diagram of a visual positioning system for cardboard box palletizing according to an embodiment of this application. Figure 3 As shown, the system 50 includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a visual positioning method for carton palletizing according to the first aspect of this application. The system also includes other components well-known to those skilled in the art, such as a communication bus and a communication interface; their configuration and functions are known in the art and will not be described further here.

Claims

1. A vision positioning method for carton palletizing, characterized by, The positioning method includes: uniformly dividing a carton image into multiple windows; calculating the gradient angle of pixels within each window and generating an angle histogram; calculating the entropy value of the angle histogram; and selecting windows with entropy values ​​less than a first threshold as candidate windows; calculating a corner presence index for the angle histogram of the candidate windows, including: in the angle histogram, selecting columns with heights greater than a preset threshold as main columns; merging adjacent main columns into merged columns; the corner presence index is positively correlated with the number of merged columns and the sum of the probabilities of all merged columns, and negatively correlated with the sum of the probabilities of all non-merged columns; and selecting candidate windows with corner presence indices greater than a second threshold as corner windows. For any pixel within the corner window, construct a structure tensor matrix with the pixel as the center and calculate multiple eigenvalues, and calculate the harmonic mean of the multiple eigenvalues. Clustering is performed on the harmonic mean of all pixels within each corner window to obtain multiple clusters. The mean of the harmonic mean of pixels within each cluster is calculated. For clusters with a mean greater than a high threshold, the pixels within the cluster are directly used as the positioning result of the cardboard box. For clusters with a mean greater than a low threshold and less than or equal to the high threshold, the NCC algorithm is executed to position the cardboard box. For clusters with a mean less than or equal to the low threshold, no positioning is performed.

2. A vision positioning method for carton stacking according to claim 1, characterized in that, The window size is either 33×33 or 65×65.

3. The visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The generating angle histogram comprises: calculating gradient values of pixels in a window in horizontal and vertical directions using a Sobel operator to form gradient vectors wherein represents a gradient value of the pixel in the horizontal direction, represents a gradient value of the pixel in the vertical direction, and a gradient angle of the pixel is obtained through an arctangent function; and an angle range of the gradient angle is evenly divided into a preset number of angle intervals, probabilities of gradient angles of all the pixels in the window falling into each angle interval are counted, and a gradient direction histogram of the window is obtained.

4. The visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The first threshold includes: taking the entropy value of all windows in the cardboard box image as input to the Otsu thresholding method and outputting the first threshold.

5. A visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The low threshold is obtained as follows: during the historical cardboard box stacking process, the cardboard box image when there is no cardboard box is acquired, the harmonic mean of all pixels in the cardboard box image is calculated, and the harmonic mean of each pixel is used as the input of the Otsu threshold segmentation method to output the low threshold.

6. The visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The high threshold is obtained as follows: during the historical cardboard box stacking process, cardboard box images are acquired when cardboard boxes are present, and Gaussian noise is added to blur the cardboard box images. The harmonic mean of each pixel in the cardboard box image is calculated. For pixels with a harmonic mean greater than the low threshold, the harmonic mean of each pixel is used as the input of the Otsu threshold segmentation method, and the high threshold is output.

7. The visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The size of the sub-window is either 5×5 or 7×7.

8. The visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The step of clustering the harmonic mean of all pixels within each corner window to obtain multiple clusters includes: using the harmonic mean of all pixels within each corner window as input to the K-means clustering algorithm, and outputting multiple clusters.

9. A visual positioning method for cardboard box palletizing according to claim 1, characterized in that, The NCC algorithm for locating the cardboard box includes: based on the position of pixels in clusters with a mean greater than a low threshold and less than or equal to a high threshold in the cardboard box image, performing non-maximum suppression processing on the pixels; filtering for maxima among spatially adjacent pixels within the cluster; and extracting a preset number of pixels with the highest harmonic mean as feature points to be verified; using each feature point to be verified as the center, cropping a sub-image of the cardboard box image with the same size as a preset standard cardboard box corner template; calculating the correlation coefficient between the sub-image to be matched and the standard cardboard box corner template using a normalized cross-correlation algorithm; if the correlation coefficient is greater than a preset matching threshold, then confirming that the feature point to be verified is a real cardboard box outline corner point, and retaining its coordinates as the positioning result of the cardboard box.

10. A visual positioning system for cardboard box palletizing, characterized in that, include: The system includes a processor, a memory, and a communication interface, wherein the memory stores a computer program that, when executed by the processor, implements a visual positioning method for carton palletizing as described in any one of claims 1 to 9.