Since the spindle thermal error of CNC machine tools has a significant impact on machining precision, this paper introduces a unique approach for modeling spindle thermal error. Several key steps are involved in the proposed approach. First, the Fluke thermal imaging camera is employed for acquiring thermal image information of the spindle system. Second, the Gaussian filter is employed to denoise the thermal image sequence. Next, the temperature values at the measurement points are extracted from the thermal image sequence according to the mapping relationship between the grayscale value and the temperature value. Subsequently, critical temperature points are identified from thermal images using the density-based spatial clustering of applications with noise (DBSCAN) algorithm and the correlation coefficient method. Finally, the multi-verse optimized NARX neural network is employed to investigate the nonlinear prediction of thermal deformation. The research is conducted on the VMC-850E vertical machining center as the subject of study. The performance of the model is validated under conditions of idle spindle and 5000 r/min, comparing prediction results against traditional algorithms. The findings demonstrate that the non-contact measurement method based on thermal imaging successfully establishes the thermal error model, achieving a prediction accuracy of 0.1517 μm for the MVO-NARX model.