With the widespread application of deep learning technology in the field of intelligent driving, machine vision has become the preferred technology for vehicle detection tasks. However, high-precision object detection often involves a large number of parameters and significant computational complexity, making algorithm deployment challenging and hindering real-time system response. This study adopts the lightweight detection model YOLOv8n as the foundational framework, optimizing it to develop BiFCNet-YOLOv8, which aims to balance detection accuracy with computational efficiency for in-vehicle system deployment. In our research, the more efficient Bi-FPN replaces the traditional PANet, enhancing feature interactions across different scales through bidirectional pathways. Additionally, the CBAM attention mechanism is incorporated between the Neck and Head layers to further refine information and enhance local feature representation. Comparative experiments show that the improved model increases Precision by 1.71% and mAP0.5:0.95 by 3.23%, with a parameter growth of only 6.43M and a FLOPS increase of only 15.83B. The detection algorithm integrates TTC and DeepSORT to enhance the driving warning function. Road tests confirm that this algorithm can effectively and accurately detect the position of the vehicle ahead. In simulation tests, key parameters such as relative speed and longitudinal acceleration meet the requirements for collision warning systems. This study provides a lightweight and efficient detection algorithm solution for vehicle collision warning tasks.