In the construction of the civil engineering infrastructure, the noise and vibration are affected by the geological conditions, adopting specific construction techniques based on the geological conditions is of great significance in suppressing the noise and vibration caused by the construction. To classify and evaluate the rock mass quality, the rock quality designation (RQD) is adopted widely in the geological and mining engineering. Traditionally, to obtain RQD, lengths of drilling core pieces are measured and RQD is calculated manually, which is labor-expensive and time-consuming. With the development of the computational power, the image treatment driven by the computer vision creates a potential approach to obtain RQD automatically. In the present work, the image treatment process with the aid of the object detection and the image segmentation is adopted to obtain RQD automatically, based on the similarity of features such as color and texture, the segment anything model is adopted to detect the rock cores in the image, then, the YOLOv8 algorithm is adopted to train the model, and the gap features of the rock chip segments are extracted for segmentation of different rock core segments. To test the performance of the proposed approach, 10 boreholes from Shapingba Railway Comprehensive Reconstruction Project are adopted to conduct the case study. Compared to the traditional manual approach, RQD obtained by the proposed approach is relatively accurate and obviously efficient, namely, the average error is less than 5% and the time consumed is less than 70%.