70 const SemanticTable &cur, std::vector<base::TrafficLightPtr> *lights,
71 std::vector<SemanticTable>::iterator *history) {
74 if ((*history)->hystertic_window.hysteretic_color == cur.
color) {
75 (*history)->hystertic_window.hysteretic_count++;
77 (*history)->hystertic_window.hysteretic_color = cur.
color;
78 (*history)->hystertic_window.hysteretic_count = 1;
81 <<
" count " << (*history)->hystertic_window.hysteretic_count
82 <<
" threshold " << hysteretic_threshold_;
84 if ((*history)->hystertic_window.hysteretic_count > hysteretic_threshold_) {
85 (*history)->color = cur.
color;
86 (*history)->hystertic_window.hysteretic_count = 0;
92 (*history)->color = cur.
color;
97 SemanticTable semantic_table, std::vector<base::TrafficLightPtr> *lights) {
99 std::vector<base::TrafficLightPtr> &lights_ref = *lights;
102 for (
size_t i = 0; i < semantic_table.
light_ids.size(); ++i) {
103 int index = semantic_table.
light_ids.at(i);
105 auto color = light->status.color;
106 vote.at(
static_cast<int>(color))++;
122 auto biggest = std::max_element(std::begin(vote), std::end(vote));
124 int max_color_num = *biggest;
125 max_color =
base::TLColor(std::distance(std::begin(vote), biggest));
129 auto second_biggest = std::max_element(std::begin(vote), std::end(vote));
133 if (max_color_num == *second_biggest) {
153 std::vector<base::TrafficLightPtr> *lights) {
155 <<
", lights number:" << semantic_table.
light_ids.size();
157 std::vector<base::TrafficLightPtr> &lights_ref = *lights;
160 semantic_table.
color = cur_color;
162 ADEBUG <<
"revise same semantic lights";
165 std::vector<SemanticTable>::iterator iter =
166 std::find_if(std::begin(history_semantic_), std::end(history_semantic_),
167 boost::bind(
compare, _1, semantic_table));
169 if (iter != history_semantic_.end()) {
170 pre_color = iter->color;
171 if (time_stamp - iter->time_stamp < revise_time_s_) {
172 ADEBUG <<
"revise by time series";
177 iter->time_stamp = time_stamp;
178 iter->hystertic_window.hysteretic_count = 0;
187 if (time_stamp - iter->last_bright_time_stamp > blink_threshold_s_ &&
188 iter->last_dark_time_stamp > iter->last_bright_time_stamp) {
191 iter->last_bright_time_stamp = time_stamp;
195 iter->last_dark_time_stamp = time_stamp;
196 iter->hystertic_window.hysteretic_count = 0;
199 iter->time_stamp = time_stamp;
211 iter->time_stamp = time_stamp;
212 iter->color = cur_color;
216 if (pre_color != iter->color ||
217 fabs(iter->last_dark_time_stamp - iter->last_bright_time_stamp) >
218 non_blink_threshold_s_) {
222 for (
auto index : semantic_table.
light_ids) {
223 lights_ref[index]->status.blink =
227 <<
s_color_strs[iter->color] <<
" blink " << iter->blink <<
" cur "
229 ADEBUG <<
"cur ts " << time_stamp;
230 ADEBUG <<
"bri ts " << iter->last_bright_time_stamp;
231 ADEBUG <<
"dar ts " << iter->last_dark_time_stamp;
235 history_semantic_.push_back(semantic_table);
241 std::vector<base::TrafficLightPtr> &lights_ref = frame->
traffic_lights;
242 std::vector<SemanticTable> semantic_table;
243 ADEBUG <<
"start revise ";
245 if (lights_ref.empty()) {
246 history_semantic_.clear();
247 ADEBUG <<
"no lights to revise, return";
251 ADEBUG <<
"lights_ref size is : " << lights_ref.size();
252 for (
size_t i = 0; i < lights_ref.size(); i++) {
254 int cur_semantic = light->semantic;
255 ADEBUG <<
"light " << light->id <<
" semantic " << cur_semantic;
258 std::stringstream ss;
260 if (cur_semantic > 0) {
261 ss <<
"Semantic_" << cur_semantic;
263 ss <<
"No_semantic_light_" << light->id;
267 tmp.
light_ids.push_back(
static_cast<int>(i));
268 tmp.
color = light->status.color;
272 std::find_if(std::begin(semantic_table), std::end(semantic_table),
273 boost::bind(
compare, _1, tmp));
275 if (iter != semantic_table.end()) {
276 iter->light_ids.push_back(
static_cast<int>(i));
278 semantic_table.push_back(tmp);
282 ADEBUG <<
"semantic_table size is : " << semantic_table.size();
283 for (
size_t i = 0; i < semantic_table.size(); ++i) {
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,...