Skip to content

Add angle spline interpolation postprocessing pass#13

Merged
fwrise merged 1 commit into
RI-SE:mainfrom
BastianHavers:dev-angle-spline-interpolate
Apr 15, 2026
Merged

Add angle spline interpolation postprocessing pass#13
fwrise merged 1 commit into
RI-SE:mainfrom
BastianHavers:dev-angle-spline-interpolate

Conversation

@BastianHavers
Copy link
Copy Markdown
Contributor

Summary

This PR adds a new opt-in postprocessing pass AngleSplineInterpolationPass that derives bounding box heading angles by fitting a cubic spline to each vehicle's trajectory.

Motivation

Existing rotation adjustment relies on frame-to-frame movement vectors, which can be noisy. Fitting a spline to the entire trajectory provides a globally smooth estimate of heading direction.

Changes

New feature: --angle-spline-interpolation S

Invoke from the CLI with --housekeeping --angle-spline-interpolation <S> where S is the splprep smoothing factor (s=0 = exact interpolation, larger = smoother curve).

Algorithm

  1. Extract (x, y) bounding box centre coordinates per tracked object
  2. Remove consecutive duplicate positions (vehicle stopped) to avoid degenerate splines
  3. Fit a parametric cubic spline via scipy.interpolate.splprep
  4. Obtain tangent vectors via scipy.interpolate.splev(der=1)
  5. Set bbox angle to atan2(dy, dx) of the tangent
  6. Forward-fill angles to stationary frames

Objects with fewer than 4 unique positions are skipped gracefully.

Pipeline placement

Runs after RotationAdjustmentPass (step 8b) and before DuplicateRemovalPass, so IoU-based duplicate detection uses the corrected angles.

Provenance

The flag and smoothing value are recorded in build_arguments_string() and captured by the dataprov provenance chain.

Files changed

  • pyproject.toml — added scipy>=1.10.0 to markit dependency group
  • markit/markitlib/postprocessing/_passes/angle_spline_interpolation.py — new pass
  • markit/markitlib/postprocessing/_passes/__init__.py, passes.py, __init__.py — exports
  • markit/run_markit.py — CLI arg, pipeline wiring, provenance tracking
  • markit/markitlib/config.py — config attribute
  • markit/tests/test_angle_spline_interpolation.py — 16 unit tests

Tests

All 138 existing tests continue to pass. 16 new tests cover: straight-line, curved trajectory, stationary frame forward-fill, too-few-points skip, width/height normalisation, housekeeping tag, statistics, smoothing factor effect, multiple objects, and the deduplication helper.

@fwrise fwrise merged commit 50e60b6 into RI-SE:main Apr 15, 2026
3 checks passed
@BastianHavers BastianHavers deleted the dev-angle-spline-interpolate branch April 15, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants