feat: CV line-crossing entry/exit detection with tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-13 15:10:01 -07:00
parent 655abc914b
commit 0a6470a096
2 changed files with 91 additions and 1 deletions

View File

@@ -146,6 +146,23 @@ CVResult cv_process(CVState& state, const uint8_t* frame, uint8_t line_pct) {
t.missed = 0;
state.tracks.push_back(t);
}
// Line crossing check added in Task 6
// Line crossing check
for (auto& track : state.tracks) {
if (track.missed > 0) continue; // only check tracks matched this frame
bool now_above = (track.y < line_y);
if (now_above != track.above_line) {
if (!now_above) {
// was above, now below → entry
state.entries++;
result.entries_delta++;
} else {
// was below, now above → exit
state.exits++;
result.exits_delta++;
}
}
track.above_line = now_above;
}
return result;
}