Nowadays, the detection technology of cracks in subway tunnels with increasingly developed rail transit in China is an important research direction. The subway will be a pillar of future traffic, so the safety of subway tunnels is also a top priority. Tunnel cracks are one of the most common problems. In the past, there were many methods for detecting cracks, but each has its own shortcomings, so this paper proposes a new algorithm. The purpose of the experiment in this paper is to identify tunnel cracks by designing an automatic tunnel crack detection system based on machine vision, in order to enhance the image using a combination of Mask homogenization and gray-scale corrosion, and use a Gaussian-fast median filter algorithm A large amount of noise is filtered out, and the crack image is segmented based on the Otsu method, and finally a binary image is obtained. The research results show that the proposed algorithm has a recognition rate of more than 95% for ordinary cracks, and an accuracy rate of 83% for the surface cracks of subway tunnels. Advantage. It is believed that this algorithm will greatly improve the safety of construction and train operation and protect people's lives.