Adaptive optics has been widely used in biological science to recover high-resolution optical image deep into the tissue, where optical distortion detection with high speed and accuracy is strongly required. Here, we introduce convolutional neural networks, one of the most popular machine learning models, into Shack–Hartmann wavefront sensor (SHWS) to simplify optical distortion detection processes. Without image segmentation or centroid positioning algorithm, the trained network could estimate up to 36th Zernike mode coefficients directly from a full SHWS image within 1.227[Formula: see text]ms on a personal computer, and achieves prediction accuracy up to 97.4%. The simulation results show that the average root mean squared error in phase residuals of our method is 75.64% lower than that with the modal-based SHWS method. With the high detection accuracy and simplified detection processes, this work has the potential to be applied in wavefront sensor-based adaptive optics for in vivo deep tissue imaging.