Apollo 10.0
自动驾驶开放平台
semantic_map.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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
13 *implied. See the License for the specific language governing
14 *permissions and limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <future>
20#include <unordered_map>
21
22#include "opencv2/opencv.hpp"
23
24#include "cyber/common/macros.h"
25#include "modules/common_msgs/prediction_msgs/feature.pb.h"
26
27#ifdef __aarch64__
29#endif
30
31namespace apollo {
32namespace prediction {
33
35 public:
37
38 virtual ~SemanticMap() = default;
39
40 void Init();
41
42 void RunCurrFrame(
43 const std::unordered_map<int, ObstacleHistory>& obstacle_id_history_map);
44
45 bool GetMapById(const int obstacle_id, cv::Mat* feature_map);
46
47 private:
48 cv::Point2i GetTransPoint(const double x, const double y, const double base_x,
49 const double base_y) {
50 return cv::Point2i(static_cast<int>((x - base_x) / 0.1),
51 static_cast<int>(2000 - (y - base_y) / 0.1));
52 }
53
54 void DrawBaseMap(const double x, const double y, const double base_x,
55 const double base_y);
56
57 void DrawBaseMapThread();
58
59 void DrawRoads(const common::PointENU& center_point, const double base_x,
60 const double base_y,
61 const cv::Scalar& color = cv::Scalar(64, 64, 64));
62
63 void DrawJunctions(const common::PointENU& center_point, const double base_x,
64 const double base_y,
65 const cv::Scalar& color = cv::Scalar(128, 128, 128));
66
67 void DrawCrosswalks(const common::PointENU& center_point, const double base_x,
68 const double base_y,
69 const cv::Scalar& color = cv::Scalar(192, 192, 192));
70
71 void DrawLanes(const common::PointENU& center_point, const double base_x,
72 const double base_y,
73 const cv::Scalar& color = cv::Scalar(255, 255, 255));
74
75 cv::Scalar HSVtoRGB(double H = 1.0, double S = 1.0, double V = 1.0);
76
77 void DrawRect(const Feature& feature, const cv::Scalar& color,
78 const double base_x, const double base_y, cv::Mat* img);
79
80 void DrawPoly(const Feature& feature, const cv::Scalar& color,
81 const double base_x, const double base_y, cv::Mat* img);
82
83 void DrawHistory(const ObstacleHistory& history, const cv::Scalar& color,
84 const double base_x, const double base_y, cv::Mat* img);
85
86 // Draw adc trajectory in semantic map
87 void DrawADCTrajectory(const cv::Scalar& color, const double base_x,
88 const double base_y, cv::Mat* img);
89
90 cv::Mat CropArea(const cv::Mat& input_img, const cv::Point2i& center_point,
91 const double heading);
92
93 cv::Mat CropByHistory(const ObstacleHistory& history, const cv::Scalar& color,
94 const double base_x, const double base_y);
95
96 private:
97 // base_image, base_x, and base_y to be updated by async thread
98 cv::Mat base_img_;
99 double base_x_ = 0.0;
100 double base_y_ = 0.0;
101
102 std::mutex draw_base_map_thread_mutex_;
103
104 // base_image, base_x, and base_y to be used in the current cycle
105 cv::Mat curr_img_;
106 double curr_base_x_ = 0.0;
107 double curr_base_y_ = 0.0;
108
109 std::unordered_map<int, ObstacleHistory> obstacle_id_history_map_;
110 Feature ego_feature_;
111
112 std::future<void> task_future_;
113
114 bool started_drawing_ = false;
115
116#ifdef __aarch64__
117 AffineTransform affine_transformer_;
118#endif
119};
120
121} // namespace prediction
122} // namespace apollo
void RunCurrFrame(const std::unordered_map< int, ObstacleHistory > &obstacle_id_history_map)
bool GetMapById(const int obstacle_id, cv::Mat *feature_map)
virtual ~SemanticMap()=default
class register implement
Definition arena_queue.h:37