The purpose of the algorithm is to effectively detect vehicles in different conditions, especially in scenes recorded by vehicle recorders. The proposed method is designed to handle complex scenarios with high accuracy and efficiency. Through the use of YOLOV5, the algorithm is able to identify and locate vehicles despite occlusions, density, and low lighting. The intermediate hidden layer's activation function is achieved by using the Leaky ReLU, and data enhancement strategies are utilized to enhance detection performance. By recognizing 100 images of traffic vehicles in complex scenes, the validation results show that the recognition rate of this recognition method is 78.87%, 89.11% and 91.88% for occluded vehicles, crowded vehicles and independent vehicles, respectively. Furthermore, the recognition speed reached 0.012 s/a, which was reduced by 0.005s compared to the original time. All the results demonstrate that the proposed algorithm has a high recognition rate and real-time speed for the complex scenes, indicating that the convolutional neural network has a promising future in the vehicle detection of complex application scenes.