Generic Loop detector. More...
#include <TemplatedLoopDetector.h>
Classes | |
struct | Parameters |
Parameters to create a loop detector. More... | |
struct | tIsland |
Matching island. More... | |
struct | tTemporalWindow |
Temporal consistency window. More... | |
Public Member Functions | |
TemplatedLoopDetector (const Parameters ¶ms=Parameters()) | |
TemplatedLoopDetector (const TemplatedVocabulary< TDescriptor, F > &voc, const Parameters ¶ms=Parameters()) | |
TemplatedLoopDetector (const TemplatedDatabase< TDescriptor, F > &db, const Parameters ¶ms=Parameters()) | |
template<class T > | |
TemplatedLoopDetector (const T &db, const Parameters ¶ms=Parameters()) | |
virtual | ~TemplatedLoopDetector (void) |
const TemplatedDatabase < TDescriptor, F > & | getDatabase () const |
const TemplatedVocabulary < TDescriptor, F > & | getVocabulary () const |
template<class T > | |
void | setDatabase (const T &db) |
void | setVocabulary (const TemplatedVocabulary< TDescriptor, F > &voc) |
void | allocate (int nentries, int nkeys=0) |
bool | detectLoop (const std::vector< cv::KeyPoint > &keys, const std::vector< TDescriptor > &descriptors, DetectionResult &match) |
void | clear () |
Protected Member Functions | |
void | removeLowScores (QueryResults &q, double threshold) const |
void | computeIslands (QueryResults &q, vector< tIsland > &islands) const |
double | calculateIslandScore (const QueryResults &q, unsigned int i_first, unsigned int i_last) const |
void | updateTemporalWindow (const tIsland &matched_island, EntryId entry_id) |
int | getConsistentEntries () const |
bool | isGeometricallyConsistent_DI (EntryId old_entry, const std::vector< cv::KeyPoint > &keys, const std::vector< TDescriptor > &descriptors, const FeatureVector &curvec) const |
bool | isGeometricallyConsistent_Flann (EntryId old_entry, const std::vector< cv::KeyPoint > &keys, const std::vector< TDescriptor > &descriptors, cv::FlannBasedMatcher &flann_structure) const |
void | getFlannStructure (const std::vector< TDescriptor > &descriptors, cv::FlannBasedMatcher &flann_structure) const |
bool | isGeometricallyConsistent_Exhaustive (const std::vector< cv::KeyPoint > &old_keys, const std::vector< TDescriptor > &old_descriptors, const std::vector< cv::KeyPoint > &cur_keys, const std::vector< TDescriptor > &cur_descriptors) const |
void | getMatches_neighratio (const std::vector< TDescriptor > &A, const vector< unsigned int > &i_A, const vector< TDescriptor > &B, const vector< unsigned int > &i_B, vector< unsigned int > &i_match_A, vector< unsigned int > &i_match_B) const |
Protected Attributes | |
TemplatedDatabase< TDescriptor, F > * | m_database |
Database. | |
vector< vector< cv::KeyPoint > > | m_image_keys |
KeyPoints of images. | |
vector< vector< TDescriptor > > | m_image_descriptors |
Descriptors of images. | |
BowVector | m_last_bowvec |
Last bow vector added to database. | |
tTemporalWindow | m_window |
Temporal consistency window. | |
Parameters | m_params |
Parameters of loop detector. | |
DVision::FSolver | m_fsolver |
To compute the fundamental matrix. |
Generic Loop detector.
TDescriptor: class of descriptor F: class of descriptor functions
DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::TemplatedLoopDetector | ( | const Parameters & | params = Parameters() |
) | [inline] |
Empty constructor
DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::TemplatedLoopDetector | ( | const TemplatedVocabulary< TDescriptor, F > & | voc, | |
const Parameters & | params = Parameters() | |||
) | [inline] |
Creates a loop detector with the given parameters and with a BoW2 database with the given vocabulary
voc | vocabulary | |
params | loop detector parameters |
DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::TemplatedLoopDetector | ( | const TemplatedDatabase< TDescriptor, F > & | db, | |
const Parameters & | params = Parameters() | |||
) | [inline] |
Creates a loop detector with a copy of the given database, but clearing its contents
db | database to copy | |
params | loop detector parameters |
DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::TemplatedLoopDetector | ( | const T & | db, | |
const Parameters & | params = Parameters() | |||
) | [inline] |
Creates a loop detector with a copy of the given database, but clearing its contents
T | class derived from TemplatedDatabase | |
db | database to copy | |
params | loop detector parameters |
DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::~TemplatedLoopDetector | ( | void | ) | [inline, virtual] |
Destructor
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::allocate | ( | int | nentries, | |
int | nkeys = 0 | |||
) | [inline] |
Allocates some memory for the first entries
nentries | number of expected entries | |
nkeys | number of keypoints per image expected |
double DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::calculateIslandScore | ( | const QueryResults & | q, | |
unsigned int | i_first, | |||
unsigned int | i_last | |||
) | const [inline, protected] |
Returns the score of the island composed of the entries of q whose indices are in [i_first, i_last] (both included)
q | ||
i_first | first index of q of the island | |
i_last | last index of q of the island |
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::clear | ( | ) | [inline] |
Resets the detector and clears the database, such that the next entry will be 0 again
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::computeIslands | ( | QueryResults & | q, | |
vector< tIsland > & | islands | |||
) | const [inline, protected] |
Returns the islands of the given matches in ascending order of entry ids
q | ||
islands | (out) computed islands |
bool DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::detectLoop | ( | const std::vector< cv::KeyPoint > & | keys, | |
const std::vector< TDescriptor > & | descriptors, | |||
DetectionResult & | match | |||
) | [inline] |
Adds the given tuple <keys, descriptors, current_t> to the database and returns the match if any
keys | keypoints of the image | |
descriptors | descriptors associated to the given keypoints | |
match | (out) match or failing information |
int DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::getConsistentEntries | ( | ) | const [inline, protected] |
Returns the number of consistent islands in the temporal window
const TemplatedDatabase< TDescriptor, F > & DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::getDatabase | ( | ) | const [inline] |
Retrieves a reference to the database used by the loop detector
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::getFlannStructure | ( | const std::vector< TDescriptor > & | descriptors, | |
cv::FlannBasedMatcher & | flann_structure | |||
) | const [inline, protected] |
Creates a flann structure from a set of descriptors to perform queries
descriptors | ||
flann_structure | (out) flann matcher |
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::getMatches_neighratio | ( | const std::vector< TDescriptor > & | A, | |
const vector< unsigned int > & | i_A, | |||
const vector< TDescriptor > & | B, | |||
const vector< unsigned int > & | i_B, | |||
vector< unsigned int > & | i_match_A, | |||
vector< unsigned int > & | i_match_B | |||
) | const [protected] |
Calculate the matches between the descriptors A[i_A] and the descriptors B[i_B]. Applies a left-right matching without neighbour ratio
A | set A of descriptors | |
i_A | only descriptors A[i_A] will be checked | |
B | set B of descriptors | |
i_B | only descriptors B[i_B] will be checked | |
i_match_A | (out) indices of descriptors matched (s.t. A[i_match_A]) | |
i_match_B | (out) indices of descriptors matched (s.t. B[i_match_B]) |
const TemplatedVocabulary< TDescriptor, F > & DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::getVocabulary | ( | ) | const [inline] |
Retrieves a reference to the vocabulary used by the loop detector
bool DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::isGeometricallyConsistent_DI | ( | EntryId | old_entry, | |
const std::vector< cv::KeyPoint > & | keys, | |||
const std::vector< TDescriptor > & | descriptors, | |||
const FeatureVector & | curvec | |||
) | const [inline, protected] |
Check if an old entry is geometrically consistent (by calculating a fundamental matrix) with the given set of keys and descriptors
old_entry | entry id of the stored image to check | |
keys | current keypoints | |
descriptors | current descriptors associated to the given keypoints | |
curvec | feature vector of the current entry |
bool DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::isGeometricallyConsistent_Exhaustive | ( | const std::vector< cv::KeyPoint > & | old_keys, | |
const std::vector< TDescriptor > & | old_descriptors, | |||
const std::vector< cv::KeyPoint > & | cur_keys, | |||
const std::vector< TDescriptor > & | cur_descriptors | |||
) | const [inline, protected] |
Check if an old entry is geometrically consistent (by calculating a fundamental matrix from left-right correspondences) with the given set of keys and descriptors, without using the direct index
old_keys | keys of old entry | |
old_descriptors | descriptors of old keys | |
cur_keys | keys of current entry | |
cur_descriptors | descriptors of cur keys |
bool DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::isGeometricallyConsistent_Flann | ( | EntryId | old_entry, | |
const std::vector< cv::KeyPoint > & | keys, | |||
const std::vector< TDescriptor > & | descriptors, | |||
cv::FlannBasedMatcher & | flann_structure | |||
) | const [inline, protected] |
Checks if an old entry is geometrically consistent (by using FLANN and computing an essential matrix by using the neighbour ratio 0.6) with the given set of keys and descriptors
old_entry | entry id of the stored image to check | |
keys | current keypoints | |
descriptors | current descriptors | |
flann_structure | flann structure with the descriptors of the current entry |
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::removeLowScores | ( | QueryResults & | q, | |
double | threshold | |||
) | const [inline, protected] |
Removes from q those results whose score is lower than threshold (that should be alpha * ns_factor)
q | results from query | |
threshold | min value of the resting results |
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::setDatabase | ( | const T & | db | ) | [inline] |
Sets the database to use. The contents of the database and the detector entries are cleared
T | class derived from TemplatedDatabase | |
db | database to copy |
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::setVocabulary | ( | const TemplatedVocabulary< TDescriptor, F > & | voc | ) | [inline] |
Sets a new DBoW2 database created from the given vocabulary
voc | vocabulary to copy |
void DLoopDetector::TemplatedLoopDetector< TDescriptor, F >::updateTemporalWindow | ( | const tIsland & | matched_island, | |
EntryId | entry_id | |||
) | [inline, protected] |
Updates the temporal window by adding the given match <island, id>, such that the window will contain only those islands which are consistent
matched_island | ||
entry_id |