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

#include <hough_transfer.h>

apollo::perception::algorithm::HoughTransfer 的协作图:

Public 成员函数

 HoughTransfer ()
 
 ~HoughTransfer ()=default
 
bool Init (int img_w, int img_h, float d_r, float d_theta)
 
bool ImageVote (const std::vector< int > &image, bool with_distribute)
 
void PointVote (int x, int y, bool with_distribute)
 
void PointVote (int pos, bool with_distribute)
 
bool GetLines (int min_pt_num, int r_neibor, int theta_neibor, bool with_distribute, std::vector< HoughLine > *lines) const
 
unsigned int MemoryConsume () const
 
void FreeCache ()
 
void ResetMaps (bool with_distribute)
 
std::string name () const
 
bool is_prepared () const
 
const std::vector< int > & get_vote_map () const
 
const std::vector< std::vector< int > > & get_distribute_map () const
 
float get_d_r () const
 
float get_d_theta () const
 
int get_img_w () const
 
int get_img_h () const
 
int get_r_size () const
 
int get_theta_size () const
 
void ClearWithShrink ()
 

详细描述

在文件 hough_transfer.h 第 37 行定义.

构造及析构函数说明

◆ HoughTransfer()

apollo::perception::algorithm::HoughTransfer::HoughTransfer ( )

在文件 hough_transfer.cc 第 22 行定义.

23 : prepared_(false),
24 d_r_(0.0),
25 d_theta_(0.0),
26 img_w_(0),
27 img_h_(0),
28 r_size_(0),
29 theta_size_(0),
30 vote_reserve_size_(10),
31 vote_map_(),
32 query_map_(),
33 distribute_map_() {}

◆ ~HoughTransfer()

apollo::perception::algorithm::HoughTransfer::~HoughTransfer ( )
default

成员函数说明

◆ ClearWithShrink()

void apollo::perception::algorithm::HoughTransfer::ClearWithShrink ( )

在文件 hough_transfer.cc 第 195 行定义.

195 {
196 vote_map_.clear();
197 vote_map_.shrink_to_fit();
198 query_map_.clear();
199 query_map_.shrink_to_fit();
200 distribute_map_.clear();
201 distribute_map_.shrink_to_fit();
202 prepared_ = false;
203}

◆ FreeCache()

void apollo::perception::algorithm::HoughTransfer::FreeCache ( )

在文件 hough_transfer.cc 第 180 行定义.

180 {
181 for (auto& distribute : distribute_map_) {
182 distribute.shrink_to_fit();
183 }
184}

◆ get_d_r()

float apollo::perception::algorithm::HoughTransfer::get_d_r ( ) const
inline

在文件 hough_transfer.h 第 92 行定义.

92{ return d_r_; }

◆ get_d_theta()

float apollo::perception::algorithm::HoughTransfer::get_d_theta ( ) const
inline

在文件 hough_transfer.h 第 93 行定义.

93{ return d_theta_; }

◆ get_distribute_map()

const std::vector< std::vector< int > > & apollo::perception::algorithm::HoughTransfer::get_distribute_map ( ) const
inline

在文件 hough_transfer.h 第 88 行定义.

88 {
89 return distribute_map_;
90 }

◆ get_img_h()

int apollo::perception::algorithm::HoughTransfer::get_img_h ( ) const
inline

在文件 hough_transfer.h 第 95 行定义.

95{ return img_h_; }

◆ get_img_w()

int apollo::perception::algorithm::HoughTransfer::get_img_w ( ) const
inline

在文件 hough_transfer.h 第 94 行定义.

94{ return img_w_; }

◆ get_r_size()

int apollo::perception::algorithm::HoughTransfer::get_r_size ( ) const
inline

在文件 hough_transfer.h 第 96 行定义.

96{ return r_size_; }

◆ get_theta_size()

int apollo::perception::algorithm::HoughTransfer::get_theta_size ( ) const
inline

在文件 hough_transfer.h 第 97 行定义.

97{ return theta_size_; }

◆ get_vote_map()

const std::vector< int > & apollo::perception::algorithm::HoughTransfer::get_vote_map ( ) const
inline

在文件 hough_transfer.h 第 87 行定义.

87{ return vote_map_; }

◆ GetLines()

bool apollo::perception::algorithm::HoughTransfer::GetLines ( int  min_pt_num,
int  r_neibor,
int  theta_neibor,
bool  with_distribute,
std::vector< HoughLine > *  lines 
) const

在文件 hough_transfer.cc 第 133 行定义.

135 {
136 if (!lines) {
137 return false;
138 }
139 int r_step = 2 * r_neibor + 1;
140 int theta_step = 2 * theta_neibor + 1;
141
142 // search one vote neighbor for max_vote position in the region
143 std::set<int> max_vote_lines;
144 GetMaxVotes(min_pt_num, r_neibor, theta_neibor, r_step, theta_step,
145 &max_vote_lines);
146
147 // from max vote pos to get line params
148 lines->resize(max_vote_lines.size());
149 int idx = 0;
150 for (auto i = max_vote_lines.begin(); i != max_vote_lines.end(); ++i) {
151 if (!VotePosToHoughLine(*i, with_distribute, &(*lines)[idx++])) {
152 return false;
153 }
154 }
155 return true;
156}

◆ ImageVote()

