Skip to content

feat: implement linear frame interpolation logic and unit tests#82

Merged
Devnil434 merged 7 commits into
Devnil434:mainfrom
saoneenandi:feature/frame-interpolation
May 20, 2026
Merged

feat: implement linear frame interpolation logic and unit tests#82
Devnil434 merged 7 commits into
Devnil434:mainfrom
saoneenandi:feature/frame-interpolation

Conversation

@saoneenandi
Copy link
Copy Markdown

@saoneenandi saoneenandi commented May 17, 2026

Description

Resolves #68

This PR implements linear frame interpolation for trajectories when a tracked object experiences temporary occlusions or missed YOLO detections. By generating smooth intermediate bounding box steps and maintaining timeline continuity, this enhancement ensures that downstream metric engines correctly calculate cumulative dwell times and prevents visual snapping on front-end dashboards.

🛠️ Changes Implemented

1. Core Logic (services/tracking/tracker.py)

  • Implemented _interpolate_trajectory() to calculate uniform coordinate and bounding box dimension deltas over a dynamic frame gap sequence.
  • Added explicit "interpolated": True flags to all synthetic sequence points to guarantee tracking data telemetry transparency.
  • Applied float rounding (2 decimal places) to all calculated positions (x, y, w, h) for consistent data schemas and dashboard safety.
  • Added protective defensive boundaries to abort and return empty sequences [] if gap_frames <= 0.

2. Test Coverage (tests/test_tracker.py)

Added a comprehensive suite of pytest cases to lock down correctness and prevent future regression:

  • test_interpolate_trajectory_success: Validates accurate linear coordinate steps, exact index incrementation, and proper metadata injection across standard multi-frame occlusions.
  • test_interpolate_trajectory_no_gap: Assures defensive short-circuiting against zero or negative frame gap arguments.
  • test_interpolate_trajectory_no_movement: Simulates static occlusion cases to verify coordinate locks function flawlessly during stationary dwell accumulations.

🧪 Verification & Testing Results

All tests run locally inside an isolated virtual environment are passing successfully:

$ pytest tests/test_tracker.py
============================= test session starts =============================
plugins: pytest-cov
collected 3 items

tests/test_tracker.py ...                                               [100%]

============================== 3 passed in 0.12s ==============================

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Trajectory points now include an interpolation flag and optional size fields; interpolation behavior is configurable.

* **Bug Fixes**
  * Short gaps between detections are filled with per-frame interpolated positions (and sizes when available) for smoother, more complete trajectories.

* **Tests**
  * Added unit tests covering interpolation for typical gaps, zero-gap, and no-movement cases.

* **Chores**
  * Deferred a heavy numeric import to reduce import-time overhead.

<!-- review_stack_entry_start -->

