OKVIS ROS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
okvis::DenseMatcher Class Reference

This class matches keypoints from two frames in parallel. More...

#include <DenseMatcher.hpp>

Classes

struct  MatchJob
 A data struct for the worker thread. More...
 
struct  Pairing
 A struct to save an index and distance pair. More...
 

Public Types

typedef std::shared_ptr
< DenseMatcher
Ptr
 
typedef float distance_t
 
typedef DenseMatcher::Pairing pairing_t
 
typedef std::vector< pairing_tpairing_list_t
 

Public Member Functions

 DenseMatcher (unsigned char numMatcherThreads=8, unsigned char numBest=4, bool useDistanceRatioThreshold=false)
 Initialize the dense matcher. More...
 
virtual ~DenseMatcher ()
 
template<typename MATCHING_ALGORITHM_T >
void match (MATCHING_ALGORITHM_T &matchingAlgorithm)
 Execute a matching algorithm. This is the fast, templated version. Use this. More...
 
template<typename MATCHING_ALGORITHM_T >
void matchInImageSpace (MATCHING_ALGORITHM_T &matchingAlgorithm)
 Execute a matching algorithm implementing image space matching (i.e. match landmarks with features in their image space vicinity) separate matching function for backwards compatability note: once a uniform implementation for the "old" matcher and the image space matching has been implemented these two methods (match, matchInImageSpace) may be merged into one. More...
 
void matchSlow (MatchingAlgorithm &matchingAlgorithm)
 Execute a matching algorithm. This is the slow, runtime polymorphic version. Don't use this. More...
 
template<typename MATCHING_ALGORITHM_T >
void matchBody (void(DenseMatcher::*doWorkPtr)(MatchJob &, MATCHING_ALGORITHM_T *), MATCHING_ALGORITHM_T &matchingAlgorithm)
 This function creates all the matching threads and assigns the best matches afterwards. More...
 
template<typename MATCHING_ALGORITHM_T >
void doWorkLinearMatching (MatchJob &my_job, MATCHING_ALGORITHM_T *matchingAlgorithm)
 The threading worker. This matches a keypoint with every other keypoint to find the best match. More...
 