bool apollo::perception::algorithm::HoughTransfer::ImageVote ( const std::vector< int > &  image,
bool  with_distribute 
)

在文件 hough_transfer.cc 第 91 行定义.

92 {
93 if (image.size() != query_map_.size()) {
94 return false;
95 }
96 ResetMaps(with_distribute);
97 for (size_t i = 0; i < image.size(); ++i) {
98 if (image[i] > 0) {
99 int x = static_cast<int>(i) % img_w_;
100 int y = static_cast<int>(i) / img_w_;
101 PointVote(x, y, with_distribute);
102 }
103 }
104 return true;
105}
void PointVote(int x, int y, bool with_distribute)

◆ Init()

bool apollo::perception::algorithm::HoughTransfer::Init ( int  img_w,
int  img_h,
float  d_r,
float  d_theta 
)

在文件 hough_transfer.cc 第 40 行定义.

40 {
41 img_w_ = img_w;
42 img_h_ = img_h;
43 d_r_ = d_r;
44 d_theta_ = static_cast<float>(M_PI) * d_theta / 180.0f;
45 r_size_ = static_cast<int>(
46 2 * sqrtf(static_cast<float>(img_w_ * img_w_ + img_h_ * img_h_)) / d_r_);
47 theta_size_ = static_cast<int>(M_PI / d_theta_);
48
50 // init vote map
51 vote_map_.resize(r_size_ * theta_size_, 0);
52 // init query map
53 query_map_.resize(img_w_ * img_h_);
54 for (auto& query : query_map_) {
55 query.resize(theta_size_, 0);
56 }
57
58 for (int theta_idx = 0; theta_idx < theta_size_; ++theta_idx) {
59 float cur_theta = d_theta_ * static_cast<float>(theta_idx);
60 for (int img_pos = 0; img_pos < img_w_ * img_h_; ++img_pos) {
61 int w = img_pos % img_w_;
62 int h = img_pos / img_w_;
63 int r =
64 static_cast<int>((cos(cur_theta) * w + sin(cur_theta) * h) / d_r_) +
65 r_size_ / 2;
66 if (0 <= r && r < r_size_) {
67 query_map_[img_pos][theta_idx] = r * theta_size_ + theta_idx;
68 }
69 }
70 }
71 // init distribute map
72 distribute_map_.resize(r_size_ * theta_size_);
73 for (auto& distribute : distribute_map_) {
74 distribute.reserve(vote_reserve_size_);
75 }
76
77 if (CheckPrepared()) {
78 prepared_ = true;
79 } else {
81 prepared_ = false;
82 }
83 return prepared_;
84}
float cos(Angle16 a)
Definition angle.cc:42
float sin(Angle16 a)
Definition angle.cc:25

◆ is_prepared()

bool apollo::perception::algorithm::HoughTransfer::is_prepared ( ) const
inline

在文件 hough_transfer.h 第 85 行定义.

85{ return prepared_; }

◆ MemoryConsume()

unsigned int apollo::perception::algorithm::HoughTransfer::MemoryConsume ( ) const

在文件 hough_transfer.cc 第 158 行定义.

158 {
159 unsigned int size = 0;
160 if (is_prepared()) {
161 size +=
162 static_cast<unsigned int>(vote_map_.capacity() * sizeof(vote_map_[0]));
163 size += static_cast<unsigned int>(query_map_.capacity() *
164 sizeof(query_map_[0]));
165 size += static_cast<unsigned int>(theta_size_ * query_map_.size() *
166 sizeof(query_map_[0][0]));
167 size += static_cast<unsigned int>(distribute_map_.capacity() *
168 sizeof(distribute_map_[0]));
169 for (const auto& distribute : distribute_map_) {
170 size += static_cast<unsigned int>(distribute.capacity() *
171 sizeof(distribute[0]));
172 }
173 }
174 return size;
175}

◆ name()

std::string apollo::perception::algorithm::HoughTransfer::name ( ) const
inline

在文件 hough_transfer.h 第 83 行定义.

83{ return "HoughTransfer"; }

◆ PointVote() [1/2]

void apollo::perception::algorithm::HoughTransfer::PointVote ( int  pos,
bool  with_distribute 
)

在文件 hough_transfer.cc 第 117 行定义.

117 {
118 for (int theta_idx = 0; theta_idx < theta_size_; ++theta_idx) {
119 ++vote_map_[query_map_[pos][theta_idx]];
120 if (with_distribute) {
121 distribute_map_[query_map_[pos][theta_idx]].push_back(pos);
122 }
123 }
124}

◆ PointVote() [2/2]

void apollo::perception::algorithm::HoughTransfer::PointVote ( int  x,
int  y,
bool  with_distribute 
)

在文件 hough_transfer.cc 第 111 行定义.

111 {
112 const int pos = y * img_w_ + x;
113 PointVote(pos, with_distribute);
114}

◆ ResetMaps()

void apollo::perception::algorithm::HoughTransfer::ResetMaps ( bool  with_distribute)

在文件 hough_transfer.cc 第 186 行定义.

186 {
187 memset(vote_map_.data(), 0, vote_map_.size() * sizeof(vote_map_[0]));
188 if (with_distribute) {
189 for (auto& distribute : distribute_map_) {
190 distribute.clear();
191 }
192 }
193}

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