Apollo  6.0
Open source self driving car software
semantic_decision.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 #pragma once
17 
18 #include <string>
19 #include <vector>
20 
22 #include "modules/perception/camera/lib/traffic_light/tracker/proto/semantic.pb.h"
23 
24 namespace apollo {
25 namespace perception {
26 namespace camera {
27 
31 };
32 
33 struct SemanticTable {
34  double time_stamp = 0.0;
35  double last_bright_time_stamp = 0.0;
36  double last_dark_time_stamp = 0.0;
37  bool blink = false;
38  std::string semantic;
39  std::vector<int> light_ids;
42 };
43 
45  public:
48 
49  bool Init(const TrafficLightTrackerInitOptions &options =
51 
52  bool Track(const TrafficLightTrackerOptions &options,
53  CameraFrame *frame) override;
54  base::TLColor ReviseBySemantic(SemanticTable semantic_table,
55  std::vector<base::TrafficLightPtr> *lights);
56  void ReviseByTimeSeries(double time_stamp, SemanticTable semantic_table,
57  std::vector<base::TrafficLightPtr> *lights);
58  void UpdateHistoryAndLights(const SemanticTable &cur,
59  std::vector<base::TrafficLightPtr> *lights,
60  std::vector<SemanticTable>::iterator *history);
61  void ReviseLights(std::vector<base::TrafficLightPtr> *lights,
62  const std::vector<int> &light_ids, base::TLColor dst_color);
63 
64  std::string Name() const override;
65 
66  explicit SemanticReviser(const BaseTrafficLightTracker &) = delete;
67  SemanticReviser &operator=(const BaseTrafficLightTracker &) = delete;
68 
69  private:
70  traffic_light::tracker::SemanticReviseParam semantic_param_;
71  float revise_time_s_ = 1.5f;
72  float blink_threshold_s_ = 0.4f;
73  float non_blink_threshold_s_ = 0.8f;
74  int hysteretic_threshold_ = 1;
75  std::vector<SemanticTable> history_semantic_;
76 };
77 
78 } // namespace camera
79 } // namespace perception
80 } // namespace apollo
base::TLColor color
Definition: semantic_decision.h:40
Definition: camera_frame.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
~SemanticReviser()
Definition: semantic_decision.h:47
Definition: base_traffic_light_tracker.h:31
Definition: semantic_decision.h:28
HystereticWindow hystertic_window
Definition: semantic_decision.h:41
base::TLColor hysteretic_color
Definition: semantic_decision.h:30
Definition: base_traffic_light_tracker.h:35
int hysteretic_count
Definition: semantic_decision.h:29
Definition: base_traffic_light_tracker.h:29
std::vector< int > light_ids
Definition: semantic_decision.h:39
Definition: semantic_decision.h:33
bool Init(const char *binary_name)
SemanticReviser()
Definition: semantic_decision.h:46
Definition: semantic_decision.h:44
TLColor
Definition: traffic_light.h:28
std::string semantic
Definition: semantic_decision.h:38