21#include "modules/perception/radar4d_detection/lib/tracker/multi_radar_fusion/proto/mrf_config.pb.h"
31 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
36 0.f, 0.f, 0.f, 0.f, 0.f, 0.2f, 0.8f};
40 std::string config_file =
"mrf_track_object_distance.pb.txt";
50 for (
int i = 0; i < config.foreground_weights_size(); ++i) {
53 std::vector<float> weights(7, 0.f);
54 weights[0] = fgws.location_dist_weight();
55 weights[1] = fgws.direction_dist_weight();
56 weights[2] = fgws.bbox_size_dist_weight();
57 weights[3] = fgws.point_num_dist_weight();
58 weights[4] = fgws.histogram_dist_weight();
59 weights[5] = fgws.centroid_shift_dist_weight();
60 weights[6] = fgws.bbox_iou_dist_weight();
61 weights[7] = fgws.semantic_map_dist_weight();
64 for (
int i = 0; i < config.background_weights_size(); ++i) {
67 std::vector<float> weights(7, 0.f);
68 weights[0] = bgws.location_dist_weight();
69 weights[1] = bgws.direction_dist_weight();
70 weights[2] = bgws.bbox_size_dist_weight();
71 weights[3] = bgws.point_num_dist_weight();
72 weights[4] = bgws.histogram_dist_weight();
73 weights[5] = bgws.centroid_shift_dist_weight();
74 weights[6] = bgws.bbox_iou_dist_weight();
84 bool is_background =
object->is_background;
86 std::string key = latest_object->sensor_info.name +
object->sensor_info.name;
87 const std::vector<float>* weights =
nullptr;
93 weights = &iter->second;
100 weights = &iter->second;
103 if (weights ==
nullptr || weights->size() < 7) {
104 AERROR <<
"Invalid weights";
107 float distance = 0.f;
108 float delta = 1e-10f;
110 double current_time =
object->object_ptr->latest_tracked_time;
111 track->PredictState(current_time);
114 track->age_ ? current_time - track->latest_visible_time_ : 0;
115 if (weights->at(0) > delta) {
120 if (weights->at(1) > delta) {
125 if (weights->at(2) > delta) {
130 if (weights->at(3) > delta) {
135 if (weights->at(4) > delta) {
140 if (weights->at(5) > delta) {
142 track->predict_.state,
145 if (weights->at(6) > delta) {
146 distance += weights->at(6) *
std::map< std::string, std::vector< float > > foreground_weight_table_
static const std::vector< float > kForegroundDefaultWeight
bool Init(const MrfTrackObjectDistanceInitOptions &options=MrfTrackObjectDistanceInitOptions())
Init mrf track object distance
double background_object_match_threshold_
std::map< std::string, std::vector< float > > background_weight_table_
float ComputeDistance(const TrackedObjectConstPtr &object, const MrfTrackDataConstPtr &track) const
Compute object track distance
static const std::vector< float > kBackgroundDefaultWeight
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
float BboxSizeDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff)
Compute bbox size distance for given track & object
float PointNumDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff)
Compute point num distance for given track & object
std::shared_ptr< const TrackedObject > TrackedObjectConstPtr
float LocationDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff)
Compute location distance for given track & object
float CentroidShiftDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff)
Compute centroid shift distance for object and background match
float BboxIouDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff, double match_threshold)
Compute bbox iou distance for object and background match
float DirectionDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff)
Compute direction distance for given track & object
std::shared_ptr< const MrfTrackData > MrfTrackDataConstPtr
float HistogramDistance(const TrackedObjectConstPtr &last_object, const Eigen::VectorXf &track_predict, const TrackedObjectConstPtr &new_object, const double time_diff)
Compute histogram distance for given track & object
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
repeated MrfDistanceWeight background_weights
repeated MrfDistanceWeight foreground_weights
optional string sensor_name_pair