The objective is to improve the prediction accuracy of foundation pit deformation in geotechnical engineering, thereby provide early warning for engineering practice. The digital closerange photogrammetry is used to obtain monitoring data. The error compensation method is used to optimize the center of the monitoring point. Aiming at the limitations of back propagation neural network (BPNN), a genetic algorithm (GA)-optimized BPNN algorithm is proposed. Then, the optimized algorithm is applied to predict the deformation and displacement of foundation pits from three aspects, i.e., simple horizontal displacement, simple longitudinal displacement, and the combination of horizontal and longitudinal displacements. Meanwhile, the time domain, space domain, and time-space domain are used as input features to compare the prediction results of the BPNN model and the GA-optimized BPNN model. Finally, the GA-improved BPNN is compared with the Support Vector Regression (SVR) model and Random Forest (RF) model. The results show that the prediction result, obtained by simultaneously using horizontal displacement and longitudinal displacement as input features, has smaller errors; also, the actual output is closer to the expected output. Compared with the prediction result with time domain and space domain as input features, the prediction result with time-space domain as input features is closer to the expected output. Taking the combination of time and space domains as input features, compared with the BPNN model, the GA-optimized BPNN model has a lower Root Mean Squared Error (RMSE) value (0.0163), a larger Index of Agreement (IA) value (0.9800), and a shorter training time (7.08 s). Compared with the SVR model and RF model, the GA-improved BPNN model has a lower Root Mean Squared Error (RMSE) value (0.0211), a larger Index of Agreement (IA) value (0.9706), and shorter training time (7.61 s). Therefore, the foundation pit deformation prediction model based on BPNN and GA has strong prediction ability, which can be popularized and applied in similar geotechnical engineering.