Feature.cpp
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 #include "Feature.h"
23 
24 using namespace ov_core;
25 
26 void Feature::clean_old_measurements(const std::vector<double> &valid_times) {
27 
28  // Loop through each of the cameras we have
29  for (auto const &pair : timestamps) {
30 
31  // Assert that we have all the parts of a measurement
32  assert(timestamps[pair.first].size() == uvs[pair.first].size());
33  assert(timestamps[pair.first].size() == uvs_norm[pair.first].size());
34 
35  // Our iterators
36  auto it1 = timestamps[pair.first].begin();
37  auto it2 = uvs[pair.first].begin();
38  auto it3 = uvs_norm[pair.first].begin();
39 
40  // Loop through measurement times, remove ones that are not in our timestamps
41  while (it1 != timestamps[pair.first].end()) {
42  if (std::find(valid_times.begin(), valid_times.end(), *it1) == valid_times.end()) {
43  it1 = timestamps[pair.first].erase(it1);
44  it2 = uvs[pair.first].erase(it2);
45  it3 = uvs_norm[pair.first].erase(it3);
46  } else {
47  ++it1;
48  ++it2;
49  ++it3;
50  }
51  }
52  }
53 }
54 
55 void Feature::clean_invalid_measurements(const std::vector<double> &invalid_times) {
56 
57  // Loop through each of the cameras we have
58  for (auto const &pair : timestamps) {
59 
60  // Assert that we have all the parts of a measurement
61  assert(timestamps[pair.first].size() == uvs[pair.first].size());
62  assert(timestamps[pair.first].size() == uvs_norm[pair.first].size());
63 
64  // Our iterators
65  auto it1 = timestamps[pair.first].begin();
66  auto it2 = uvs[pair.first].begin();
67  auto it3 = uvs_norm[pair.first].begin();
68 
69  // Loop through measurement times, remove ones that are in our timestamps
70  while (it1 != timestamps[pair.first].end()) {
71  if (std::find(invalid_times.begin(), invalid_times.end(), *it1) != invalid_times.end()) {
72  it1 = timestamps[pair.first].erase(it1);
73  it2 = uvs[pair.first].erase(it2);
74  it3 = uvs_norm[pair.first].erase(it3);
75  } else {
76  ++it1;
77  ++it2;
78  ++it3;
79  }
80  }
81  }
82 }
83 
84 void Feature::clean_older_measurements(double timestamp) {
85 
86  // Loop through each of the cameras we have
87  for (auto const &pair : timestamps) {
88 
89  // Assert that we have all the parts of a measurement
90  assert(timestamps[pair.first].size() == uvs[pair.first].size());
91  assert(timestamps[pair.first].size() == uvs_norm[pair.first].size());
92 
93  // Our iterators
94  auto it1 = timestamps[pair.first].begin();
95  auto it2 = uvs[pair.first].begin();
96  auto it3 = uvs_norm[pair.first].begin();
97 
98  // Loop through measurement times, remove ones that are older then the specified one
99  while (it1 != timestamps[pair.first].end()) {
100  if (*it1 <= timestamp) {
101  it1 = timestamps[pair.first].erase(it1);
102  it2 = uvs[pair.first].erase(it2);
103  it3 = uvs_norm[pair.first].erase(it3);
104  } else {
105  ++it1;
106  ++it2;
107  ++it3;
108  }
109  }
110  }
111 }
ov_core::Feature::clean_invalid_measurements
void clean_invalid_measurements(const std::vector< double > &invalid_times)
Remove measurements that occur at the invalid timestamps.
Definition: Feature.cpp:55
ov_core::Feature::clean_old_measurements
void clean_old_measurements(const std::vector< double > &valid_times)
Remove measurements that do not occur at passed timestamps.
Definition: Feature.cpp:26
Feature.h
ov_core::Feature::clean_older_measurements
void clean_older_measurements(double timestamp)
Remove measurements that are older then the specified timestamp.
Definition: Feature.cpp:84
ov_core::Feature::uvs
std::unordered_map< size_t, std::vector< Eigen::VectorXf > > uvs
UV coordinates that this feature has been seen from (mapped by camera ID)
Definition: Feature.h:49
ov_core::Feature::uvs_norm
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)
Definition: Feature.h:52
ov_core::Feature::timestamps
std::unordered_map< size_t, std::vector< double > > timestamps
Timestamps of each UV measurement (mapped by camera ID)
Definition: Feature.h:55
ov_core
Core algorithms for OpenVINS.
Definition: CamBase.h:30


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