Apollo 10.0
自动驾驶开放平台
object_template_manager.h
浏览该文件的文档.
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 <map>
19#include <string>
20#include <vector>
21
22#include "gflags/gflags.h"
23
24#include "modules/perception/common/camera/common/proto/object_template_meta_schema.pb.h"
25
26#include "cyber/common/log.h"
27#include "cyber/common/macros.h"
31
32namespace apollo {
33namespace perception {
34namespace camera {
35
42
43typedef std::map<base::ObjectSubType, std::vector<float>> TemplateMap;
44
46 public:
47 bool Init();
48 // for general visual obj typed as vehicle
49 float VehObjHwlBySearchTemplates(float *hwl, int *index = nullptr,
50 bool *is_flip = nullptr);
51 const int NrDimPerTmplt() {
52 ACHECK(inited_);
53 return nr_dim_per_tmplt_;
54 }
55 const std::vector<float> &VehHwl() {
56 ACHECK(inited_);
57 return veh_hwl_;
58 }
59 const std::map<TemplateIndex, int> &LookUpTableMinVolumeIndex() {
60 ACHECK(inited_);
61 return look_up_table_min_volume_index_;
62 }
63 const std::map<base::ObjectSubType, float> &TypeSpeedLimit() {
64 ACHECK(inited_);
65 return type_speed_limit_;
66 }
67 const std::vector<base::ObjectSubType> &TypeRefinedByTemplate() {
68 ACHECK(inited_);
69 return type_refined_by_template_;
70 }
71 const std::vector<base::ObjectSubType> &TypeRefinedByRef() {
72 ACHECK(inited_);
73 return type_refined_by_ref_;
74 }
75 const std::vector<base::ObjectSubType> &TypeCanBeRef() {
76 ACHECK(inited_);
77 return type_can_be_ref_;
78 }
80 ACHECK(inited_);
81 return min_template_hwl_;
82 }
84 ACHECK(inited_);
85 return mid_template_hwl_;
86 }
88 ACHECK(inited_);
89 return max_template_hwl_;
90 }
91 const std::vector<TemplateMap> &TemplateHWL() {
92 ACHECK(inited_);
93 return template_hwl_;
94 }
95
96 private:
97 void LoadVehTemplates(const ObjectTemplate &tmplt);
98 void LoadVehMinMidMaxTemplates(const base::ObjectSubType &type,
99 const ObjectTemplate &tmplt);
100
101 // util for tmplt search
102 float Get3dDimensionSimilarity(const float *hwl1, const float *hwl2);
103
104 private:
105 bool inited_ = false;
106 lib::Mutex mutex_;
107
108 int nr_dim_per_tmplt_ = 0;
109 int total_nr_tmplts_veh_ = 0;
110 float max_dim_change_ratio_ = 0.0f;
111 // tmplt
112 std::vector<float> veh_hwl_;
113 // index for min vol in veh class
114 std::map<TemplateIndex, int> look_up_table_min_volume_index_;
115
116 std::map<base::ObjectSubType, float> type_speed_limit_;
117
118 std::vector<base::ObjectSubType> type_refined_by_template_;
119 std::vector<base::ObjectSubType> type_refined_by_ref_;
120 std::vector<base::ObjectSubType> type_can_be_ref_;
121
122 TemplateMap min_template_hwl_;
123 TemplateMap mid_template_hwl_;
124 TemplateMap max_template_hwl_;
125 std::vector<TemplateMap> template_hwl_;
126
128};
129
130} // namespace camera
131} // namespace perception
132} // namespace apollo
const std::map< TemplateIndex, int > & LookUpTableMinVolumeIndex()
const std::map< base::ObjectSubType, float > & TypeSpeedLimit()
const std::vector< base::ObjectSubType > & TypeRefinedByTemplate()
const std::vector< base::ObjectSubType > & TypeRefinedByRef()
const std::vector< base::ObjectSubType > & TypeCanBeRef()
float VehObjHwlBySearchTemplates(float *hwl, int *index=nullptr, bool *is_flip=nullptr)
#define DECLARE_SINGLETON(classname)
Definition macros.h:52
#define ACHECK(cond)
Definition log.h:80
std::map< base::ObjectSubType, std::vector< float > > TemplateMap
class register implement
Definition arena_queue.h:37