Due to the inaccurate and unreliable moving distance measurement of the hydraulic support in mines, a method based on the random circle detection (RCD) algorithm and the fruit fly optimization algorithm (FOA) is proposed. According to the changing center and radium of the circle on the support, the relative position of adjacent supports is acquired by the camera. The noise of the collected image is moved, and the edge feature is protected using a bilateral filter. A local adaptive threshold algorithm is used for binary processing of the image. Then, RCD is used to detect the contour, which is similar to the circle. A method to detect the circle based on FOA is used to accurately detect the circle. Subsequently, the relative distance is calculated according to the change of the circle. Finally, the accuracy and reliability of the proposed method are verified though the experiment.