StateEstimation::MaskPointTracker
StateEstimation::MaskPointTracker
A discrete particle filter for tracking a single point through mask data. More…
#include <MaskParticleFilter.hpp>
Public Functions
| Name | |
|---|---|
| MaskPointTracker(size_t num_particles =1000, float transition_radius =5.0f, float random_walk_prob =0.01f, bool use_velocity_model =true, float velocity_noise_std =1.0f) Construct a new MaskPointTracker. |
|
| std::vector< Point2D< uint32_t > > | track(Point2D< uint32_t > const & start_point, Point2D< uint32_t > const & end_point, std::vector< Mask2D > const & masks, std::vector< float > const & time_deltas ={}) Track a point through a sequence of masks between two ground truth labels. |
Detailed Description
class StateEstimation::MaskPointTracker;A discrete particle filter for tracking a single point through mask data.
This filter maintains particles that are constrained to lie on mask pixels. It performs forward filtering and backward smoothing between ground truth labels.
IMPORTANT STATE MODEL LIMITATIONS:
This is a POSITION-ONLY particle filter with NO VELOCITY component in the state.
Each particle represents only a 2D position (x, y) on the mask. There is no tracking of velocity, momentum, or direction of motion. The state transition model is a MEMORYLESS random walk on mask pixels:
- With probability (1 - random_walk_prob):
- Sample uniformly from pixels within transition_radius of current position
- This creates local, short-range transitions
- With probability random_walk_prob:
- Sample uniformly from ALL mask pixels (with distance penalty)
- This allows exploration and recovery from tracking failures
CONSEQUENCES OF NO VELOCITY MODEL:
• Particles have no “momentum” or preferred direction of motion • Over long gaps between labels, particles spread out randomly across the mask • Backward smoothing selects based on proximity to next frame, not trajectory smoothness • This can cause JUMPS at label boundaries when the best particle isn’t actually following a smooth path • The filter cannot predict where the point is “heading” - it only knows where it was
WHEN JUMPS OCCUR:
Large jumps between frames happen when:
- Gap between ground truth labels is large (many frames)
- Mask topology allows particles to explore distant regions
- Random walk allows particles to “teleport” across the mask
- Backward smoothing picks a particle that’s close spatially but came from a different trajectory
POTENTIAL IMPROVEMENTS:
To reduce jumps, consider: • Add velocity to particle state: Particle { position, velocity } • Use velocity in transition: new_position = position + velocity + noise • Track trajectory smoothness during backward smoothing • Penalize sudden direction changes in the backward pass • Use a constant-velocity Kalman filter for comparison
However, velocity models increase state dimensionality and may not work well when motion is highly constrained by mask topology or when the point genuinely changes direction rapidly.
Public Functions Documentation
function MaskPointTracker
inline explicit MaskPointTracker(
size_t num_particles =1000,
float transition_radius =5.0f,
float random_walk_prob =0.01f,
bool use_velocity_model =true,
float velocity_noise_std =1.0f
)Construct a new MaskPointTracker.
Parameters:
- num_particles Number of particles to use
- transition_radius Maximum distance a particle can move in one time step (in pixels)
- random_walk_prob Probability of random walk vs staying on nearby mask pixels
- use_velocity_model If true, particles track velocity and use constant-velocity motion model
- velocity_noise_std Standard deviation of velocity process noise (pixels/frame)
Default parameters are tuned to prevent “walking” on elongated masks:
- Velocity model enabled by default for spatial consistency
- Smaller transition_radius (5.0) limits per-frame movement
- Lower random_walk_prob (0.01) reduces random exploration
function track
std::vector< Point2D< uint32_t > > track(
Point2D< uint32_t > const & start_point,
Point2D< uint32_t > const & end_point,
std::vector< Mask2D > const & masks,
std::vector< float > const & time_deltas ={}
)Track a point through a sequence of masks between two ground truth labels.
Parameters:
- start_point Ground truth starting point
- end_point Ground truth ending point
- masks Vector of masks for each time frame (in order)
- time_deltas Optional vector of time differences between frames (for velocity model) If empty, assumes dt=1.0 for all frames. Should have size masks.size()-1
Return: Vector of tracked points (one per mask frame)
Updated on 2026-11-13 at 20:25:41 +0000