Apollo  6.0
Open source self driving car software
traffic_light.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 <memory>
19 #include <string>
20 #include <vector>
21 
23 
24 namespace apollo {
25 namespace perception {
26 namespace base {
27 
28 enum class TLColor {
29  TL_UNKNOWN_COLOR = 0,
30  TL_RED = 1,
31  TL_YELLOW = 2,
32  TL_GREEN = 3,
33  TL_BLACK = 4,
35 };
36 
37 enum class TLDetectionClass {
38  TL_UNKNOWN_CLASS = -1,
42 };
43 
44 // @brief Light Region in the Image
45 struct LightRegion {
46  // roi is marked by map & projection, it may be too large or not accuracy.
49  bool outside_image = false;
50 
51  std::vector<Rect<int>> debug_roi;
52  std::vector<float> debug_roi_detect_scores;
53 
55  bool is_detected = false;
56  bool is_selected = false;
58 
59  // 3d polygon
60  std::vector<base::PointXYZID> points;
61 
62  // output score by detection
63  float detect_score = 0.0f;
64 };
65 
66 // @brief Light Status
67 struct LightStatus {
68  // Traffic light color status.
70  // How confidence about the detected results, between 0 and 1.
71  double confidence = 0.0;
72  // Duration of the traffic light since detected.
73  double tracking_time = 0.0;
74  // blink status
75  bool blink = false;
76 };
77 
78 // @brief A Traffic Light.
79 struct TrafficLight {
80  TrafficLight() = default;
81 
82  std::string id;
83  int semantic = 0;
84  LightRegion region; // Light region.
85  LightStatus status; // Light Status.
86 };
87 
88 typedef std::shared_ptr<TrafficLight> TrafficLightPtr;
89 typedef std::vector<TrafficLightPtr> TrafficLightPtrs;
90 
91 } // namespace base
92 } // namespace perception
93 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
LightStatus status
Definition: traffic_light.h:85
Rect< int > projection_roi
Definition: traffic_light.h:47
std::vector< Rect< int > > debug_roi
Definition: traffic_light.h:51
Definition: traffic_light.h:79
Definition: traffic_light.h:45
std::shared_ptr< TrafficLight > TrafficLightPtr
Definition: traffic_light.h:88
std::vector< float > debug_roi_detect_scores
Definition: traffic_light.h:52
LightRegion region
Definition: traffic_light.h:84
std::vector< base::PointXYZID > points
Definition: traffic_light.h:60
std::vector< TrafficLightPtr > TrafficLightPtrs
Definition: traffic_light.h:89
Rect< int > detection_roi
Definition: traffic_light.h:54
TLDetectionClass
Definition: traffic_light.h:37
Rect< int > crop_roi
Definition: traffic_light.h:48
Definition: traffic_light.h:67
std::string id
Definition: traffic_light.h:82
TLColor
Definition: traffic_light.h:28