MSCEqF
1.0
Multi State Constraint Equivariant Filter for visual inertial navigation
Toggle main menu visibility
Loading...
Searching...
No Matches
track.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 Apache License, Version 2.0
7
// (the "License"); you may not use this file except in compliance with the
8
// License. You may obtain a copy of the License at
9
//
10
// http://www.apache.org/licenses/LICENSE-2.0
11
//
12
// Unless required by applicable law or agreed to in writing, software
13
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
// License for the specific language governing permissions and limitations
16
// under the License.
17
//
18
// You can contact the authors at <alessandro.fornasier@ieee.org>
19
20
#ifndef TRACK_HPP
21
#define TRACK_HPP
22
23
#include <opencv2/opencv.hpp>
24
25
#include "types/fptypes.hpp"
26
#include "vision/features.hpp"
27
28
namespace
msceqf
29
{
37
struct
Track
38
{
39
using
Times
= std::vector<fp>;
40
46
inline
bool
empty
() const noexcept {
return
uvs_
.empty(); }
47
53
inline
size_t
size
() const noexcept
54
{
55
assert(
uvs_
.size() ==
normalized_uvs_
.size());
56
assert(
uvs_
.size() ==
timestamps_
.size());
57
return
uvs_
.size();
58
}
59
66
void
removeInvalid
(std::vector<bool>& invalid)
67
{
68
assert(invalid.size() ==
uvs_
.size());
69
assert(
uvs_
.size() ==
normalized_uvs_
.size());
70
assert(
uvs_
.size() ==
timestamps_
.size());
71
72
size_t
i = 0;
73
size_t
j = 0;
74
75
while
(i <
uvs_
.size())
76
{
77
if
(!invalid[i])
78
{
79
uvs_
[j] =
uvs_
[i];
80
normalized_uvs_
[j] =
normalized_uvs_
[i];
81
timestamps_
[j] =
timestamps_
[i];
82
++j;
83
}
84
++i;
85
}
86
87
uvs_
.resize(j);
88
normalized_uvs_
.resize(j);
89
timestamps_
.resize(j);
90
}
91
100
void
removeTail
(
const
fp& timestamp,
const
bool
& remove_equal =
true
)
101
{
102
assert(
uvs_
.size() ==
normalized_uvs_
.size());
103
assert(
uvs_
.size() ==
timestamps_
.size());
104
105
size_t
j = 0;
106
size_t
i = 0;
107
108
while
(i <
uvs_
.size())
109
{
110
if
(remove_equal &&
timestamps_
[i] > timestamp)
111
{
112
uvs_
[j] =
uvs_
[i];
113
normalized_uvs_
[j] =
normalized_uvs_
[i];
114
timestamps_
[j] =
timestamps_
[i];
115
++j;
116
}
117
if
(!remove_equal &&
timestamps_
[i] >= timestamp)
118
{
119
uvs_
[j] =
uvs_
[i];
120
normalized_uvs_
[j] =
normalized_uvs_
[i];
121
timestamps_
[j] =
timestamps_
[i];
122
++j;
123
}
124
++i;
125
}
126
127
uvs_
.resize(j);
128
normalized_uvs_
.resize(j);
129
timestamps_
.resize(j);
130
}
131
136
friend
bool
operator<
(
const
Track
& lhs,
const
Track
& rhs) {
return
lhs.
size
() < rhs.
size
(); }
137
138
FeaturesCoordinates
uvs_
;
139
FeaturesCoordinates
normalized_uvs_
;
140
Times
timestamps_
;
141
};
142
143
using
Tracks = std::unordered_map<uint, Track>;
144
145
}
// namespace msceqf
146
147
#endif
// TRACK_HPP
msceqf::Track
(Cache friendly) Track struct. Define a feature (labeled via a feature id) detected/tracked at differ...
Definition
track.hpp:38
msceqf::Track::removeInvalid
void removeInvalid(std::vector< bool > &invalid)
Remove invalid features coordinates, normalized feature coordinates and ids given a vector of boolean...
Definition
track.hpp:66
msceqf::Track::empty
bool empty() const noexcept
Check if there valid coordinates in uvs_.
Definition
track.hpp:46
msceqf::Track::removeTail
void removeTail(const fp ×tamp, const bool &remove_equal=true)
Remove the tail of the track. this method removes coordinates and timestamps that are older or equal ...
Definition
track.hpp:100
msceqf::Track::uvs_
FeaturesCoordinates uvs_
(u, v) coordinates of the same feature at different time steps
Definition
track.hpp:138
msceqf::Track::size
size_t size() const noexcept
Return the amount of features (size of uvs_).
Definition
track.hpp:53
msceqf::Track::operator<
friend bool operator<(const Track &lhs, const Track &rhs)
Comparison operator with other tracks for sorting based on track length.
Definition
track.hpp:136
msceqf::Track::normalized_uvs_
FeaturesCoordinates normalized_uvs_
Normalized (u, v) coordinates of the same feature at different time steps.
Definition
track.hpp:139
msceqf::Track::timestamps_
Times timestamps_
Timestamps of the camera measurement containing the feature.
Definition
track.hpp:140
msceqf::Track::Times
std::vector< fp > Times
vector of timestamps
Definition
track.hpp:39
include
vision
track.hpp
Generated by
1.17.0