Added info() method in descriptor matchers (#2330)
authorIlya Lysenkov <lysenkov.ilya@gmail.com>
Thu, 31 Jan 2013 21:07:27 +0000 (01:07 +0400)
committerIlya Lysenkov <lysenkov.ilya@gmail.com>
Thu, 31 Jan 2013 22:23:40 +0000 (02:23 +0400)
modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst
modules/features2d/include/opencv2/features2d/features2d.hpp
modules/features2d/src/features2d_init.cpp
modules/features2d/test/test_matchers_algorithmic.cpp

index cf1dab6..533d2e9 100644 (file)
@@ -267,7 +267,7 @@ BFMatcher::BFMatcher
 --------------------
 Brute-force matcher constructor.
 
-.. ocv:function:: BFMatcher::BFMatcher( int normType, bool crossCheck=false )
+.. ocv:function:: BFMatcher::BFMatcher( int normType=NORM_L2, bool crossCheck=false )
 
     :param normType: One of ``NORM_L1``, ``NORM_L2``, ``NORM_HAMMING``, ``NORM_HAMMING2``. ``L1`` and ``L2`` norms are preferable choices for SIFT and SURF descriptors, ``NORM_HAMMING`` should be used with ORB and BRIEF, ``NORM_HAMMING2`` should be used with ORB when ``WTA_K==3`` or ``4`` (see ORB::ORB constructor description).
 
index a205322..e135087 100644 (file)
@@ -1198,13 +1198,14 @@ protected:
 class CV_EXPORTS_W BFMatcher : public DescriptorMatcher
 {
 public:
-    CV_WRAP BFMatcher( int normType, bool crossCheck=false );
+    CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
     virtual ~BFMatcher() {}
 
     virtual bool isMaskSupported() const { return true; }
 
     virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
 
+    AlgorithmInfo* info() const;
 protected:
     virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
            const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
@@ -1238,6 +1239,7 @@ public:
 
     virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
 
+    AlgorithmInfo* info() const;
 protected:
     static void convertToDMatches( const DescriptorCollection& descriptors,
                                    const Mat& indices, const Mat& distances,
index ffac5b4..1e1b0ca 100644 (file)
@@ -166,6 +166,16 @@ CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
                   obj.info()->addParam(obj, "gridRows", obj.gridRows);
                   obj.info()->addParam(obj, "gridCols", obj.gridCols));
 
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+CV_INIT_ALGORITHM(BFMatcher, "DescriptorMatcher.BFMatcher",
+                  obj.info()->addParam(obj, "normType", obj.normType);
+                  obj.info()->addParam(obj, "crossCheck", obj.crossCheck));
+
+CV_INIT_ALGORITHM(FlannBasedMatcher, "DescriptorMatcher.FlannBasedMatcher",);
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 bool cv::initModule_features2d(void)
 {
     bool all = true;
@@ -181,6 +191,8 @@ bool cv::initModule_features2d(void)
     all &= !HarrisDetector_info_auto.name().empty();
     all &= !DenseFeatureDetector_info_auto.name().empty();
     all &= !GridAdaptedFeatureDetector_info_auto.name().empty();
+    all &= !BFMatcher_info_auto.name().empty();
+    all &= !FlannBasedMatcher_info_auto.name().empty();
 
     return all;
 }
index a3a5efe..d76715d 100644 (file)
@@ -532,12 +532,12 @@ void CV_DescriptorMatcherTest::run( int )
 
 TEST( Features2d_DescriptorMatcher_BruteForce, regression )
 {
-    CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", new BFMatcher(NORM_L2), 0.01f );
+    CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.BFMatcher"), 0.01f );
     test.safe_run();
 }
 
 TEST( Features2d_DescriptorMatcher_FlannBased, regression )
 {
-    CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", new FlannBasedMatcher, 0.04f );
+    CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.FlannBasedMatcher"), 0.04f );
     test.safe_run();
 }