MSCEqF 1.0
Multi State Constraint Equivariant Filter for visual inertial navigation
Loading...
Searching...
No Matches
features.hpp
1// Copyright (C) 2023 Alessandro Fornasier.
2// Control of Networked Systems, University of Klagenfurt, Austria.
3//
4// All rights reserved.
5//
6// This software is licensed under the terms of the BSD-2-Clause-License with
7// no commercial use allowed, the full terms of which are made available
8// in the LICENSE file. No license in patents is granted.
9//
10// You can contact the authors at <alessandro.fornasier@ieee.org>
11
12#ifndef FEATURES_HPP
13#define FEATURES_HPP
14
15#include <opencv2/opencv.hpp>
16
17#include "types/fptypes.hpp"
18
19namespace msceqf
20{
21using FeaturesCoordinates = std::vector<cv::Point2f>;
22
30{
31 using FeatureIds = std::vector<uint>;
32
38 inline bool empty() const noexcept { return uvs_.empty(); }
39
45 inline size_t size() const noexcept
46 {
47 assert(distorted_uvs_.size() == uvs_.size());
48 assert(distorted_uvs_.size() == normalized_uvs_.size());
49 assert(distorted_uvs_.size() == ids_.size());
50 return distorted_uvs_.size();
51 }
52
59 void removeInvalid(std::vector<bool>& invalid)
60 {
61 assert(invalid.size() == distorted_uvs_.size());
62 assert(distorted_uvs_.size() == uvs_.size());
63 assert(distorted_uvs_.size() == normalized_uvs_.size());
64 assert(distorted_uvs_.size() == ids_.size());
65
66 size_t i = 0;
67 size_t j = 0;
68
69 while (i < invalid.size())
70 {
71 if (!invalid[i])
72 {
74 uvs_[j] = uvs_[i];
76 ids_[j] = ids_[i];
77 ++j;
78 }
79 ++i;
80 }
81
82 distorted_uvs_.resize(j);
83 uvs_.resize(j);
84 normalized_uvs_.resize(j);
85 ids_.resize(j);
86 }
87
88 FeaturesCoordinates distorted_uvs_;
89 FeaturesCoordinates uvs_;
90 FeaturesCoordinates normalized_uvs_;
92};
93
94} // namespace msceqf
95
96#endif // FEATURES_HPP
(Cache friendly) Features struct. Define a set of features detected/tracked.
Definition features.hpp:30
FeaturesCoordinates distorted_uvs_
Distorted (u, v) coordinates of the features detected/tracked.
Definition features.hpp:88
FeaturesCoordinates uvs_
Undistorted (u, v) coordinates of the features detected/tracked.
Definition features.hpp:89
void removeInvalid(std::vector< bool > &invalid)
Remove invalid features coordinates, normalized feature coordinates and ids given a vector of boolean...
Definition features.hpp:59
FeatureIds ids_
Id of the features detected/tracked.
Definition features.hpp:91
FeaturesCoordinates normalized_uvs_
Undistorted normalized (u, v) coordinates of features detected/tracked.
Definition features.hpp:90
std::vector< uint > FeatureIds
Vector of feature ids.
Definition features.hpp:31
bool empty() const noexcept
Check if there valid coordinates in uvs_.
Definition features.hpp:38
size_t size() const noexcept
Return the amount of features (size of uvs_)
Definition features.hpp:45