template<typename MATCHING_ALGORITHM_T >
void doWorkImageSpaceMatching (MatchJob &my_job, MATCHING_ALGORITHM_T *matchingAlgorithm)
 The threading worker. This matches a keypoint with only a subset of the other keypoints to find the best match. (From matchingAlgorithm->getListBStartIterator() to MatchingAlgorithm->getListBEndIterator(). More...
 
void assignbest (int myIndexScored, pairing_list_t &vPairsWithScore, std::vector< std::vector< pairing_t > > &aiBestList, std::mutex *locks, int startidx)
 A recursive function that reassigns weak matches, if a stronger match is found for a particular point. More...
 
template<typename MATCHING_ALGORITHM_T >
void listBIteration (MATCHING_ALGORITHM_T *matchingAlgorithm, std::vector< pairing_t > &aiBest, size_t shortindexA, size_t i)
 This calculates the distance between to keypoint descriptors. If it is better than the /e numBest_ found so far, it is included in the aiBest list. More...
 

Public Attributes

unsigned char numMatcherThreads_
 The set number of threads. More...
 
unsigned char numBest_
 The set number of best pairings to save. More...
 
bool useDistanceRatioThreshold_
 Use ratio of best and second best match instead of absolute threshold. More...
 
std::unique_ptr
< okvis::ThreadPool
matcherThreadPool_
 The threads. More...
 

Detailed Description

This class matches keypoints from two frames in parallel.

Member Typedef Documentation

typedef std::shared_ptr<DenseMatcher> okvis::DenseMatcher::Ptr

Constructor & Destructor Documentation

okvis::DenseMatcher::DenseMatcher ( unsigned char  numMatcherThreads = 8,
unsigned char  numBest = 4,
bool  useDistanceRatioThreshold = false 
)

Initialize the dense matcher.

Parameters
numMatcherThreadsNumber of matcher threads.
numBestThe number of best matches to keep.
useDistanceRatioThresholdInstead of using an absolute descriptor distance threshold, compare the smallest distance to the second smallest to decide whether to set it as a match.
okvis::DenseMatcher::~DenseMatcher ( )
virtual

Member Function Documentation

void okvis::DenseMatcher::assignbest ( int  myIndexScored,
pairing_list_t vPairsWithScore,
std::vector< std::vector< pairing_t > > &  aiBestList,
std::mutex *  locks,
int  startidx 
)

A recursive function that reassigns weak matches, if a stronger match is found for a particular point.

Parameters
[in]myIndexScoredThe keypoint index that was scored with other keypoints.
[in,out]vPairsWithScoreThe distances to other keypoints that a single thread calculated.
[in,out]aiBestListThe best matches so far.
locksThe mutexes.
startidxStart the assigning at some index. Used for the recursion. Set to 0.
template<typename MATCHING_ALGORITHM_T >
void okvis::DenseMatcher::doWorkImageSpaceMatching ( MatchJob my_job,
MATCHING_ALGORITHM_T *  matchingAlgorithm 
)

The threading worker. This matches a keypoint with only a subset of the other keypoints to find the best match. (From matchingAlgorithm->getListBStartIterator() to MatchingAlgorithm->getListBEndIterator().

Template Parameters
MATCHING_ALGORITHM_TThe algorithm to use. E.g. a class derived from MatchingAlgorithm.
Warning
The MATCHING_ALGORITHM_T class needs an implementatino of getListBStartIterator() and getListBEndIterator().
Parameters
my_jobStruct with information about the job.
matchingAlgorithmThe matching algorithm to use.
template<typename MATCHING_ALGORITHM_T >
void okvis::DenseMatcher::doWorkLinearMatching ( MatchJob my_job,
MATCHING_ALGORITHM_T *  matchingAlgorithm 
)

The threading worker. This matches a keypoint with every other keypoint to find the best match.

Template Parameters
MATCHING_ALGORITHM_TThe algorithm to use. E.g. a class derived from MatchingAlgorithm.
Parameters
my_jobStruct with information about the job.
matchingAlgorithmThe matching algorithm to use.
template<typename MATCHING_ALGORITHM_T >
void okvis::DenseMatcher::listBIteration ( MATCHING_ALGORITHM_T *  matchingAlgorithm,
std::vector< pairing_t > &  aiBest,
size_t  shortindexA,
size_t  i 
)
inline

This calculates the distance between to keypoint descriptors. If it is better than the /e numBest_ found so far, it is included in the aiBest list.

Template Parameters
MATCHING_ALGORITHM_TThe algorithm to use. E.g. a class derived from MatchingAlgorithm.
Parameters
matchingAlgorithmThe matching algorithm to use.
[in,out]aiBestThe numBest_ pairings found so far.
[in]shortindexAKeypoint index in frame A.
[in]iKeypoint index in frame B.
template<typename MATCHING_ALGORITHM_T >
void okvis::DenseMatcher::match ( MATCHING_ALGORITHM_T &  matchingAlgorithm)

Execute a matching algorithm. This is the fast, templated version. Use this.

Template Parameters
MATCHING_ALGORITHM_TThe algorithm to use. E.g. a class derived from MatchingAlgorithm
template<typename MATCHING_ALGORITHM_T >
void okvis::DenseMatcher::matchBody ( void(DenseMatcher::*)(MatchJob &, MATCHING_ALGORITHM_T *)  doWorkPtr,
MATCHING_ALGORITHM_T &  matchingAlgorithm 
)

This function creates all the matching threads and assigns the best matches afterwards.

Template Parameters
MATCHING_ALGORITHM_TThe algorithm to use. E.g. a class derived from MatchingAlgorithm
Parameters
doWorkPtrThe function that the threads are going to run.
matchingAlgorithmThe matching algorithm.
template<typename MATCHING_ALGORITHM_T >
void okvis::DenseMatcher::matchInImageSpace ( MATCHING_ALGORITHM_T &  matchingAlgorithm)

Execute a matching algorithm implementing image space matching (i.e. match landmarks with features in their image space vicinity) separate matching function for backwards compatability note: once a uniform implementation for the "old" matcher and the image space matching has been implemented these two methods (match, matchInImageSpace) may be merged into one.

void okvis::DenseMatcher::matchSlow ( MatchingAlgorithm matchingAlgorithm)

Execute a matching algorithm. This is the slow, runtime polymorphic version. Don't use this.

Member Data Documentation

std::unique_ptr<okvis::ThreadPool> okvis::DenseMatcher::matcherThreadPool_

The threads.

unsigned char okvis::DenseMatcher::numBest_

The set number of best pairings to save.

unsigned char okvis::DenseMatcher::numMatcherThreads_

The set number of threads.

bool okvis::DenseMatcher::useDistanceRatioThreshold_

Use ratio of best and second best match instead of absolute threshold.


The documentation for this class was generated from the following files: