In order to achieve the resolution comparable to that of a monolithic primary mirror telescope and make the imaging quality of the imaging system reach or approach the diffraction limit, the submirrors of the segments telescope should ensure co-phase splicing. To solve the problem of phase error detection, a high-precision piston error detection method based on convolutional neural network (CNN) is proposed. By setting a mask with a sparse multi-subpupil configuration on the exit pupil of the imaging system, a point spread function (PSF) image dataset that is extremely sensitive to the piston error is constructed. According to the characteristics of this dataset, a high-performance CNN model is built. And the best detection range of CNN is tested. The simulation results show that a single network can accurately output the piston error of one or more submirrors in the capture range slightly less than one wavelength. When applied to the six-submirror imaging system, the detection precision of the piston error reaches 0.0013λ RMS (Root Mean Square). And the method has good robustness to residual tip-tilt error, wavefront aberration, and CCD noise, light source bandwidth. The method is simple and fast, and can be widely used in the detection of the piston error of the segments.