wrapped FlannBasedMatcher (and extended DescriptorMatcher wrapper)

updated feature_homography.py sample to use new features
This commit is contained in:
Alexander Mordvintsev
2011-09-15 11:10:06 +00:00
parent d174c3db04
commit 028c44531f
4 changed files with 62 additions and 27 deletions

View File

@@ -2237,24 +2237,24 @@ public:
* Add descriptors to train descriptor collection.
* descriptors Descriptors to add. Each descriptors[i] is a descriptors set from one image.
*/
virtual void add( const vector<Mat>& descriptors );
CV_WRAP virtual void add( const vector<Mat>& descriptors );
/*
* Get train descriptors collection.
*/
const vector<Mat>& getTrainDescriptors() const;
CV_WRAP const vector<Mat>& getTrainDescriptors() const;
/*
* Clear train descriptors collection.
*/
virtual void clear();
CV_WRAP virtual void clear();
/*
* Return true if there are not train descriptors in collection.
*/
virtual bool empty() const;
CV_WRAP virtual bool empty() const;
/*
* Return true if the matcher supports mask in match methods.
*/
virtual bool isMaskSupported() const = 0;
CV_WRAP virtual bool isMaskSupported() const = 0;
/*
* Train matcher (e.g. train flann index).
@@ -2267,7 +2267,7 @@ public:
* if it has not trained yet or if new descriptors have been added to the train
* collection).
*/
virtual void train();
CV_WRAP virtual void train();
/*
* Group of methods to match descriptors from image pair.
* Method train() is run in this methods.
@@ -2291,9 +2291,9 @@ public:
* Group of methods to match descriptors from one image to image set.
* See description of similar methods for matching image pair above.
*/
void match( const Mat& queryDescriptors, vector<DMatch>& matches,
CV_WRAP void match( const Mat& queryDescriptors, CV_OUT vector<DMatch>& matches,
const vector<Mat>& masks=vector<Mat>() );
void knnMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT vector<vector<DMatch> >& matches, int k,
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
void radiusMatch( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, float maxDistance,
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
@@ -2562,10 +2562,10 @@ void BruteForceMatcher<L2<float> >::radiusMatchImpl( const Mat& queryDescriptors
/*
* Flann based matcher
*/
class CV_EXPORTS FlannBasedMatcher : public DescriptorMatcher
class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher
{
public:
FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=new flann::KDTreeIndexParams(),
CV_WRAP FlannBasedMatcher( const Ptr<flann::IndexParams>& indexParams=new flann::KDTreeIndexParams(),
const Ptr<flann::SearchParams>& searchParams=new flann::SearchParams() );
virtual void add( const vector<Mat>& descriptors );

View File

@@ -74,6 +74,11 @@ typedef Ptr<FeatureDetector> Ptr_FeatureDetector;
typedef Ptr<DescriptorExtractor> Ptr_DescriptorExtractor;
typedef Ptr<DescriptorMatcher> Ptr_DescriptorMatcher;
typedef cvflann::flann_distance_t cvflann_flann_distance_t;
typedef cvflann::flann_algorithm_t cvflann_flann_algorithm_t;
typedef Ptr<flann::IndexParams> Ptr_flann_IndexParams;
typedef Ptr<flann::SearchParams> Ptr_flann_SearchParams;
static PyObject* failmsgp(const char *fmt, ...)
{
char str[1000];
@@ -820,6 +825,14 @@ static bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name
return ok;
}
template <class T>
static bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name="<unknown>")
{
p = new T();
return pyopencv_to(o, *p, name);
}
static bool pyopencv_to(PyObject *o, cvflann::flann_distance_t& dist, const char *name="<unknown>")
{
int d = (int)dist;

View File

@@ -191,7 +191,7 @@ class CppHeaderParser(object):
if add_star:
arg_type += "*"
arg_type = self.batch_replace(arg_type, [("std::", ""), ("cv::", "")])
arg_type = self.batch_replace(arg_type, [("std::", ""), ("cv::", ""), ("::", "_")])
return arg_type, arg_name, modlist, argno