FeatureDatabase.h
Go to the documentation of this file.
1 /*
2  * OpenVINS: An Open Platform for Visual-Inertial Research
3  * Copyright (C) 2018-2023 Patrick Geneva
4  * Copyright (C) 2018-2023 Guoquan Huang
5  * Copyright (C) 2018-2023 OpenVINS Contributors
6  * Copyright (C) 2018-2019 Kevin Eckenhoff
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OV_CORE_FEATURE_DATABASE_H
23 #define OV_CORE_FEATURE_DATABASE_H
24 
25 #include <Eigen/Eigen>
26 #include <memory>
27 #include <mutex>
28 #include <unordered_map>
29 #include <vector>
30 
31 namespace ov_core {
32 
33 class Feature;
34 
55 
56 public:
61 
68  std::shared_ptr<Feature> get_feature(size_t id, bool remove = false);
69 
76  bool get_feature_clone(size_t id, Feature &feat);
77 
91  void update_feature(size_t id, double timestamp, size_t cam_id, float u, float v, float u_n, float v_n);
92 
100  std::vector<std::shared_ptr<Feature>> features_not_containing_newer(double timestamp, bool remove = false, bool skip_deleted = false);
101 
108  std::vector<std::shared_ptr<Feature>> features_containing_older(double timestamp, bool remove = false, bool skip_deleted = false);
109 
116  std::vector<std::shared_ptr<Feature>> features_containing(double timestamp, bool remove = false, bool skip_deleted = false);
117 
123  void cleanup();
124 
128  void cleanup_measurements(double timestamp);
129 
133  void cleanup_measurements_exact(double timestamp);
134 
138  size_t size() {
139  std::lock_guard<std::mutex> lck(mtx);
140  return features_idlookup.size();
141  }
142 
146  std::unordered_map<size_t, std::shared_ptr<Feature>> get_internal_data() {
147  std::lock_guard<std::mutex> lck(mtx);
148  return features_idlookup;
149  }
150 
154  double get_oldest_timestamp();
155 
159  void append_new_measurements(const std::shared_ptr<FeatureDatabase> &database);
160 
161 protected:
163  std::mutex mtx;
164 
166  std::unordered_map<size_t, std::shared_ptr<Feature>> features_idlookup;
167 };
168 
169 } // namespace ov_core
170 
171 #endif /* OV_CORE_FEATURE_DATABASE_H */
std::vector< std::shared_ptr< Feature > > features_containing_older(double timestamp, bool remove=false, bool skip_deleted=false)
Get features that has measurements older then the specified time.
std::mutex mtx
Mutex lock for our map.
void update_feature(size_t id, double timestamp, size_t cam_id, float u, float v, float u_n, float v_n)
Update a feature object.
size_t size()
Returns the size of the feature database.
void cleanup_measurements(double timestamp)
This function will delete all feature measurements that are older then the specified timestamp...
std::shared_ptr< Feature > get_feature(size_t id, bool remove=false)
Get a specified feature.
void cleanup_measurements_exact(double timestamp)
This function will delete all feature measurements that are at the specified timestamp.
Sparse feature class used to collect measurements.
Definition: Feature.h:39
double get_oldest_timestamp()
Gets the oldest time in the database.
Database containing features we are currently tracking.
FeatureDatabase()
Default constructor.
std::unordered_map< size_t, std::shared_ptr< Feature > > features_idlookup
Our lookup array that allow use to query based on ID.
void append_new_measurements(const std::shared_ptr< FeatureDatabase > &database)
Will update the passed database with this database&#39;s latest feature information.
Core algorithms for OpenVINS.
Definition: CamBase.h:30
bool get_feature_clone(size_t id, Feature &feat)
Get a specified feature clone (pointer is thread safe)
void cleanup()
This function will delete all features that have been used up.
std::vector< std::shared_ptr< Feature > > features_not_containing_newer(double timestamp, bool remove=false, bool skip_deleted=false)
Get features that do not have newer measurement then the specified time.
std::vector< std::shared_ptr< Feature > > features_containing(double timestamp, bool remove=false, bool skip_deleted=false)
Get features that has measurements at the specified time.
std::unordered_map< size_t, std::shared_ptr< Feature > > get_internal_data()
Returns the internal data (should not normally be used)


ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Wed Jun 21 2023 03:05:36