Skip to content

feat(detections): accept empty bboxes and keep sequence frames continuous#624

Open
MateoLostanlen wants to merge 5 commits into
mainfrom
feat/continuity-detections
Open

feat(detections): accept empty bboxes and keep sequence frames continuous#624
MateoLostanlen wants to merge 5 commits into
mainfrom
feat/continuity-detections

Conversation

@MateoLostanlen

Copy link
Copy Markdown
Member

Devices had to send a fake placeholder bbox (0.0,0.0,0.0001,0.0001,0.0) for frames with no detection, which created phantom sequences (placeholders overlap each other and seed a sequence after 3 frames).

  • bboxes="[]" is now valid on POST /detections: the frame is attached with an empty bbox ("continuity detection") to every sequence of the pose seen within SEQUENCE_CONTINUITY_SECONDS (default 120s) that no real bbox of the request matched; with no active sequence, nothing is stored (204). This also keeps a frame in a sequence whose smoke faded while another object on the same frame is still detected (multi-bbox case).
  • Continuity rows never refresh last_seen_at / max_conf and never seed sequences, but re-enqueue temporal validation; spatial matching, notifications and per-sequence counts use the last non-empty bbox only.
  • Deleting a detection no longer removes the S3 frame object while sibling rows (multi-bbox, continuity) still reference it.
  • pyroclient.create_detection accepts an empty bbox list.

…uous

A frame with no detection had to carry a fake placeholder bbox, which
created phantom sequences (placeholders overlap each other and seed a
sequence after a few frames). bboxes="[]" is now valid: the frame is
attached with an empty bbox to every recently-seen sequence of the pose
(SEQUENCE_CONTINUITY_SECONDS) not already covered by a real bbox of the
same request, and stored nowhere otherwise (204). Continuity rows never
refresh last_seen_at nor max_conf, but re-enqueue temporal validation;
spatial matching compares against the last non-empty bbox so it survives
them. This also keeps a frame in a sequence whose object faded while
another object on the same frame is still detected.
Continuity rows carry a frame, not a detection: notification channels
now use the sequence's latest non-empty detection, and per-sequence
detection counts skip empty bboxes.
…tection

Detections of the same upload (multi-bbox siblings, continuity rows)
share one S3 frame object; deleting a single detection removed the
image out from under the others.
Devices report a frame with no detection by sending an empty list
instead of a placeholder bbox; the API attaches it to recently-seen
sequences (201) or stores nothing (204).
response = await async_client.post(
"/detections", data=payload, files={"file": ("logo.png", mock_img, "image/png")}, headers=auth
)
assert response.status_code == 204, print(response.__dict__)
response = await async_client.post(
"/detections", data=payload, files={"file": ("logo.png", mock_img, "image/png")}, headers=auth
)
assert response.status_code == 201, print(response.__dict__)
files={"file": ("logo.png", mock_img, "image/png")},
headers=auth,
)
assert response.status_code == 201, print(response.__dict__)
response = await async_client.post(
"/detections", data=payload, files={"file": ("logo.png", mock_img, "image/png")}, headers=auth
)
assert response.status_code == 201, print(response.__dict__)
files={"file": ("logo.png", mock_img + bytes([idx]), "image/png")},
headers=auth,
)
assert response.status_code == 201, print(response.__dict__)
files={"file": ("logo.png", mock_img + b"-final-frame", "image/png")},
headers=auth,
)
assert response.status_code == 201, print(response.__dict__)
COMPILED_BOXES_PATTERN = re.compile(BOXES_PATTERN)

# Stored bbox of a continuity detection: a frame attached to a sequence with no detection on it.
EMPTY_BBOXES = "[]"
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.25%. Comparing base (2f4a08a) to head (d4d2d48).

Files with missing lines Patch % Lines
src/app/api/api_v1/endpoints/detections.py 96.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #624      +/-   ##
==========================================
+ Coverage   90.97%   93.25%   +2.27%     
==========================================
  Files           3       58      +55     
  Lines         133     2980    +2847     
==========================================
+ Hits          121     2779    +2658     
- Misses         12      201     +189     

☔ View full report in Codecov by Harness.
📢 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.

1 participant