Apollo 10.0
自动驾驶开放平台
apollo::perception::camera::GroundPlaneTracker类 参考

#include <camera_ground_plane.h>

apollo::perception::camera::GroundPlaneTracker 的协作图:

Public 成员函数

 GroundPlaneTracker (int track_length)
 
 ~GroundPlaneTracker ()
 
void Push (const std::vector< float > &ph, const float &inlier_ratio)
 
void GetGround (float *pitch, float *cam_height)
 
void Restart ()
 
int GetCurTrackLength ()
 

详细描述

在文件 camera_ground_plane.h52 行定义.

构造及析构函数说明

◆ GroundPlaneTracker()

apollo::perception::camera::GroundPlaneTracker::GroundPlaneTracker ( int  track_length)
explicit

在文件 camera_ground_plane.cc112 行定义.

112 {
113 if (track_length <= 0) {
114 AERROR << "track_length, " << track_length << ", should be positive";
115 }
116 pitch_height_inlier_tracks_.resize(track_length * 3);
117 const_weight_temporal_.resize(track_length, 0.0f);
118
119 weight_.resize(track_length, 0.0f);
120 for (int i = track_length - 1; i >= 0; --i) {
121 const_weight_temporal_.at(i) =
122 algorithm::IPow(algorithm::ISqrt(2.0f), track_length - 1 - i);
123 }
124
125 // normalize
126 float accm_sum = algorithm::ISum(const_weight_temporal_.data(), track_length);
127 algorithm::IScale(const_weight_temporal_.data(), track_length,
128 algorithm::IRec(accm_sum));
129
130 head_ = track_length;
131}
#define AERROR
Definition log.h:44
void IScale(T *x, int n, T sf)
Definition i_blas.h:1853
T ISum(const T *x, int n)
Definition i_blas.h:2344
float IPow(float a, float b)
Definition i_basic.h:142

◆ ~GroundPlaneTracker()

apollo::perception::camera::GroundPlaneTracker::~GroundPlaneTracker ( )
inline

在文件 camera_ground_plane.h55 行定义.

55{}

成员函数说明

◆ GetCurTrackLength()

int apollo::perception::camera::GroundPlaneTracker::GetCurTrackLength ( )
inline

在文件 camera_ground_plane.h63 行定义.

63 {
64 int length = static_cast<int>(pitch_height_inlier_tracks_.size());
65 CHECK_GE(length, 0);
66 return length;
67 }

◆ GetGround()

void apollo::perception::camera::GroundPlaneTracker::GetGround ( float *  pitch,
float *  cam_height 
)

在文件 camera_ground_plane.cc155 行定义.

155 {
156 CHECK_NOTNULL(pitch);
157 CHECK_NOTNULL(cam_height);
158 int i = 0;
159 int length = static_cast<int>(pitch_height_inlier_tracks_.size() / 3);
160 if (!length) {
161 *pitch = *cam_height = 0.0f;
162 return;
163 } else if (length == 1) {
164 *pitch = pitch_height_inlier_tracks_[0];
165 *cam_height = pitch_height_inlier_tracks_[1];
166 return;
167 }
168
169 float ph[2] = {0};
170 float w = 0.0f;
171 for (i = head_; i < length; i++) {
172 w = pitch_height_inlier_tracks_.at(i * 3 + 2);
173 weight_.at(i) = const_weight_temporal_.at(i) * w;
174 }
175
176 // normalize factor
177 float accm_wei = algorithm::ISum(weight_.data() + head_, (length - head_));
178
179 ph[0] = ph[1] = 0.0f;
180 for (i = head_; i < length; i++) {
181 w = weight_.at(i);
182 int i3 = i * 3;
183 ph[0] += pitch_height_inlier_tracks_.at(i3) * w;
184 ph[1] += pitch_height_inlier_tracks_.at(i3 + 1) * w;
185 }
186 ph[0] = algorithm::IDiv(ph[0], accm_wei);
187 ph[1] = algorithm::IDiv(ph[1], accm_wei);
188 *pitch = ph[0];
189 *cam_height = ph[1];
190}
float IDiv(float a, float b)
Definition i_basic.h:35

◆ Push()

void apollo::perception::camera::GroundPlaneTracker::Push ( const std::vector< float > &  ph,
const float &  inlier_ratio 
)

在文件 camera_ground_plane.cc133 行定义.

134 {
135 CHECK_EQ(ph.size(), 2U);
136 int i = 0;
137 int length = static_cast<int>(pitch_height_inlier_tracks_.size());
138 if (head_ == 0) {
139 if (length > 3) { // move backwards
140 for (i = length - 1; i >= 3; i--) { // 3: pitch, height, inlier-number
141 pitch_height_inlier_tracks_[i] = pitch_height_inlier_tracks_[i - 3];
142 }
143 }
144 } else { // _head >= zero
145 head_ -= 1;
146 }
147
148 // fill the head_ (fresh input)
149 int head3 = head_ * 3;
150 pitch_height_inlier_tracks_[head3] = ph[0];
151 pitch_height_inlier_tracks_[head3 + 1] = ph[1];
152 pitch_height_inlier_tracks_[head3 + 2] = inlier_ratio;
153}

◆ Restart()

void apollo::perception::camera::GroundPlaneTracker::Restart ( )

在文件 camera_ground_plane.cc192 行定义.

192 {
193 unsigned int track_length =
194 static_cast<unsigned int>(pitch_height_inlier_tracks_.size() / 3);
195 auto &data = pitch_height_inlier_tracks_;
196 unsigned int i = 0;
197 for (; i < track_length; ++i) {
198 int i3 = i * 3;
199 data.at(i3) = data.at(i3 + 1) = data.at(i3 + 2) = 0.0f;
200 weight_.at(i) = 0.0f;
201 }
202 head_ = track_length; // reset to init value
203}

该类的文档由以下文件生成: