With the increase in traffic, vehicle scratches and rear-end collision caused by vehicle line-pressing violation have brought a great threat to driving safety. A three-step approach based on YOLOv5 and DeepSort is proposed to detect vehicle line-pressing in this paper. First, the YOLOv5 network is trained on a large traffic dataset to complete the detection of vehicles, and the DeepSort algorithm is used to achieve the tracking of moving vehicles. After that, we use Hough transform to detect lane lines and obtain their position. Finally, according to the information of lane lines and the position of vehicles at different moments, we propose an algorithm to judge whether vehicles press lines. The results show that the approach has good performance and the accuracy of violation detection is 99.5%.