To ensure that the crane can smoothly calibrate and align the lifting rod with the beam body lifting hole, it is necessary to use image processing technology to locate and detect the corner coordinates of the crane’s lifting rod. Traditional corner detection methods are not suitable for this scene. This article proposes a new idea for corner positioning, which locates corner coordinates through the intersection of straight lines. Firstly, using the R and G channels of the RGB color space to construct a grayscale difference map is beneficial for Otsu’s threshold segmentation; Secondly, this article proposes an optimal adaptive threshold determination method to filter the number of votes in the clustering results, eliminate interfering straight lines, and improve the clustering centroid calculation method based on the weight calculation formula of different voting proportion, replacing the original clustering centroid as the basis for line fitting; Finally, calculate the corner coordinates of the crane’s grab boom based on the straight line fitting results, and compare the recognition accuracy under different lighting conditions. This method is significantly superior to traditional corner detection methods, providing a method basis for solving the algorithm accuracy and robustness problems of port cranes under multiple environmental variables.