An anti-collision assistance system designed to detect the vehicle ahead, monitor its braking behavior in real time, and issue a warning when the leading vehicle appears to be braking sharply relative to the user's car. This uses optical expansion to infer collision risk by monitoring how rapidly a vehicle's detected bounding box grows over time.
- Detects cars, buses, and trucks using YOLOv8 object detection.
- Tracks each object's bounding box over time and computes area growth percent.
- Averages area change percent values across the last few frames for each tracked vehicle.
- Uses the relative bounding-box area to select a required percent-change threshold:
- smaller relative size => larger required threshold
- larger relative size => smaller required threshold
- Issues an alert (
resources/beep.mp3) when smoothed area growth exceeds the threshold, representating aggresive braking or an immminent collision.
- Run
main.py. - Enter the base video name when prompted. The app will open
tests/<input>.mp4. - An OpenCV window should open.
- Press
qto quit,fto jump forward 10 frames, orrto reset frame tracking history.
- The tracker only monitors vehicles that are about 20% in the frame (to track only the vehicle infront of the user).
- Whether or not the vehicle is braking is ignored, only the change bounding box size.
- Can be tested with dashcam footage of brake checking from YouTube.
pygameis used instead ofwinsoundto support compatibility on Linux (Raspberry Pi).
- Oncoming traffic from another lane may trigger an alert due to the vehicles being included in the frame.
- Low quality or miscentered video footage may not detect braking properly.
- The dynamic threshold may not be fine-tuned enough.