From: Ilya Lysenkov Date: Thu, 31 Jan 2013 21:07:27 +0000 (+0400) Subject: Added info() method in descriptor matchers (#2330) X-Git-Tag: accepted/2.0/20130307.220821~146^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7745c8806c0f6f4b0ad49bcd9c0a58fe94c90c7d;p=profile%2Fivi%2Fopencv.git Added info() method in descriptor matchers (#2330) --- diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst index cf1dab6..533d2e9 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst @@ -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). diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index a205322..e135087 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -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 clone( bool emptyTrainData=false ) const; + AlgorithmInfo* info() const; protected: virtual void knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int k, const vector& masks=vector(), bool compactResult=false ); @@ -1238,6 +1239,7 @@ public: virtual Ptr clone( bool emptyTrainData=false ) const; + AlgorithmInfo* info() const; protected: static void convertToDMatches( const DescriptorCollection& descriptors, const Mat& indices, const Mat& distances, diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index ffac5b4..1e1b0ca 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -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; } diff --git a/modules/features2d/test/test_matchers_algorithmic.cpp b/modules/features2d/test/test_matchers_algorithmic.cpp index a3a5efe..d76715d 100644 --- a/modules/features2d/test/test_matchers_algorithmic.cpp +++ b/modules/features2d/test/test_matchers_algorithmic.cpp @@ -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.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.FlannBasedMatcher"), 0.04f ); test.safe_run(); }