[![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Devnil434/Eagle/pull/82?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR implements trajectory interpolation for missed detections: a new _interpolate_trajectory generates linear per-frame points (optionally interpolating w/h) and Tracker.update merges them into stored trajectories when gaps are short. The TrajectoryPoint schema gains interpolated and optional w/h. Three unit tests cover movement, no-gap, and no-movement cases.

sequenceDiagram
  participant Detector
  participant Tracker.update
  participant _interpolate_trajectory
  participant TrackStore
  Detector->>Tracker.update: detection (frame_id, bbox/center)
  Tracker.update->>TrackStore: fetch previous track (last_seen_frame, last_pos)
  alt gap_frames > 0 and <= max_interpolation_gap
    Tracker.update->>_interpolate_trajectory: last_pos, new_pos, gap_frames, start_frame_id
    _interpolate_trajectory->>Tracker.update: interpolated points (frame_id,x,y[,w,h],interpolated=True)
    Tracker.update->>TrackStore: merge interpolated points + current point, truncate to MAX_TRAJECTORY_LEN
  else
    Tracker.update->>TrackStore: append current point only
  end
Loading

Changes

Trajectory interpolation for missed detections

Layer / File(s) Summary
TrajectoryPoint schema update
libs/schemas/tracking.py
Adds interpolated: bool = False and optional w: Optional[float] = None, h: Optional[float] = None to TrajectoryPoint and imports Optional.
Interpolation helper and Tracker.update integration
services/tracking/tracker.py
Adds _interpolate_trajectory(last_pos, new_pos, gap_frames, start_frame_id) and updates Tracker.__init__ (new max_interpolation_gap) and Tracker.update to compute gap_frames, call the helper when appropriate, merge interpolated points into the stored trajectory, and truncate to MAX_TRAJECTORY_LEN.
Unit tests for interpolation
tests/test_tracker.py
Imports _interpolate_trajectory and adds test_interpolate_trajectory_success, test_interpolate_trajectory_no_gap, and test_interpolate_trajectory_no_movement.
MemoryService annotation cleanup
services/memory/memory.py
Removes module-level numpy import and changes embedding parameter annotations to string forward-references ("numpy.ndarray") for lifecycle methods; runtime behavior unchanged.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 I hop between frames, stitch gaps with cheer,
Steps of x and y, each missing frame appears,
Width and height join when both ends provide,
Trajectories whole again — smooth hops, satisfied! 🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes out-of-scope changes to services/memory/memory.py (numpy import conversion to string annotations) not required by Issue #68 and unrelated to frame interpolation. Remove changes to services/memory/memory.py or document its necessity; focus on tracker.py, tracking.py schema, and tests/test_tracker.py as specified in Issue #68.
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: implementing linear frame interpolation logic and unit tests, which matches the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from Issue #68: the _interpolate_trajectory helper, integration into Tracker.update with gap detection, interpolated point marking, dwell-time accumulation support, configurable max_interpolation_gap parameter, and comprehensive unit tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_tracker.py (1)

491-515: ⚡ Quick win

Strengthen interpolation test assertions for w/h and full step sequence.

test_interpolate_trajectory_success currently checks only the first interpolated (x, y) point. Add assertions for w, h, and at least the last interpolated point to lock down the full linear progression contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_tracker.py` around lines 491 - 515, Update
test_interpolate_trajectory_success to assert the full linear progression:
verify that each interpolated dict in the returned list has interpolated==True
and correct sequential frame_id starting at start_frame, assert both "w" and "h"
values for the first and last interpolated entries (matching expected linear
interpolation between last_pos and new_pos), and add an assertion for the last
interpolated point's "x" and "y" to confirm the final step (e.g.,
result[-1]["x"], result[-1]["y"], result[-1]["w"], result[-1]["h"] match the
expected values). Use the existing _interpolate_trajectory inputs and compute
expected per-step deltas to validate the entire sequence.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@services/tracking/tracker.py`:
- Around line 366-396: Tracker.update is never calling the new helper
_interpolate_trajectory so missed-frame gaps are not filled; modify
Tracker.update to detect a gap between the last stored point for a track and the
incoming new_pos (compute gap_frames as new_pos['frame_id'] -
last_point['frame_id'] - 1), call _interpolate_trajectory(last_point, new_pos,
gap_frames, last_point['frame_id'] + 1) when gap_frames > 0, extend the track's
history with the returned interpolated points before appending the current
new_pos (preserving w/h if present), and ensure the same interpolated
flag/rounding behavior is used to keep consistency with _interpolate_trajectory.

---

Nitpick comments:
In `@tests/test_tracker.py`:
- Around line 491-515: Update test_interpolate_trajectory_success to assert the
full linear progression: verify that each interpolated dict in the returned list
has interpolated==True and correct sequential frame_id starting at start_frame,
assert both "w" and "h" values for the first and last interpolated entries
(matching expected linear interpolation between last_pos and new_pos), and add
an assertion for the last interpolated point's "x" and "y" to confirm the final
step (e.g., result[-1]["x"], result[-1]["y"], result[-1]["w"], result[-1]["h"]
match the expected values). Use the existing _interpolate_trajectory inputs and
compute expected per-step deltas to validate the entire sequence.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 204a55a7-3af6-4e8b-8ac2-bc48b68b2d3a

📥 Commits

Reviewing files that changed from the base of the PR and between 4616ca6 and ac0c4e4.

📒 Files selected for processing (2)
  • services/tracking/tracker.py
  • tests/test_tracker.py

Comment thread services/tracking/tracker.py Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@services/tracking/tracker.py`:
- Around line 194-195: Protect the access to prev.trajectory[-1] to avoid
IndexError by checking if prev.trajectory is truthy/non-empty before indexing;
if empty, set last_pos to the current center (use {"x": cx, "y": cy}) or skip
interpolation logic that uses last_pos. Update the block where last_pos and
new_pos are created (references: prev, prev.trajectory, last_pos, new_pos, cx,
cy) to perform this guard and ensure downstream interpolation code can handle
the fallback path.
- Line 190: The interpolation gap limit should be an explicit Tracker attribute
rather than reading from an uninitialized self.config; add a parameter/attribute
named max_interpolation_gap (default 10) to Tracker's initializer (e.g.,
__init__) and replace uses of self.config.get("max_interpolation_gap", 10) with
self.max_interpolation_gap (or self._max_interpolation_gap if you prefer private
naming) so interpolation logic in methods like the one setting max_gap refers
directly to the Tracker attribute and is discoverable/configurable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 804a9e1a-2129-4d63-93cc-a8e8c5e6e422

📥 Commits

Reviewing files that changed from the base of the PR and between ac0c4e4 and b946a4a.

📒 Files selected for processing (2)
  • services/tracking/tracker.py
  • tests/test_tracker.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_tracker.py

Comment thread services/tracking/tracker.py Outdated
Comment thread services/tracking/tracker.py Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
services/tracking/tracker.py (1)

64-93: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

max_interpolation_gap attribute is missing from __init__.

Line 188 references self.max_interpolation_gap, but this attribute is never initialized in __init__. This will raise AttributeError at runtime when the interpolation logic executes.

🐛 Proposed fix
     def __init__(
         self,
         fps: float = FPS_DEFAULT,
         max_age: int = 30,  # frames before a lost track is marked DEAD
         n_init: int = 3,  # frames before a track is CONFIRMED
         max_cosine_distance: float = 0.4,
         camera_id: str = "cam_01",
         event_logger: TrackEventLogger | None = None,
         reid_similarity_threshold: float = 0.85,
+        max_interpolation_gap: int = 10,
     ) -> None:
         self.fps = fps
         self.camera_id = camera_id
         self.max_age = max_age  # NEW
         self.REID_SIMILARITY_THRESHOLD = reid_similarity_threshold
+        self.max_interpolation_gap = max_interpolation_gap
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/tracking/tracker.py` around lines 64 - 93, The constructor __init__
is missing initialization for self.max_interpolation_gap which is referenced
later (causing AttributeError); add a new parameter (e.g.,
max_interpolation_gap: int = <sensible default>) to __init__'s signature and
assign it (self.max_interpolation_gap = max_interpolation_gap) alongside other
instance attributes so the interpolation logic can safely read it; update any
callers if needed to pass the value.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@services/tracking/tracker.py`:
- Around line 209-218: The instantiation of TrajectoryPoint in tracker.py passes
interpolated and optional w/h which are not defined on the TrajectoryPoint
pydantic model, causing TypeError; either update the TrajectoryPoint schema in
libs/schemas/tracking.py to include interpolated: bool (default False) and
optional w: Optional[float] and h: Optional[float] (or appropriate numeric
types) so the constructor accepts these keys, or remove those extra kwargs from
the list comprehension in tracker.py (the TrajectoryPoint(...) call) so only x,
y, and frame_id are passed; pick the approach consistent with downstream code
(if interpolation metadata is needed, add the fields to TrajectoryPoint and make
them optional with sensible defaults).

---

Duplicate comments:
In `@services/tracking/tracker.py`:
- Around line 64-93: The constructor __init__ is missing initialization for
self.max_interpolation_gap which is referenced later (causing AttributeError);
add a new parameter (e.g., max_interpolation_gap: int = <sensible default>) to
__init__'s signature and assign it (self.max_interpolation_gap =
max_interpolation_gap) alongside other instance attributes so the interpolation
logic can safely read it; update any callers if needed to pass the value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e08814c2-c0a8-441c-8384-2a7e209aed30

📥 Commits

Reviewing files that changed from the base of the PR and between b946a4a and 6f5bff1.

📒 Files selected for processing (3)
  • services/memory/memory.py
  • services/tracking/tracker.py
  • tests/test_tracker.py
✅ Files skipped from review due to trivial changes (1)
  • services/memory/memory.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_tracker.py

Comment thread services/tracking/tracker.py Outdated
@saoneenandi
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
services/tracking/tracker.py (1)

190-199: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Include occluded frames in dwell-time accumulation.

dwell_frames only increments by 1, so a track that disappears for 3 frames and then reappears still advances dwell by a single frame. That under-reports occupancy instead of preserving continuity across occlusions.

Suggested fix
             prev = self._active_tracks.get(tid)
-            dwell_frames = (prev.dwell_time_frames + 1) if prev else 1
+            gap_frames = max(0, self._frame_id - prev.last_seen_frame - 1) if prev else 0
+            dwell_frames = (prev.dwell_time_frames + gap_frames + 1) if prev else 1
             dwell_secs = dwell_frames / self.fps

             # ── Trajectory ────────────────────────────────────────────────
             prev_traj = prev.trajectory if prev else []
-            gap_frames = 0
-
-            if prev is not None:
-                gap_frames = max(0, self._frame_id - prev.last_seen_frame - 1)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/tracking/tracker.py` around lines 190 - 199, The dwell-time calc
currently only adds 1 on reappearance and ignores occluded frames; update the
logic so that when prev exists you compute gap_frames = max(0, self._frame_id -
prev.last_seen_frame - 1) and add that gap to dwell_frames (i.e., dwell_frames =
prev.dwell_time_frames + 1 + gap_frames) so occluded frames are counted toward
occupancy; adjust any subsequent uses that assume dwell_frames to use this new
value (references: variables prev, dwell_frames, gap_frames,
prev.last_seen_frame, prev.dwell_time_frames, self._frame_id, self.fps).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@services/tracking/tracker.py`:
- Around line 417-425: The _interpolate_trajectory function is defined after the
module-level entry point so main() can call Tracker.update which references it,
causing a NameError; move the entire _interpolate_trajectory function definition
so it appears before the if __name__ == "__main__": guard (i.e., above the
main() call) so that _interpolate_trajectory is defined when Tracker.update
runs, or alternatively hoist its definition near other helper functions used by
Tracker.update.

---

Outside diff comments:
In `@services/tracking/tracker.py`:
- Around line 190-199: The dwell-time calc currently only adds 1 on reappearance
and ignores occluded frames; update the logic so that when prev exists you
compute gap_frames = max(0, self._frame_id - prev.last_seen_frame - 1) and add
that gap to dwell_frames (i.e., dwell_frames = prev.dwell_time_frames + 1 +
gap_frames) so occluded frames are counted toward occupancy; adjust any
subsequent uses that assume dwell_frames to use this new value (references:
variables prev, dwell_frames, gap_frames, prev.last_seen_frame,
prev.dwell_time_frames, self._frame_id, self.fps).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c753bcf9-215b-4454-bc7e-e1f9d6c688c7

📥 Commits

Reviewing files that changed from the base of the PR and between 6f5bff1 and c7d2307.

📒 Files selected for processing (2)
  • libs/schemas/tracking.py
  • services/tracking/tracker.py

Comment thread services/tracking/tracker.py Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
services/tracking/tracker.py (2)

424-454: 💤 Low value

Interpolation logic is correct; consider moving function definition earlier in the file.

The linear interpolation math is sound and correctly generates gap_frames intermediate points with proper frame_id sequencing. However, defining _interpolate_trajectory after main() (line 369) doesn't follow typical Python conventions. Consider moving this helper function to appear before the Tracker class or immediately after it, where helper functions are more discoverable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/tracking/tracker.py` around lines 424 - 454, The helper function
_interpolate_trajectory is defined after main() which breaks common readability
conventions; move its definition to appear before the Tracker class or
immediately after the Tracker class (but before main()) so helper functions are
discoverable; ensure any references to _interpolate_trajectory (e.g., from
Tracker methods) still resolve and update any nearby docstrings/comments if
needed, and run tests to confirm no import/forward-reference issues arise.

211-214: 💤 Low value

Consider logging a warning if prev.trajectory is unexpectedly empty.

The fallback to current center coordinates will interpolate from the current position to itself over the gap, which produces unintuitive results. Since this edge case shouldn't occur in normal operation (a track with gap_frames > 0 should always have a non-empty trajectory), consider logging a warning or skipping interpolation entirely when this condition is detected.

Alternative approach
 if prev is not None and 0 < gap_frames <= max_gap:
-    if prev.trajectory:
+    if prev.trajectory:
         last_pos = {"x": prev.trajectory[-1].x, "y": prev.trajectory[-1].y}
     else:
-        last_pos = {"x": cx, "y": cy}
+        logger.warning(f"Track #{tid} has gap but empty trajectory; skipping interpolation")
+        # Skip interpolation by not setting last_pos
+        prev.trajectory = []  # Ensure we skip the interpolation block
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/tracking/tracker.py` around lines 211 - 214, Detect when
prev.trajectory is empty before falling back to last_pos and either log a
warning or skip interpolation: in the block that currently sets last_pos from
prev.trajectory or falls back to {"x": cx, "y": cy}, add a conditional that if
prev.trajectory is empty (len(prev.trajectory) == 0) emits a warning via the
module/logger used in tracker.py including identifying context (e.g., track id
or frame index and gap_frames) and then either set a flag to skip interpolation
for this gap or continue without interpolating, rather than silently using the
current center; keep references to prev.trajectory, last_pos, cx, cy and
gap_frames so the change is localized and easy to find.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@services/tracking/tracker.py`:
- Around line 424-454: The helper function _interpolate_trajectory is defined
after main() which breaks common readability conventions; move its definition to
appear before the Tracker class or immediately after the Tracker class (but
before main()) so helper functions are discoverable; ensure any references to
_interpolate_trajectory (e.g., from Tracker methods) still resolve and update
any nearby docstrings/comments if needed, and run tests to confirm no
import/forward-reference issues arise.
- Around line 211-214: Detect when prev.trajectory is empty before falling back
to last_pos and either log a warning or skip interpolation: in the block that
currently sets last_pos from prev.trajectory or falls back to {"x": cx, "y":
cy}, add a conditional that if prev.trajectory is empty (len(prev.trajectory) ==
0) emits a warning via the module/logger used in tracker.py including
identifying context (e.g., track id or frame index and gap_frames) and then
either set a flag to skip interpolation for this gap or continue without
interpolating, rather than silently using the current center; keep references to
prev.trajectory, last_pos, cx, cy and gap_frames so the change is localized and
easy to find.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df50f261-d981-48be-94b9-368daab4c456

📥 Commits

Reviewing files that changed from the base of the PR and between c7d2307 and 166c5bf.

📒 Files selected for processing (1)
  • services/tracking/tracker.py

@Devnil434 Devnil434 merged commit df73452 into Devnil434:main May 20, 2026
1 of 2 checks passed
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.

[Issue]— Implement frame interpolation for missed detections

2 participants