GSoC2011SfM
0.1
Google Summer of Code 2011: Structure from motion
|
A class used for matching descriptors that can be described as vectors in a finite-dimensional space. More...
#include <PointsMatcher.h>
Public Member Functions | |
PointsMatcher (const cv::Ptr< cv::DescriptorMatcher > &matcher) | |
PointsMatcher (const PointsMatcher ©) | |
virtual | ~PointsMatcher () |
virtual void | add (cv::Ptr< PointsToTrack > pointCollection) |
virtual void | clear () |
virtual void | train () |
virtual bool | isMaskSupported () |
virtual bool | empty () const |
virtual cv::Ptr< PointsMatcher > | clone (bool emptyTrainData=true) |
virtual void | match (cv::Ptr< PointsToTrack > queryPoints, std::vector< cv::DMatch > &matches, const std::vector< cv::Mat > &masks=std::vector< cv::Mat >()) |
virtual void | knnMatch (cv::Ptr< PointsToTrack > queryPoints, std::vector< std::vector< cv::DMatch > > &matches, int k, const std::vector< cv::Mat > &masks=std::vector< cv::Mat >(), bool compactResult=true) |
virtual void | radiusMatch (cv::Ptr< PointsToTrack > queryPoints, std::vector< std::vector< cv::DMatch > > &matches, float maxDistance, const std::vector< cv::Mat > &masks=std::vector< cv::Mat >(), bool compactResult=true) |
virtual void | crossMatch (cv::Ptr< PointsMatcher > otherMatcher, std::vector< cv::DMatch > &matches, const std::vector< cv::Mat > &masks=std::vector< cv::Mat >()) |
const cv::KeyPoint & | getKeypoint (int numKey) const |
Static Public Member Functions | |
static cv::Ptr< PointsMatcher > | create (std::string match_algo) |
static void | drawMatches (const cv::Mat &img1, const std::vector< cv::KeyPoint > &keypoints1, const std::vector< cv::KeyPoint > &keypoints2, const std::vector< cv::DMatch > &matches1to2, cv::Mat &outImg, const cv::Scalar &matchColor=cv::Scalar::all(-1), const cv::Scalar &singlePointColor=cv::Scalar::all(-1), const std::vector< char > &matchesMask=std::vector< char >(), int flags=cv::DrawMatchesFlags::DEFAULT) |
static void | read (const cv::FileNode &node, PointsMatcher &points) |
static void | write (cv::FileStorage &fs, const PointsMatcher &points) |
Protected Member Functions | |
DECLARE_MUTEX (thread_concurr) | |
PointsMatcher () | |
Protected Attributes | |
cv::Ptr< cv::DescriptorMatcher > | matcher_ |
Algorithm used to find matches... | |
std::vector< cv::Ptr < PointsToTrack > > | pointCollection_ |
Vector of points used to compute matches... |
A class used for matching descriptors that can be described as vectors in a finite-dimensional space.
Any Matcher that inherit from DescriptorMatcher can be used ( For example, you can use FlannBasedMatcher or BruteForceMatcher ).
Definition at line 17 of file PointsMatcher.h.
OpencvSfM::PointsMatcher::PointsMatcher | ( | const cv::Ptr< cv::DescriptorMatcher > & | matcher | ) |
Constructor. Need a matcher algorithm...
matcher | Ptr on a matcher. See for available matcher: http://opencv.willowgarage.com/documentation/cpp/features2d_common_interfaces_of_descriptor_matchers.html#descriptormatcher |
Definition at line 20 of file PointsMatcher.cpp.
OpencvSfM::PointsMatcher::PointsMatcher | ( | const PointsMatcher & | copy | ) |
Copy constructor.
Definition at line 33 of file PointsMatcher.cpp.
OpencvSfM::PointsMatcher::~PointsMatcher | ( | void | ) | [virtual] |
Destructor...
Definition at line 40 of file PointsMatcher.cpp.
OpencvSfM::PointsMatcher::PointsMatcher | ( | ) | [protected] |
This constructor is only available for inherited classes!
Definition at line 27 of file PointsMatcher.cpp.
Referenced by clone().
void OpencvSfM::PointsMatcher::add | ( | cv::Ptr< PointsToTrack > | pointCollection | ) | [virtual] |
Use this function to add data used to find matches
pointCollection | points computed using various methods. Please be carful to get compatible points ( that is with descriptors if matcher need some ) |
Definition at line 51 of file PointsMatcher.cpp.
void OpencvSfM::PointsMatcher::clear | ( | ) | [virtual] |
If needed, you can clear the training data using this method.
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow.
Definition at line 58 of file PointsMatcher.cpp.
Ptr< PointsMatcher > OpencvSfM::PointsMatcher::clone | ( | bool | emptyTrainData = true | ) | [virtual] |
Clone the matcher.
emptyTrainData | IIf emptyTrainData is false the method create deep copy of the object, i.e. copies both parameters and train data. If emptyTrainData is true the method create object copy with current parameters but with empty train data.. |
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow, and OpencvSfM::MatcherSparseFlow.
Definition at line 170 of file PointsMatcher.cpp.
Referenced by OpencvSfM::MatchingThread::operator()().
static cv::Ptr<PointsMatcher> OpencvSfM::PointsMatcher::create | ( | std::string | match_algo | ) | [inline, static] |
Use this function to create a point matcher using the name of a matching algorithm (see http://opencv.willowgarage.com/documentation/cpp/features2d_common_interfaces_of_descriptor_matchers.html)
match_algo | name of the wanted algorithm |
Definition at line 41 of file PointsMatcher.h.
void OpencvSfM::PointsMatcher::crossMatch | ( | cv::Ptr< PointsMatcher > | otherMatcher, |
std::vector< cv::DMatch > & | matches, | ||
const std::vector< cv::Mat > & | masks = std::vector<cv::Mat>( ) |
||
) | [virtual] |
Using an other matchers given in parameters, recompute a matching in inverse order and keep only matches which are two-ways.
otherMatcher | Query set of points and descriptors. |
matches | First guess of matches... Will be updated to contain only two-way matches ( can be empty ). |
masks | specifying permissible matches between input query and train matrices of descriptors. |
Definition at line 181 of file PointsMatcher.cpp.
OpencvSfM::PointsMatcher::DECLARE_MUTEX | ( | thread_concurr | ) | [protected] |
In order to be able to match points in threads, we have to take care of interprocess access.
void OpencvSfM::PointsMatcher::drawMatches | ( | const cv::Mat & | img1, |
const std::vector< cv::KeyPoint > & | keypoints1, | ||
const std::vector< cv::KeyPoint > & | keypoints2, | ||
const std::vector< cv::DMatch > & | matches1to2, | ||
cv::Mat & | outImg, | ||
const cv::Scalar & | matchColor = cv::Scalar::all( -1 ) , |
||
const cv::Scalar & | singlePointColor = cv::Scalar::all( -1 ) , |
||
const std::vector< char > & | matchesMask = std::vector<char>( ) , |
||
int | flags = cv::DrawMatchesFlags::DEFAULT |
||
) | [static] |
This function draw keypoints and matches. Contrary to cv::drawMatches, only the first image is used to draw matches...
img1 | First source image. |
keypoints1 | Keypoints from first source image. |
keypoints2 | Keypoints from second source image. |
matches1to2 | Matches from first image to second one, i.e. keypoints1[ i ] has corresponding point keypoints2[ matches[ i ]] . |
outImg | Output image. Its content depends on flags value what is drawn in output image. See below possible flags bit values. |
matchColor | – Color of matches ( lines and connected keypoints ). If matchColor==Scalar::all( -1 ) color will be generated randomly. |
singlePointColor | – Color of single keypoints ( circles ), i.e. keypoints not having the matches. If singlePointColor==Scalar::all( -1 ) color will be generated randomly. |
matchesMask | – Mask determining which matches will be drawn. If mask is empty all matches will be drawn. |
flags | – Each bit of flags sets some feature of drawing. Possible flags bit values is defined by DrawMatchesFlags , see http://opencv.willowgarage.com/documentation/cpp/features2d_drawing_function_of_keypoints_and_matches.html#cv-drawmatches. |
Definition at line 227 of file PointsMatcher.cpp.
Referenced by OpencvSfM::SequenceAnalyzer::showTracks(), and OpencvSfM::SequenceAnalyzer::showTracksBetween().
bool OpencvSfM::PointsMatcher::empty | ( | ) | const [virtual] |
Use to know if matching are available
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow.
Definition at line 165 of file PointsMatcher.cpp.
const cv::KeyPoint & OpencvSfM::PointsMatcher::getKeypoint | ( | int | numKey | ) | const |
Get a keypoint
numKey | index of the wanted point |
Definition at line 45 of file PointsMatcher.cpp.
bool OpencvSfM::PointsMatcher::isMaskSupported | ( | ) | [virtual] |
Use this method to know if mask are supported with current matcher
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow.
Definition at line 97 of file PointsMatcher.cpp.
virtual void OpencvSfM::PointsMatcher::knnMatch | ( | cv::Ptr< PointsToTrack > | queryPoints, |
std::vector< std::vector< cv::DMatch > > & | matches, | ||
int | k, | ||
const std::vector< cv::Mat > & | masks = std::vector< cv::Mat >() , |
||
bool | compactResult = true |
||
) | [virtual] |
Find the k best matches for each descriptor from a query set with train descriptors.
queryPoints | Query set of points and descriptors. |
matches | Mathes. Each matches[ i ] is k or less matches for the same query descriptor. |
k | Count of best matches will be found per each query descriptor ( or less if it’s not possible ). |
masks | specifying permissible matches between input query and train matrices of descriptors. |
compactResult | – It’s used when mask ( or masks ) is not empty. If compactResult is false matches vector will have the same size as queryDescriptors rows. If compactResult is true matches vector will not contain matches for fully masked out query descriptors. |
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow, and OpencvSfM::MatcherSparseFlow.
void OpencvSfM::PointsMatcher::match | ( | cv::Ptr< PointsToTrack > | queryPoints, |
std::vector< cv::DMatch > & | matches, | ||
const std::vector< cv::Mat > & | masks = std::vector<cv::Mat>( ) |
||
) | [virtual] |
Find the k best matches for each descriptor from a query set with train descriptors.
queryPoints | Query set of points and descriptors. |
matches | Mathes. If some query descriptor ( keypoint ) masked out in mask no match will be added for this descriptor. So matches size may be less than query keypoints count. |
masks | The set of masks. Each masks[ i ] specifies permissible matches between input query keypoints and stored train keypointss from i-th image. |
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow, and OpencvSfM::MatcherSparseFlow.
Definition at line 102 of file PointsMatcher.cpp.
Referenced by crossMatch().
virtual void OpencvSfM::PointsMatcher::radiusMatch | ( | cv::Ptr< PointsToTrack > | queryPoints, |
std::vector< std::vector< cv::DMatch > > & | matches, | ||
float | maxDistance, | ||
const std::vector< cv::Mat > & | masks = std::vector< cv::Mat >() , |
||
bool | compactResult = true |
||
) | [virtual] |
Find the best matches for each query descriptor which have distance less than given threshold.
queryPoints | Query set of points and descriptors. |
matches | Each matches[ i ] is k or less matches for the same query descriptor. |
maxDistance | The threshold to found match distances. |
masks | specifying permissible matches between input query and train matrices of descriptors. |
compactResult | – It’s used when mask ( or masks ) is not empty. If compactResult is false matches vector will have the same size as queryDescriptors rows. If compactResult is true matches vector will not contain matches for fully masked out query descriptors. |
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow, and OpencvSfM::MatcherSparseFlow.
void OpencvSfM::PointsMatcher::read | ( | const cv::FileNode & | node, |
PointsMatcher & | points | ||
) | [static] |
Load the matches from a YAML file.
node | Previously opened YAML file node |
points | output |
Definition at line 284 of file PointsMatcher.cpp.
void OpencvSfM::PointsMatcher::train | ( | ) | [virtual] |
When using matcher which need training, use this method to start the training.
Reimplemented in OpencvSfM::PointsMatcherOpticalFlow.
Definition at line 69 of file PointsMatcher.cpp.
Referenced by crossMatch(), OpencvSfM::PointsMatcherOpticalFlow::knnMatch(), match(), and OpencvSfM::PointsMatcherOpticalFlow::radiusMatch().
void OpencvSfM::PointsMatcher::write | ( | cv::FileStorage & | fs, |
const PointsMatcher & | points | ||
) | [static] |
Save the matches into a YAML file.
fs | Previously opened YAML file node |
points | sequence to save... |
Definition at line 309 of file PointsMatcher.cpp.