Apollo 10.0
自动驾驶开放平台
apollo::perception::radar4d::util 命名空间参考

函数

void FromStdToVector (const std::vector< float > &src_prob, Vectord *dst_prob)
 From std to vector
 
void FromEigenToVector (const Vectord &src_prob, std::vector< float > *dst_prob)
 Transfrom Eigen to vector
 
void ToLog (Vectord *prob)
 Compute log of Vectord
 
void ToExp (Vectord *prob)
 Compute exponential of Vectord
 
void ToExpStable (Vectord *prob)
 Compute stable exponential of Vectord
 
void Normalize (Vectord *prob)
 Compute normalize of Vectord
 
void NormalizeRow (Matrixd *prob)
 Compute normalize row of Matrixd
 
bool LoadSingleMatrix (std::ifstream &fin, Matrixd *matrix)
 Load single matrix
 
bool LoadSingleMatrixFile (const std::string &filename, Matrixd *matrix)
 Load single matrix from file
 
bool LoadMultipleMatricesFile (const std::string &filename, EigenMap< std::string, Matrixd > *matrices)
 
bool LoadMultipleMatricesFile (const std::string &filename, apollo::common::EigenMap< std::string, Matrixd > *matrices)
 Load multiple matrices from file
 

函数说明

◆ FromEigenToVector()

void apollo::perception::radar4d::util::FromEigenToVector ( const Vectord src_prob,
std::vector< float > *  dst_prob 
)

Transfrom Eigen to vector

参数
src_prob
dst_prob

在文件 util.cc37 行定义.

37 {
38 dst_prob->assign(static_cast<int>(ObjectType::MAX_OBJECT_TYPE), 0);
39 dst_prob->at(0) = static_cast<float>(src_prob(0));
40 for (size_t i = 3; i < static_cast<size_t>(ObjectType::MAX_OBJECT_TYPE);
41 ++i) {
42 dst_prob->at(i) = static_cast<float>(src_prob(i - 2));
43 }
44}

◆ FromStdToVector()

void apollo::perception::radar4d::util::FromStdToVector ( const std::vector< float > &  src_prob,
Vectord dst_prob 
)

From std to vector

参数
src_prob
dst_prob

在文件 util.cc29 行定义.

29 {
30 (*dst_prob)(0) = src_prob[0];
31 for (size_t i = 3; i < static_cast<size_t>(ObjectType::MAX_OBJECT_TYPE);
32 ++i) {
33 (*dst_prob)(i - 2) = static_cast<double>(src_prob[i]);
34 }
35}

◆ LoadMultipleMatricesFile() [1/2]

bool apollo::perception::radar4d::util::LoadMultipleMatricesFile ( const std::string &  filename,
apollo::common::EigenMap< std::string, Matrixd > *  matrices 
)

Load multiple matrices from file

参数
filenamefile to load matrices
matrices
返回
true
false

◆ LoadMultipleMatricesFile() [2/2]

bool apollo::perception::radar4d::util::LoadMultipleMatricesFile ( const std::string &  filename,
EigenMap< std::string, Matrixd > *  matrices 
)

在文件 util.cc108 行定义.

109 {
110 if (matrices == nullptr) {
111 return false;
112 }
113 std::ifstream fin(filename);
114 if (!fin.is_open()) {
115 AERROR << "Fail to open file: " << filename;
116 return false;
117 }
118 matrices->clear();
119 size_t num = 0;
120 fin >> num;
121 if (num > 100) {
122 fin.close();
123 return false;
124 }
125 for (size_t i = 0; i < num; ++i) {
126 std::string name;
127 fin >> name;
128 Matrixd matrix;
129 LoadSingleMatrix(fin, &matrix);
130 matrices->emplace(name, matrix);
131 }
132 fin.close();
133 return true;
134}
#define AERROR
Definition log.h:44

◆ LoadSingleMatrix()

bool apollo::perception::radar4d::util::LoadSingleMatrix ( std::ifstream &  fin,
Matrixd matrix 
)

Load single matrix

参数
fin
matrix
返回
true
false

在文件 util.cc85 行定义.

85 {
86 for (size_t row = 0; row < VALID_OBJECT_TYPE; ++row) {
87 for (size_t col = 0; col < VALID_OBJECT_TYPE; ++col) {
88 fin >> (*matrix)(row, col);
89 }
90 }
91 return true;
92}

◆ LoadSingleMatrixFile()

bool apollo::perception::radar4d::util::LoadSingleMatrixFile ( const std::string &  filename,
Matrixd matrix 
)

Load single matrix from file

参数
filenamefile to load matrix
matrix
返回
true
false

在文件 util.cc94 行定义.

94 {
95 if (matrix == nullptr) {
96 return false;
97 }
98 std::ifstream fin(filename);
99 if (!fin.is_open()) {
100 AERROR << "Fail to open file: " << filename;
101 return false;
102 }
103 LoadSingleMatrix(fin, matrix);
104 fin.close();
105 return true;
106}

◆ Normalize()

void apollo::perception::radar4d::util::Normalize ( Vectord prob)

Compute normalize of Vectord

参数
prob

在文件 util.cc65 行定义.

65 {
66 double sum = prob->sum();
67 sum = sum < 1e-9 ? 1e-9 : sum;
68 *prob /= sum;
69}

◆ NormalizeRow()

void apollo::perception::radar4d::util::NormalizeRow ( Matrixd prob)

Compute normalize row of Matrixd

参数
prob

在文件 util.cc71 行定义.

71 {
72 double sum = 0.0;
73 for (size_t row = 0; row < VALID_OBJECT_TYPE; ++row) {
74 sum = 0.0;
75 for (size_t col = 0; col < VALID_OBJECT_TYPE; ++col) {
76 sum += (*prob)(row, col);
77 }
78 sum = sum < 1e-9 ? 1e-9 : sum;
79 for (size_t col = 0; col < VALID_OBJECT_TYPE; ++col) {
80 (*prob)(row, col) /= sum;
81 }
82 }
83}

◆ ToExp()

void apollo::perception::radar4d::util::ToExp ( Vectord prob)

Compute exponential of Vectord

参数
prob

在文件 util.cc52 行定义.

52 {
53 for (size_t i = 0; i < VALID_OBJECT_TYPE; ++i) {
54 (*prob)(i) = exp((*prob)(i));
55 }
56}

◆ ToExpStable()

void apollo::perception::radar4d::util::ToExpStable ( Vectord prob)

Compute stable exponential of Vectord

参数
prob

在文件 util.cc58 行定义.

58 {
59 double min_value = prob->minCoeff();
60 for (size_t i = 0; i < VALID_OBJECT_TYPE; ++i) {
61 (*prob)(i) = exp((*prob)(i)-min_value);
62 }
63}

◆ ToLog()

void apollo::perception::radar4d::util::ToLog ( Vectord prob)

Compute log of Vectord

参数
prob

在文件 util.cc46 行定义.

46 {
47 for (size_t i = 0; i < VALID_OBJECT_TYPE; ++i) {
48 (*prob)(i) = log((*prob)(i));
49 }
50}