(a) (b) (c)
Figure 10. Line detection results under different Hough transform thresholds
From Figure 10a, it can be seen that when the voting threshold is 30, the Hough transform detects multiple straight lines in the figure. That is, the smaller the voting threshold setting, the shorter the line segment features that can be detected, It is obvious that this will detect the interfering pixels in the edge image as straight lines. In Figure 10b, when the threshold of vote count is 40, the number of interfering pixels detected in the Hough transform detection results significantly decreases. Therefore, it can be concluded that increasing the threshold of vote count will improve the accuracy of line detection. But when the threshold of the number of votes is 60, the Hough transform only detects two edge lines of the crane grabbing the boom, missing the other two edge lines. This indicates that the edge line detection of the crane’s grab boom cannot be achieved solely by increasing the threshold setting of the number of votes. In the edge detection image shown in Figure 10, Due to factors such as uneven lighting ,the linearity of the pixel arrangement of the four edge lines of Crane grabbing boom will undergo a sudden change , There may be slight differences in the parameters of the lines detected on the same edge line. And these subtle differences may directly affect the accuracy of line fitting. Therefore, it is difficult to determine which straight line to use as the edge straight line for the crane to grab the boom, Meanwhile, the purpose of conducting line detection in this article is to calculate the coordinates of the three corner points of the crane’s grab boom through the intersection of lines, Therefore, it is necessary to fit the detected straight lines and simplify them to four.

2.2 Clustering of Line Parameter Points Based on k-means

The coordinate points mapped to the Hough space correspond to a straight line in the image coordinate system, Crane grabbing boom has 4 edge lines. Therefore, the clustering method[20-21] is adopted to cluster all the line parameter points detected by the Hough transform into the same number of classes as the number of edges of Crane grabbing boom . Compared to other clustering algorithms, the k-menas algorithm has advantages such as simple algorithm idea, fast convergence speed, better clustering effect, and the main parameter that needs to be adjusted is only the number of clusters K. When other clustering algorithms are applied to edge maps with significant interference, they will cluster the coordinates of the line parameter points detected by Hough transform into an uncertain number of clusters. Intuitively manifested as fitting 3, 4, 5, or even more straight lines, From an engineering perspective, it is not possible to guarantee the stability of the coordinates of the three corner points used to obtain the crane’s grasping boom. The k-means algorithm needs to specify the number of clustering clusters K in advance to ensure that the lines detected by the Hough transform can be clustered into four categories, intuitively manifested as fitting four corresponding lines. Therefore, this article uses the k-means algorithm to cluster linear parameter points.
K-means algorithm is a unsupervised learning clustering method. According to the attributes of N data objects, it is divided into K clusters, and the center point of each cluster is calculated. Make the clustering results meet the requirements of high similarity among samples within different clusters and low similarity among samples between different clusters. It uses the Euclidean distance and the sum of squared errors criterion as the evaluation criteria.
Specifically, for a given K clusters,the center point of each cluster is , all data points in the -th cluster are in set , and represents the Nth data point in the -th cluster.The sum of squared errors of the -th cluster and the sum of squared errors are shown below,the goal of the k-means algorithm is to find a partitioning method,the process of recalculating the cluster center point and reallocating data points to the cluster through iterative methods to minimize the total sum of squared errors (SSE).
Perform k-means clustering analysis on the parameter coordinates of straight lines mapped to the Hough space, as shown in Figure 11. The edge detection results shown in Figure 11a contain a large number of interfering edge points, which have weak linear relationships. Under low threshold conditions, pixels with weak linear relationships are easily detected as straight lines. The voting threshold in Figure 11 is 40, Normalize the coordinates of parameter points with votes higher than 40 in the Hough space voter and perform k-means clustering analysis. The clustering results are affected by the interference coordinate points in the Hough space. Figure 11c shows that the clustering center of the red cluster is affected by the interference data points. The intuitive manifestation is that the fitted straight line produces a significant deviation, as shown in Figure 11b.