StateEstimation::MinCostFlowTracker
StateEstimation::MinCostFlowTracker
A tracker that uses a global min-cost flow optimization to solve data association. More…
#include <MinCostFlowTracker.hpp>
Public Functions
| Name | |
|---|---|
| MinCostFlowTracker(std::unique_ptr< IFilter > filter_prototype, std::unique_ptr< IFeatureExtractor< DataType > > feature_extractor, CostFunction cost_function, double cost_scale_factor =100.0, double cheap_assignment_threshold =5.0, TrackerContractPolicy policy =TrackerContractPolicy::Throw, int n_scan_depth =3, bool enable_n_scan =true, int max_gap_frames =3) Construct a new MinCostFlowTracker. |
|
| MinCostFlowTracker(std::unique_ptr< IFilter > filter_prototype, std::unique_ptr< IFeatureExtractor< DataType > > feature_extractor, CostFunction chain_cost_function, CostFunction transition_cost_function, double cost_scale_factor, double cheap_assignment_threshold, TrackerContractPolicy policy =TrackerContractPolicy::Throw, int n_scan_depth =3, bool enable_n_scan =true, int max_gap_frames =3) Construct with separate cost functions for greedy chaining and meta-node transitions. |
|
| MinCostFlowTracker(std::unique_ptr< IFilter > filter_prototype, std::unique_ptr< IFeatureExtractor< DataType > > feature_extractor, Eigen::MatrixXd const & measurement_matrix, Eigen::MatrixXd const & measurement_noise_covariance, double cost_scale_factor =100.0, double cheap_assignment_threshold =5.0, TrackerContractPolicy policy =TrackerContractPolicy::Throw, int n_scan_depth =3, bool enable_n_scan =true, int max_gap_frames =3) Convenience constructor using default Mahalanobis distance cost function. |
|
| void | setLookaheadCostFunction(CostFunction cost_fn) Set a dedicated cost function for N-scan lookahead scoring. |
| void | setTransitionCostFunction(CostFunction cost_fn) Override the transition cost used between meta-nodes in the MCF graph. |
| void | setLookaheadThreshold(double threshold) Set the acceptance threshold for N-scan lookahead costs. |
| void | setAmbiguityThreshold(double threshold) Set ambiguity threshold and optional margin to decide when to run N-scan. If the best cost < ambiguity_threshold and (second_best - best) >= ambiguity_margin, the chain is considered certain and N-scan is skipped. |
| void | setAmbiguityMargin(double margin) |
| template <typename Source > SmoothedResults |
process(Source && data_source, EntityGroupManager & group_manager, GroundTruthMap const & ground_truth, TimeFrameIndex start_frame, TimeFrameIndex end_frame, ProgressCallback progress, std::map< GroupId, GroupId > const * output_group_ids =[nullptr], std::unordered_set< EntityId > const * excluded_entities =[nullptr], std::unordered_set< EntityId > const * include_entities =[nullptr]) Process a range of frames using min-cost flow optimization. |
| void | enableDebugLogging(std::string const & file_path) |
| TrackerDiagnostics | getDiagnostics() const |
Detailed Description
template <typename DataType >
class StateEstimation::MinCostFlowTracker;A tracker that uses a global min-cost flow optimization to solve data association.
Template Parameters:
- DataType raw observation type (e.g., Line2D)
This tracker formulates the tracking problem as a graph problem, finding the globally optimal set of tracks over an entire interval between anchors. It is more robust to ambiguities and identity swaps than iterative, frame-by-frame methods.
Public Functions Documentation
function MinCostFlowTracker
inline MinCostFlowTracker(
std::unique_ptr< IFilter > filter_prototype,
std::unique_ptr< IFeatureExtractor< DataType > > feature_extractor,
CostFunction cost_function,
double cost_scale_factor =100.0,
double cheap_assignment_threshold =5.0,
TrackerContractPolicy policy =TrackerContractPolicy::Throw,
int n_scan_depth =3,
bool enable_n_scan =true,
int max_gap_frames =3
)Construct a new MinCostFlowTracker.
Parameters:
- filter_prototype Prototype filter (cloned for prediction and final smoothing). If nullptr, prediction is skipped in cost calculation (cost function must handle this) and no smoothing is performed. The filter’s uncertainty automatically scales with gap size through process noise accumulation.
- feature_extractor Feature extractor for DataType
- cost_function Function to compute cost between predicted state and observation
- cost_scale_factor Multiplier to convert floating-point costs to integers for the solver.
- cheap_assignment_threshold Threshold for greedy chaining
- policy Contract violation policy
- n_scan_depth Number of frames to look ahead when assignments are ambiguous (default 3)
- enable_n_scan Enable N-scan lookahead for ambiguous assignments (default true)
- max_gap_frames Maximum frames a chain can skip before terminating (default 3, set to -1 for unlimited)
function MinCostFlowTracker
inline MinCostFlowTracker(
std::unique_ptr< IFilter > filter_prototype,
std::unique_ptr< IFeatureExtractor< DataType > > feature_extractor,
CostFunction chain_cost_function,
CostFunction transition_cost_function,
double cost_scale_factor,
double cheap_assignment_threshold,
TrackerContractPolicy policy =TrackerContractPolicy::Throw,
int n_scan_depth =3,
bool enable_n_scan =true,
int max_gap_frames =3
)Construct with separate cost functions for greedy chaining and meta-node transitions.
Parameters:
- chain_cost_function Cost for frame-to-frame greedy chaining (typically 1-step)
- transition_cost_function Cost for meta-node transitions across k-step gaps
- n_scan_depth Number of frames to look ahead when assignments are ambiguous (default 3)
- enable_n_scan Enable N-scan lookahead for ambiguous assignments (default true)
function MinCostFlowTracker
inline MinCostFlowTracker(
std::unique_ptr< IFilter > filter_prototype,
std::unique_ptr< IFeatureExtractor< DataType > > feature_extractor,
Eigen::MatrixXd const & measurement_matrix,
Eigen::MatrixXd const & measurement_noise_covariance,
double cost_scale_factor =100.0,
double cheap_assignment_threshold =5.0,
TrackerContractPolicy policy =TrackerContractPolicy::Throw,
int n_scan_depth =3,
bool enable_n_scan =true,
int max_gap_frames =3
)Convenience constructor using default Mahalanobis distance cost function.
Parameters:
- filter_prototype Prototype filter (cloned for prediction and final smoothing). If nullptr, Mahalanobis distance cannot be computed properly (requires filter state covariance). The filter’s uncertainty automatically scales with gap size.
- feature_extractor Feature extractor for DataType
- measurement_matrix H matrix for Mahalanobis distance calculation
- measurement_noise_covariance R matrix for Mahalanobis distance calculation
- cost_scale_factor Multiplier to convert floating-point costs to integers for the solver.
- cheap_assignment_threshold Threshold for greedy chaining
- policy Contract violation policy
- n_scan_depth Number of frames to look ahead when assignments are ambiguous (default 3)
- enable_n_scan Enable N-scan lookahead for ambiguous assignments (default true)
function setLookaheadCostFunction
inline void setLookaheadCostFunction(
CostFunction cost_fn
)Set a dedicated cost function for N-scan lookahead scoring.
Precondition: cost_fn should be a valid callable; behavior is undefined if empty
Postcondition: Subsequent N-scan calls will use the provided function
This function is used exclusively inside the lookahead expansion and can differ from the greedy chaining or meta-node transition costs. It is useful to introduce dynamics-aware penalties (velocity/acceleration) only for ambiguity resolution while keeping cheaper costs elsewhere.
function setTransitionCostFunction
inline void setTransitionCostFunction(
CostFunction cost_fn
)Override the transition cost used between meta-nodes in the MCF graph.
function setLookaheadThreshold
inline void setLookaheadThreshold(
double threshold
)Set the acceptance threshold for N-scan lookahead costs.
Use a larger threshold for dynamics-aware costs whose scale exceeds the cheap chaining threshold. Set to infinity to disable pruning by threshold.
function setAmbiguityThreshold
inline void setAmbiguityThreshold(
double threshold
)Set ambiguity threshold and optional margin to decide when to run N-scan. If the best cost < ambiguity_threshold and (second_best - best) >= ambiguity_margin, the chain is considered certain and N-scan is skipped.
function setAmbiguityMargin
inline void setAmbiguityMargin(
double margin
)function process
template <typename Source >
inline SmoothedResults process(
Source && data_source,
EntityGroupManager & group_manager,
GroundTruthMap const & ground_truth,
TimeFrameIndex start_frame,
TimeFrameIndex end_frame,
ProgressCallback progress,
std::map< GroupId, GroupId > const * output_group_ids =nullptr,
std::unordered_set< EntityId > const * excluded_entities =nullptr,
std::unordered_set< EntityId > const * include_entities =nullptr
)Process a range of frames using min-cost flow optimization.
Parameters:
- data_source Zero-copy data source
- group_manager Group manager to record final assignments
- ground_truth Ground truth at specific frames (anchors)
- start_frame Inclusive start frame
- end_frame Inclusive end frame
- progress Optional progress callback
Return: Smoothed states per group across processed frames
function enableDebugLogging
inline void enableDebugLogging(
std::string const & file_path
)function getDiagnostics
inline TrackerDiagnostics getDiagnostics() constUpdated on 2026-11-13 at 20:25:41 +0000