Longitudinal cracks are a common defect on the surface of continuous casting slabs, and cause increases in additional processing costs or long-time interruptions. The accurate identification of surface longitudinal cracks is helpful to ensure the casting process is adjusted in time, which significantly improves the quality of slabs. In this research, the typical temperature characteristics of thermocouples at the position of longitudinal cracks and their adjacent locations were extracted. The principal component analysis (PCA) method was used to reduce the dimensions of these characteristics to remove the redundant information. The particle swarm optimization (PSO) method was introduced to optimize the parameter. On this basis, a recognition model of surface longitudinal cracks was established, based on a particle swarm optimization–eXtreme gradient boosting (XGBOOST) model. Finally, this model was trained and tested using longitudinal crack and non-longitudinal crack samples and compared with the decision tree, the gradient boosting decision tree (GBDT) and XGBOOST models. The test results showed that PSO-XGBOOST had the best identification performance in all evaluation indexes. The accuracy, F1 score and alarm rate results were 95.8%, 92.3% and 100%, respectively, and the false alarm rate was as low as 5.5%. The research results provide a theoretical basis and a reliable model for surface longitudinal crack identification.