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 */
ov_core::FeatureDatabase::get_oldest_timestamp
double get_oldest_timestamp()
Gets the oldest time in the database.
Definition: FeatureDatabase.cpp:265
ov_core::FeatureDatabase::append_new_measurements
void append_new_measurements(const std::shared_ptr< FeatureDatabase > &database)
Will update the passed database with this database's latest feature information.
Definition: FeatureDatabase.cpp:278
ov_core::FeatureDatabase::features_containing_older
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.
Definition: FeatureDatabase.cpp:128
ov_core::FeatureDatabase::size
size_t size()
Returns the size of the feature database.
Definition: FeatureDatabase.h:138
ov_core::FeatureDatabase::cleanup
void cleanup()
This function will delete all features that have been used up.
Definition: FeatureDatabase.cpp:211
ov_core::FeatureDatabase::features_not_containing_newer
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.
Definition: FeatureDatabase.cpp:87
ov_core::FeatureDatabase::mtx
std::mutex mtx
Mutex lock for our map.
Definition: FeatureDatabase.h:163
ov_core::FeatureDatabase::get_internal_data
std::unordered_map< size_t, std::shared_ptr< Feature > > get_internal_data()
Returns the internal data (should not normally be used)
Definition: FeatureDatabase.h:146
ov_core::FeatureDatabase::cleanup_measurements_exact
void cleanup_measurements_exact(double timestamp)
This function will delete all feature measurements that are at the specified timestamp.
Definition: FeatureDatabase.cpp:245
ov_core::Feature
Sparse feature class used to collect measurements.
Definition: Feature.h:39
ov_core::FeatureDatabase::FeatureDatabase
FeatureDatabase()
Default constructor.
Definition: FeatureDatabase.h:60
ov_core::FeatureDatabase
Database containing features we are currently tracking.
Definition: FeatureDatabase.h:54
ov_core::FeatureDatabase::features_containing
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.
Definition: FeatureDatabase.cpp:169
ov_core::FeatureDatabase::update_feature
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.
Definition: FeatureDatabase.cpp:59
ov_core::FeatureDatabase::get_feature_clone
bool get_feature_clone(size_t id, Feature &feat)
Get a specified feature clone (pointer is thread safe)
Definition: FeatureDatabase.cpp:41
ov_core
Core algorithms for OpenVINS.
Definition: CamBase.h:30
ov_core::FeatureDatabase::features_idlookup
std::unordered_map< size_t, std::shared_ptr< Feature > > features_idlookup
Our lookup array that allow use to query based on ID.
Definition: FeatureDatabase.h:166
ov_core::FeatureDatabase::cleanup_measurements
void cleanup_measurements(double timestamp)
This function will delete all feature measurements that are older then the specified timestamp.
Definition: FeatureDatabase.cpp:226
ov_core::FeatureDatabase::get_feature
std::shared_ptr< Feature > get_feature(size_t id, bool remove=false)
Get a specified feature.
Definition: FeatureDatabase.cpp:29


ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Mon Jan 22 2024 03:08:17