Apollo  6.0
Open source self driving car software
object_maintainer.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 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 
21 
22 namespace apollo {
23 namespace perception {
24 namespace camera {
25 
26 class ObjectMaintainer {
27  public:
30  // @brief: return true if new object added
31  bool Add(int idx, base::ObjectPtr obj) {
32  auto obj_it = assigned_index_.find(idx);
33  if (obj_it == assigned_index_.end()) {
34  assigned_index_[idx] = obj;
35  return true;
36  }
37 
38  auto prev_obj = obj_it->second;
39  const auto &&curr_type = static_cast<int>(obj->sub_type);
40  const auto &&prev_type = static_cast<int>(prev_obj->sub_type);
41  if (obj->sub_type_probs[curr_type] > prev_obj->sub_type_probs[prev_type]) {
42  *prev_obj = *obj;
43  }
44  return false;
45  }
46 
47  protected:
48  std::map<int, base::ObjectPtr> assigned_index_;
49 };
50 
51 } // namespace camera
52 } // namespace perception
53 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::map< int, base::ObjectPtr > assigned_index_
Definition: object_maintainer.h:33
bool Add(int idx, base::ObjectPtr obj)
Definition: object_maintainer.h:31
~ObjectMaintainer()
Definition: object_maintainer.h:29
std::shared_ptr< Object > ObjectPtr
Definition: object.h:123
ObjectMaintainer()
Definition: object_maintainer.h:28