Skip to content

Conversation

@MateoLostanlen
Copy link
Member

@MateoLostanlen MateoLostanlen commented Dec 28, 2025

⚠️ This PR depends on #538 and must be merged after it.

This PR builds on top of #538 and further refines the detection and sequencing logic by making pose handling explicit and by tightening payload validation and sequence attribution.

What’s new in this PR

Detection model and API changes

  • Dropped Detection.azimuth

  • Made pose_id mandatory for all detections

  • Creation logic now:

    • Explodes multi bbox payloads into one Detection per bbox
    • Stores sibling bounding boxes in others_bboxes
    • Ensures all detections reference the same uploaded media key

Sequencing logic improvements

  • Sequences are now looked up using:

    • camera_id
    • pose_id
    • Recent last_seen
  • For each new detection:

    • Its bbox is parsed

    • A candidate sequence is reused only if the last bbox overlaps

    • Otherwise, a new sequence is created

      • Cone is computed using the pose azimuth
      • First bbox initializes the spatial reference
  • This prevents merging detections that are spatially distant but temporally close

Helpers refactor

  • Bbox parsing moved to a shared scope
  • Overlap and parsing helpers are always available
  • Cone computation consistently relies on pose azimuth

Why this matters

The main goal of this change is to separate unrelated detections coming from the same image.
When a single frame contains both a real fire and a false positive, these detections have nothing in common spatially or semantically and must not end up in the same sequence.

By enforcing one detection per bbox and reusing sequences only when spatial overlap exists, we ensure that fires and false positives evolve independently, even if they originate from the same image and timestamp

@socket-security
Copy link

socket-security bot commented Dec 28, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednumpy@​1.26.47510010010070
Addednumpy@​2.4.07510010010070
Addedpandas@​2.3.37610010010080
Addednetworkx@​3.697100100100100
Addednetworkx@​3.6.197100100100100
Updatedbotocore@​1.42.13 ⏵ 1.42.1498 -210010010070 -30
Updatednodeenv@​1.9.1 ⏵ 1.10.098 +1100100100100
Addedpyproj@​3.7.298100100100100
Updatedboto3@​1.42.13 ⏵ 1.42.1499 -110010010080 -19
Addedgeopy@​2.4.1100100100100100
Updatedfastapi@​0.125.0 ⏵ 0.127.0100100100100100
Addedgeographiclib@​2.1100100100100100

View full report

@codecov
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

❌ Patch coverage is 72.67206% with 135 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.50%. Comparing base (ac3e175) to head (84794aa).

Files with missing lines Patch % Lines
src/app/api/api_v1/endpoints/detections.py 59.54% 53 Missing ⚠️
src/app/api/api_v1/endpoints/sequences.py 41.81% 32 Missing ⚠️
src/app/services/overlap.py 85.25% 23 Missing ⚠️
src/app/api/api_v1/endpoints/alerts.py 79.31% 12 Missing ⚠️
src/app/api/api_v1/endpoints/organizations.py 41.66% 7 Missing ⚠️
src/app/db.py 33.33% 6 Missing ⚠️
src/app/crud/base.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #539      +/-   ##
==========================================
- Coverage   83.99%   81.50%   -2.49%     
==========================================
  Files          42       44       +2     
  Lines        1318     1633     +315     
==========================================
+ Hits         1107     1331     +224     
- Misses        211      302      +91     
Flag Coverage Δ
backend 81.50% <72.67%> (-2.51%) ⬇️
client ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants