-
-
Notifications
You must be signed in to change notification settings - Fork 873
Expand file tree
/
Copy pathtracksUtils.hpp
More file actions
164 lines (142 loc) · 7.35 KB
/
tracksUtils.hpp
File metadata and controls
164 lines (142 loc) · 7.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// This file is part of the AliceVision project.
// Copyright (c) 2016 AliceVision contributors.
// Copyright (c) 2012 openMVG contributors.
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include <aliceVision/track/Track.hpp>
#include <aliceVision/sfmData/SfMData.hpp>
namespace aliceVision {
namespace track {
/**
* @brief Find common tracks between images.
* @param[in] imageIndexes: set of images we are looking for common tracks
* @param[in] tracksIn: all tracks of the scene
* @param[out] tracksOut: output with only the common tracks
*/
bool getCommonTracksInImages(const std::set<std::size_t>& imageIndexes, const TracksMap& tracksIn, TracksMap& tracksOut);
/**
* @brief Find common tracks among a set of images.
* @param[in] imageIndexes: set of images we are looking for common tracks.
* @param[in] tracksPerView: for each view it contains the list of visible tracks. *The tracks ids must be ordered*.
* @param[out] visibleTracks: output with only the common tracks.
*/
void getCommonTracksInImages(const std::set<std::size_t>& imageIndexes, const TracksPerView& tracksPerView, std::set<std::size_t>& visibleTracks);
/**
* @brief Find common tracks among images.
* @param[in] imageIndexes: set of images we are looking for common tracks.
* @param[in] tracksIn: all tracks of the scene.
* @param[in] tracksPerView: for each view the id of the visible tracks.
* @param[out] tracksOut: output with only the common tracks.
*/
bool getCommonTracksInImagesFast(const std::set<std::size_t>& imageIndexes,
const TracksMap& tracksIn,
const TracksPerView& tracksPerView,
TracksMap& tracksOut);
/**
* @brief Find all the visible tracks from a set of images.
* @param[in] imagesId set of images we are looking for tracks.
* @param[in] tracks all tracks of the scene.
* @param[out] tracksId the tracks in the images
*/
void getTracksInImages(const std::set<std::size_t>& imagesId, const TracksMap& tracks, std::set<std::size_t>& tracksId);
/**
* @brief Find all the visible tracks from a set of images.
* @param[in] imagesId set of images we are looking for tracks.
* @param[in] tracksPerView for each view the id of the visible tracks.
* @param[out] tracksId the tracks in the images
*/
void getTracksInImagesFast(const std::set<IndexT>& imagesId, const TracksPerView& tracksPerView, std::set<IndexT>& tracksIds);
/**
* @brief Find all the visible tracks from a single image.
* @param[in] imageIndex of the image we are looking for tracks.
* @param[in] tracks all tracks of the scene.
* @param[out] tracksIds the tracks in the image
*/
void getTracksInImage(const std::size_t& imageIndex, const TracksMap& tracks, std::set<std::size_t>& tracksIds);
/**
* @brief Find all the visible tracks from a set of images.
* @param[in] imageId of the image we are looking for tracks.
* @param[in] map_tracksPerView for each view the id of the visible tracks.
* @param[out] tracksIds the tracks in the images
*/
void getTracksInImageFast(const std::size_t& imageId, const TracksPerView& tracksPerView, std::set<std::size_t>& tracksIds);
/**
* @brief Compute the number of tracks for each view
* @param[in] tracks all tracks of the scene as a map {trackId, track}
* @param[out] tracksPerView : for each view the id of the visible tracks as a map {viewID, vector<trackID>}
*/
void computeTracksPerView(const TracksMap& tracks, TracksPerView& tracksPerView);
/**
* @brief Return the tracksId as a set (sorted increasing)
* @param[in] tracks all tracks of the scene as a map {trackId, track}
* @param[out] tracksIds the tracks in the images
*/
void getTracksIdVector(const TracksMap& tracks, std::set<std::size_t>* tracksIds);
/**
* @brief Get feature id (with associated describer type) in the specified view for each TrackId
* @param[in] allTracks all tracks of the scene as a map {trackId, track}
* @param[in] trackIds the tracks in the images
* @param[in] viewId: ImageId we are looking for features
* @param[out] outFeatId the number of features in the image as a vector
* @return true if the vector of features Ids is not empty
*/
bool getFeatureIdInViewPerTrack(const TracksMap& allTracks, const std::set<std::size_t>& trackIds, IndexT viewId, std::vector<FeatureId>& outFeatId);
struct FunctorMapFirstEqual
{
std::size_t id;
explicit FunctorMapFirstEqual(std::size_t val)
: id(val){};
bool operator()(const std::pair<std::size_t, Track>& val) const { return (id == val.first); }
};
/**
* @brief Convert a trackId to a vector of indexed Matches.
*
* @param[in] tracks: set of tracks with only 2 elements
* (image A and image B) in each Track.
* @param[in] filterIndex: the track indexes to retrieve.
* Only track indexes contained in this filter vector are kept.
* @param[out] outIndex: list of matches
* (feature index in image A, feature index in image B).
*
* @warning The input tracks must be composed of only two images index.
* @warning Image index are considered sorted (increasing order).
*/
void tracksToIndexedMatches(const TracksMap& tracks, const std::vector<IndexT>& filterIndex, std::vector<matching::IndMatch>* outIndex);
/**
* @brief Return the occurrence of tracks length.
* @param[in] tracks all tracks of the scene as a map {trackId, track}
* @param[out] occurrenceTrackLength : the occurrence length of each trackId in the scene
*/
void tracksLength(const TracksMap& tracks, std::map<std::size_t, std::size_t>& occurrenceTrackLength);
/**
* @brief Return a set containing the image Id considered in the tracks container.
* @param[in] tracksPerView the visible tracks as a map {viewID, vector<trackID>}
* @param[out] imagesId set of images considered in the visible tracks container.
*/
void imageIdInTracks(const TracksPerView& tracksPerView, std::set<std::size_t>& imagesId);
/**
* @brief Return a set containing the image Id considered in the tracks container.
* @param[in] tracks all tracks of the scene as a map {trackId, track}
* @param[out] imagesId set of images considered in the tracks container.
*/
void imageIdInTracks(const TracksMap& tracks, std::set<std::size_t>& imagesId);
/**
* @brief compute the set of pairs of views which shares some observed features
* @param covisibility a map indexed by pair of views and whose values are the number of shared features
* @param mapTracks the input tracks map
*/
void computeCovisibility(std::map<Pair, unsigned int>& covisibility, const track::TracksMap& mapTracks);
/**
* @brief Generate noisy tracks
* @param[in] sfmData the input SfMData file
* @param[in] sigmaNoise the variance (in pixels) of the Gaussian noise added to the observation coordinates
* @param[in] outlierRatio the ratio of outliers with respect to the observations count
* @param[in] outlierEpipolarRatio the proportion of outliers which are still respecting the epipolar constraint
* @param[in] randomNoiseVariancePerView specify whether to use different noise variance per view
* @param[out] mapTracks the output tracks map
*/
void simulateTracks(const sfmData::SfMData& sfmData, double sigmaNoise, double outlierRatio, double outlierEpipolarRatio, bool randomNoiseVariancePerView, TracksMap& mapTracks);
} // namespace track
} // namespace aliceVision