Skip to content

Conversation

@MateoLostanlen
Copy link
Member

@MateoLostanlen MateoLostanlen commented Dec 28, 2025

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

@MateoLostanlen MateoLostanlen marked this pull request as ready for review January 14, 2026 14:57
@MateoLostanlen MateoLostanlen requested a review from fe51 January 14, 2026 14:57
sequence_id: Union[int, None] = Field(None, foreign_key="sequences.id", nullable=True)
azimuth: float = Field(..., ge=0, lt=360)
bucket_key: str
bboxes: str = Field(..., min_length=2, max_length=settings.MAX_BBOX_STR_LENGTH, nullable=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clearer, we should rename this field as bbox in the singular (and update all references to it).

azimuth: float = Field(..., ge=0, lt=360)
bucket_key: str
bboxes: str = Field(..., min_length=2, max_length=settings.MAX_BBOX_STR_LENGTH, nullable=False)
others_bboxes: Union[str, None] = Field(default=None, nullable=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have a max lenght as well derived from max_length=settings.MAX_BBOX_STR_LENGTH (2 bboxes max in other bboxes with the current logic)

)
matched_sequence: Optional[Sequence] = None
for seq in candidate_sequences:
if seq.id is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can it be empty ? candidate_sequences are coming from a sequences fetch_all, hence, objects are supposed to have an id.

azimuth = detection_data.get("azimuth")
if azimuth is None:
azimuth = detection_data.get("pose_azimuth")
if azimuth is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to reconsider which info to provide in slack message. This sequence of if statements with different concepts emphasises that the information provided is unclear.

Copy link
Member

@fe51 fe51 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made commits to fixed some discussed points.
Should be challenged once you are back, but thanks a lot for this feature !

@fe51 fe51 merged commit ed87c2a into main Jan 22, 2026
24 checks passed
@fe51 fe51 deleted the split_detections branch January 22, 2026 10:55
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.

3 participants