Skip to content

Totoro700/preemptive-cps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Preemptive Collision Prevention System (PCPS)

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.

Approach

  • 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.

Usage

  1. Run main.py.
  2. Enter the base video name when prompted. The app will open tests/<input>.mp4.
  3. An OpenCV window should open.
  4. Press q to quit, f to jump forward 10 frames, or r to reset frame tracking history.

Notes

  • 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.
  • pygame is used instead of winsound to support compatibility on Linux (Raspberry Pi).

Known issues

  • 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.

About

Preemptive collision prevention system with optical expansion and scale tracking

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages