30 std::lock_guard<std::mutex> lck(
mtx);
42 std::lock_guard<std::mutex> lck(
mtx);
47 feat.
featid = temp->featid;
54 feat.
p_FinA = temp->p_FinA;
55 feat.
p_FinG = temp->p_FinG;
62 std::lock_guard<std::mutex> lck(
mtx);
67 feat->uvs[cam_id].push_back(Eigen::Vector2f(u, v));
68 feat->uvs_norm[cam_id].push_back(Eigen::Vector2f(u_n, v_n));
69 feat->timestamps[cam_id].push_back(timestamp);
77 std::shared_ptr<Feature> feat = std::make_shared<Feature>();
79 feat->uvs[cam_id].push_back(Eigen::Vector2f(u, v));
80 feat->uvs_norm[cam_id].push_back(Eigen::Vector2f(u_n, v_n));
81 feat->timestamps[cam_id].push_back(timestamp);
90 std::vector<std::shared_ptr<Feature>> feats_old;
93 std::lock_guard<std::mutex> lck(
mtx);
96 if (skip_deleted && (*it).second->to_delete) {
102 bool has_newer_measurement =
false;
103 for (
auto const &pair : (*it).second->timestamps) {
104 has_newer_measurement = (!pair.second.empty() && pair.second.at(pair.second.size() - 1) >= timestamp);
105 if (has_newer_measurement) {
110 if (!has_newer_measurement) {
111 feats_old.push_back((*it).second);
131 std::vector<std::shared_ptr<Feature>> feats_old;
134 std::lock_guard<std::mutex> lck(
mtx);
137 if (skip_deleted && (*it).second->to_delete) {
143 bool found_containing_older =
false;
144 for (
auto const &pair : (*it).second->timestamps) {
145 found_containing_older = (!pair.second.empty() && pair.second.at(0) < timestamp);
146 if (found_containing_older) {
151 if (found_containing_older) {
152 feats_old.push_back((*it).second);
172 std::vector<std::shared_ptr<Feature>> feats_has_timestamp;
175 std::lock_guard<std::mutex> lck(
mtx);
178 if (skip_deleted && (*it).second->to_delete) {
184 bool has_timestamp =
false;
185 for (
auto const &pair : (*it).second->timestamps) {
186 has_timestamp = (std::find(pair.second.begin(), pair.second.end(), timestamp) != pair.second.end());
193 feats_has_timestamp.push_back((*it).second);
208 return feats_has_timestamp;
214 std::lock_guard<std::mutex> lck(
mtx);
217 if ((*it).second->to_delete) {
227 std::lock_guard<std::mutex> lck(
mtx);
230 (*it).second->clean_older_measurements(timestamp);
233 for (
const auto &pair : (*it).second->timestamps) {
234 ct_meas += (int)(pair.second.size());
246 std::lock_guard<std::mutex> lck(
mtx);
247 std::vector<double> timestamps = {timestamp};
250 (*it).second->clean_invalid_measurements(timestamps);
253 for (
const auto &pair : (*it).second->timestamps) {
254 ct_meas += (int)(pair.second.size());
266 std::lock_guard<std::mutex> lck(
mtx);
267 double oldest_time = -1;
269 for (
auto const &camtimepair : feat.second->timestamps) {
270 if (!camtimepair.second.empty() && (oldest_time == -1 || oldest_time > camtimepair.second.at(0))) {
271 oldest_time = camtimepair.second.at(0);
279 std::lock_guard<std::mutex> lck(
mtx);
283 for (
const auto &feat : database->get_internal_data()) {
288 for (
const auto × : feat.second->timestamps) {
291 size_t cam_id = times.first;
292 if (temp->timestamps.find(cam_id) == temp->timestamps.end()) {
293 temp->timestamps[cam_id] = feat.second->timestamps.at(cam_id);
294 temp->uvs[cam_id] = feat.second->uvs.at(cam_id);
295 temp->uvs_norm[cam_id] = feat.second->uvs_norm.at(cam_id);
297 auto temp_times = temp->timestamps.at(cam_id);
298 for (
size_t i = 0; i < feat.second->timestamps.at(cam_id).size(); i++) {
299 double time_to_find = feat.second->timestamps.at(cam_id).at(i);
300 if (std::find(temp_times.begin(), temp_times.end(), time_to_find) == temp_times.end()) {
301 temp->timestamps.at(cam_id).push_back(feat.second->timestamps.at(cam_id).at(i));
302 temp->uvs.at(cam_id).push_back(feat.second->uvs.at(cam_id).at(i));
303 temp->uvs_norm.at(cam_id).push_back(feat.second->uvs_norm.at(cam_id).at(i));
312 std::shared_ptr<Feature> temp = std::make_shared<Feature>();
313 temp->featid = feat.second->featid;
314 temp->timestamps = feat.second->timestamps;
315 temp->uvs = feat.second->uvs;
316 temp->uvs_norm = feat.second->uvs_norm;
Eigen::Vector3d p_FinG
Triangulated position of this feature, in the global frame.
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.
bool to_delete
If this feature should be deleted.
std::unordered_map< size_t, std::vector< double > > timestamps
Timestamps of each UV measurement (mapped by camera ID)
void cleanup_measurements(double timestamp)
This function will delete all feature measurements that are older then the specified timestamp...
int anchor_cam_id
What camera ID our pose is anchored in!! By default the first measurement is the anchor.
size_t featid
Unique ID of this feature.
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.
double get_oldest_timestamp()
Gets the oldest time in the database.
double anchor_clone_timestamp
Timestamp of anchor clone.
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's latest feature information.
std::unordered_map< size_t, std::vector< Eigen::VectorXf > > uvs_norm
UV normalized coordinates that this feature has been seen from (mapped by camera ID) ...
Core algorithms for OpenVINS.
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::unordered_map< size_t, std::vector< Eigen::VectorXf > > uvs
UV coordinates that this feature has been seen from (mapped by camera ID)
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.
Eigen::Vector3d p_FinA
Triangulated position of this feature, in the anchor frame.