From e2755362e1957c214eb873f82f7f389aa60c431d Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sat, 18 Oct 2014 20:46:17 +0400 Subject: [PATCH] quickly corrected the previous refactoring of features2d/xfeatures2d: moved from set(SOME_PROP, val) to setSomeProp(val) --- modules/ccalib/src/ccalib.cpp | 9 ++--- .../include/opencv2/xfeatures2d/nonfree.hpp | 16 ++++++++- modules/xfeatures2d/src/surf.cpp | 34 ------------------- modules/xfeatures2d/src/surf.hpp | 25 +++++++++++--- modules/xfeatures2d/test/test_features2d.cpp | 4 +-- 5 files changed, 42 insertions(+), 46 deletions(-) diff --git a/modules/ccalib/src/ccalib.cpp b/modules/ccalib/src/ccalib.cpp index dc7b9d34c..efb5bdf25 100644 --- a/modules/ccalib/src/ccalib.cpp +++ b/modules/ccalib/src/ccalib.cpp @@ -93,10 +93,11 @@ bool CustomPattern::init(Mat& image, const float pixel_size, OutputArray output) if (!detector) // if no detector chosen, use default { - detector = ORB::create(); - detector->set(ORB::NFEATURES, 2000); - detector->set(ORB::SCALE_FACTOR, 1.15); - detector->set(ORB::NLEVELS, 30); + Ptr orb = ORB::create(); + orb->setMaxFeatures(2000); + orb->setScaleFactor(1.15); + orb->setNLevels(30); + detector = orb; } detector->detect(img_roi, keypoints); diff --git a/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp b/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp index 412818abd..6278bb246 100644 --- a/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp +++ b/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp @@ -74,10 +74,24 @@ typedef SIFT SiftDescriptorExtractor; class CV_EXPORTS_W SURF : public Feature2D { public: - enum { HESSIAN_THRESHOLD = 10000, NOCTAVES=10001, NOCTAVE_LAYERS=10002, EXTENDED=10003, UPRIGHT=10004 }; CV_WRAP static Ptr create(double hessianThreshold=100, int nOctaves = 4, int nOctaveLayers = 3, bool extended = false, bool upright = false); + + CV_WRAP virtual void setHessianThreshold(double hessianThreshold) = 0; + CV_WRAP virtual double getHessianThreshold() const = 0; + + CV_WRAP virtual void setNOctaves(int nOctaves) = 0; + CV_WRAP virtual int getNOctaves() const = 0; + + CV_WRAP virtual void setNOctaveLayers(int nOctaveLayers) = 0; + CV_WRAP virtual int getNOctaveLayers() const = 0; + + CV_WRAP virtual void setExtended(bool extended) = 0; + CV_WRAP virtual bool getExtended() const = 0; + + CV_WRAP virtual void setUpright(bool upright) = 0; + CV_WRAP virtual bool getUpright() const = 0; }; typedef SURF SurfFeatureDetector; diff --git a/modules/xfeatures2d/src/surf.cpp b/modules/xfeatures2d/src/surf.cpp index 00f3a37ca..673817e73 100644 --- a/modules/xfeatures2d/src/surf.cpp +++ b/modules/xfeatures2d/src/surf.cpp @@ -876,40 +876,6 @@ SURF_Impl::SURF_Impl(double _threshold, int _nOctaves, int _nOctaveLayers, bool nOctaveLayers = _nOctaveLayers; } -void SURF_Impl::set(int prop, double value) -{ - if( prop == HESSIAN_THRESHOLD ) - hessianThreshold = value; - else if( prop == NOCTAVES ) - nOctaves = cvRound(value); - else if( prop == NOCTAVE_LAYERS ) - nOctaveLayers = cvRound(value); - else if( prop == EXTENDED ) - extended = value != 0; - else if( prop == UPRIGHT ) - upright = value != 0; - else - CV_Error(Error::StsBadArg, ""); -} - -double SURF_Impl::get(int prop) const -{ - double value = 0; - if( prop == HESSIAN_THRESHOLD ) - value = hessianThreshold; - else if( prop == NOCTAVES ) - value = nOctaves; - else if( prop == NOCTAVE_LAYERS ) - value = nOctaveLayers; - else if( prop == EXTENDED ) - value = extended; - else if( prop == UPRIGHT ) - value = upright; - else - CV_Error(Error::StsBadArg, ""); - return value; -} - int SURF_Impl::descriptorSize() const { return extended ? 128 : 64; } int SURF_Impl::descriptorType() const { return CV_32F; } int SURF_Impl::defaultNorm() const { return NORM_L2; } diff --git a/modules/xfeatures2d/src/surf.hpp b/modules/xfeatures2d/src/surf.hpp index 5a52be345..2c4e271f2 100644 --- a/modules/xfeatures2d/src/surf.hpp +++ b/modules/xfeatures2d/src/surf.hpp @@ -42,11 +42,26 @@ public: OutputArray descriptors, bool useProvidedKeypoints = false); - CV_PROP_RW double hessianThreshold; - CV_PROP_RW int nOctaves; - CV_PROP_RW int nOctaveLayers; - CV_PROP_RW bool extended; - CV_PROP_RW bool upright; + void setHessianThreshold(double hessianThreshold_) { hessianThreshold = hessianThreshold_; } + double getHessianThreshold() const { return hessianThreshold; } + + void setNOctaves(int nOctaves_) { nOctaves = nOctaves_; } + int getNOctaves() const { return nOctaves; } + + void setNOctaveLayers(int nOctaveLayers_) { nOctaveLayers = nOctaveLayers_; } + int getNOctaveLayers() const { return nOctaveLayers; } + + void setExtended(bool extended_) { extended = extended_; } + bool getExtended() const { return extended; } + + void setUpright(bool upright_) { upright = upright_; } + bool getUpright() const { return upright; } + + double hessianThreshold; + int nOctaves; + int nOctaveLayers; + bool extended; + bool upright; }; class SURF_OCL diff --git a/modules/xfeatures2d/test/test_features2d.cpp b/modules/xfeatures2d/test/test_features2d.cpp index 3b14fc31f..d5f001ce1 100644 --- a/modules/xfeatures2d/test/test_features2d.cpp +++ b/modules/xfeatures2d/test/test_features2d.cpp @@ -449,8 +449,8 @@ protected: fs.open( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::WRITE ); if( fs.isOpened() ) { - SurfFeatureDetector fd; - fd.detect(img, keypoints); + Ptr fd = SURF::create(); + fd->detect(img, keypoints); write( fs, "keypoints", keypoints ); } else