r/computervision • u/kendryte_k230 • 21d ago
Showcase Calculating the risk of vehicle hitting jaywalker via an embedded, visionAI implementation.
Continuing from previous post of wanting to make an improvement off previous script, where we said one of a more practical implementations will be to analyse the risks of moving vehicle hitting jaywalker.
Adding hit score as below:
The score answers: "How dangerous is this vehicle to this jaywalker right now?" on a 0-99 % scale, for every vehicle-jaywalker pair on screen.
It is a risk index built from rules, not a statistically calibrated probability. There is no crash data behind it, and 80 % does not mean "8 in 10 such situations end in a hit". It is designed so that:
- it rises smoothly as danger grows and falls as danger passes;
- an imminent hit always reads high (above 75 %, shown in red);
- harmless situations stay low.
The range is strictly 0 to 99 %. 100 % is never shown, because the system cannot be certain a hit will happen.
Input to this analysis will be : 1) Distance; 2) Speed; 3) Direction.
The formula
Stopped vehicle (speed 0, or not yet known):
score = 99 x exp(-d / 5 m) x 0.4A stopped vehicle cannot hit anyone, but a jaywalker right next to one is still in a risky place (it may pull away). So the score is capped at 40 % (RISK_STATIONARY_WEIGHT).
Moving vehicle: the score is the highest of three measures:
1. Proximity 99 x exp(-d / 5 m)
x (0.7 + 0.3 x min(1, km/h / 30)) slower = a little lower
x (1 - 0.5 x how directly it is driving away)
2. Time to 99 x exp(-TTC / 1.5 s)
contact where TTC = d / (speed towards the jaywalker)
(only while the vehicle is closing in)
3. Near floor if d <= 1 m: 80 % at 1 m, rising evenly to 99 % at contactNot yet a field test, will conduct actual field test on actual road soon for real data.
(A noticeable bug, count of jaywalkers not tally with J ID. will fix in next version).
Suggestions/Comments welcome on what else need to be considered for the formula.
previous posts:
part 1: https://www.reddit.com/r/computervision/comments/1xliui4/a_project_to_identify_jaywalker/

