27#include "modules/perception/lidar_tracking/tracker/type_fusion/proto/ccrf_type_filter_config.pb.h"
33using ObjectPtr = std::shared_ptr<apollo::perception::base::Object>;
37 std::string config_file =
"ccrf_type_fusion.conf";
45 std::string classifiers_property_file_path
54 pair.second.transposeInPlace();
55 AINFO <<
"Source: " << pair.first << std::endl << pair.second;
78 new_object->type =
static_cast<ObjectType
>(std::distance(
79 new_object->type_probs.begin(),
80 std::max_element(new_object->type_probs.begin(),
81 new_object->type_probs.end())));
87 const auto&
object = new_object->object_ptr;
88 if (log_prob ==
nullptr) {
91 const auto& vecs =
object->lidar_supplement.raw_probs;
92 const auto& names =
object->lidar_supplement.raw_classification_methods;
100 static const Vectord epsilon = Vectord::Ones() * 1e-6;
101 float conf =
object->confidence;
102 for (
size_t i = 0; i < vecs.size(); ++i) {
105 size_t type_count =
static_cast<size_t>(ObjectType::MAX_OBJECT_TYPE);
106 if (vec.size() != type_count) {
107 AERROR <<
"[TypeFilter] Encounter Unknown type_probs";
113 single_prob = single_prob + epsilon;
115 single_prob = iter->second * single_prob + epsilon;
121 single_prob = conf * single_prob + (1.0 - conf) * tmp;
125 *log_prob += single_prob;
136 std::string config_file =
"ccrf_type_fusion.conf";
144 std::string transition_property_file_path
168 const std::vector<TrackedObjectConstPtr>& tracked_objects,
175 const std::vector<TrackedObjectConstPtr>& tracked_objects,
179 for (
const auto& obj : tracked_objects) {
183 AERROR <<
"Failed to fuse one short probs in sequence.";
189 AERROR <<
"Failed to fuse one short probs for new object.";
201 for (std::size_t i = 1; i < length; ++i) {
204 double max_prob = -std::numeric_limits<double>::max();
210 if (prob > max_prob) {
224 &new_object->type_probs, &new_object->type);
226 std::stringstream sstr;
232 sstr <<
" After-Smooth[" << std::to_string(i) <<
"]: ";
233 for (
size_t j = 0; j < 4; j++) {
234 sstr << tmp(j) <<
", ";
243 std::vector<float>* dst, ObjectType* type) {
247 *type =
static_cast<ObjectType
>(std::distance(dst->begin(),
248 std::max_element(dst->begin(), dst->end())));
bool TypeFusion(const TypeFilterOption &option, const std::vector< TrackedObjectConstPtr > &tracked_objects, TrackedObjectPtr new_object) override
apollo::common::EigenVector< Vectord > fused_sequence_probs_
bool RecoverFromLogProbability(Vectord *prob, std::vector< float > *dst, perception::base::ObjectType *type)
Matrixd transition_matrix_
CCRFSingleShotTypeFusion one_shot_fuser_
EIGEN_MAKE_ALIGNED_OPERATOR_NEW bool Init(const TypeFilterInitOption &option) override
bool FuseWithConditionalProbabilityInference(const std::vector< TrackedObjectConstPtr > &tracked_objects, TrackedObjectPtr new_object)
apollo::common::EigenVector< Vectori > state_back_trace_
apollo::common::EigenVector< Vectord > fused_oneshot_probs_
bool TypeFusion(const TypeFilterOption &option, TrackedObjectPtr new_object) override
bool FuseOneShotTypeProbs(const TrackedObjectConstPtr &new_object, Vectord *log_prob)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW bool Init(const TypeFilterInitOption &option) override
Matrixd confidence_smooth_matrix_
apollo::common::EigenMap< std::string, Matrixd > smooth_matrices_
#define PERCEPTION_REGISTER_ONESHOTTYPEFUSION(name)
#define PERCEPTION_REGISTER_SEQUENCETYPEFUSION(name)
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,...
void ToExpStable(Vectord *prob)
Compute stable exponential of Vectord
void ToExp(Vectord *prob)
Compute exponential of Vectord
bool LoadSingleMatrixFile(const std::string &filename, Matrixd *matrix)
Load single matrix from file
void FromStdToVector(const std::vector< float > &src_prob, Vectord *dst_prob)
From std to vector
void NormalizeRow(Matrixd *prob)
Compute normalize row of Matrixd
void ToLog(Vectord *prob)
Compute log of Vectord
void Normalize(Vectord *prob)
Compute normalize of Vectord
bool LoadMultipleMatricesFile(const std::string &filename, EigenMap< std::string, Matrixd > *matrices)
void FromEigenToVector(const Vectord &src_prob, std::vector< float > *dst_prob)
Transfrom Eigen to vector
std::shared_ptr< const TrackedObject > TrackedObjectConstPtr
Eigen::Matrix< double, VALID_OBJECT_TYPE, 1 > Vectord
std::shared_ptr< apollo::perception::base::Object > ObjectPtr
std::shared_ptr< TrackedObject > TrackedObjectPtr
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
optional string classifiers_property_file_path
optional float transition_matrix_alpha
optional string transition_property_file_path