Commit e2755362 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

quickly corrected the previous refactoring of features2d/xfeatures2d: moved from…

quickly corrected the previous refactoring of features2d/xfeatures2d: moved from set(SOME_PROP, val) to setSomeProp(val)
parent 99a5f4cf
...@@ -93,10 +93,11 @@ bool CustomPattern::init(Mat& image, const float pixel_size, OutputArray output) ...@@ -93,10 +93,11 @@ bool CustomPattern::init(Mat& image, const float pixel_size, OutputArray output)
if (!detector) // if no detector chosen, use default if (!detector) // if no detector chosen, use default
{ {
detector = ORB::create(); Ptr<ORB> orb = ORB::create();
detector->set(ORB::NFEATURES, 2000); orb->setMaxFeatures(2000);
detector->set(ORB::SCALE_FACTOR, 1.15); orb->setScaleFactor(1.15);
detector->set(ORB::NLEVELS, 30); orb->setNLevels(30);
detector = orb;
} }
detector->detect(img_roi, keypoints); detector->detect(img_roi, keypoints);
......
...@@ -74,10 +74,24 @@ typedef SIFT SiftDescriptorExtractor; ...@@ -74,10 +74,24 @@ typedef SIFT SiftDescriptorExtractor;
class CV_EXPORTS_W SURF : public Feature2D class CV_EXPORTS_W SURF : public Feature2D
{ {
public: public:
enum { HESSIAN_THRESHOLD = 10000, NOCTAVES=10001, NOCTAVE_LAYERS=10002, EXTENDED=10003, UPRIGHT=10004 };
CV_WRAP static Ptr<SURF> create(double hessianThreshold=100, CV_WRAP static Ptr<SURF> create(double hessianThreshold=100,
int nOctaves = 4, int nOctaveLayers = 3, int nOctaves = 4, int nOctaveLayers = 3,
bool extended = false, bool upright = false); 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; typedef SURF SurfFeatureDetector;
......
...@@ -876,40 +876,6 @@ SURF_Impl::SURF_Impl(double _threshold, int _nOctaves, int _nOctaveLayers, bool ...@@ -876,40 +876,6 @@ SURF_Impl::SURF_Impl(double _threshold, int _nOctaves, int _nOctaveLayers, bool
nOctaveLayers = _nOctaveLayers; 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::descriptorSize() const { return extended ? 128 : 64; }
int SURF_Impl::descriptorType() const { return CV_32F; } int SURF_Impl::descriptorType() const { return CV_32F; }
int SURF_Impl::defaultNorm() const { return NORM_L2; } int SURF_Impl::defaultNorm() const { return NORM_L2; }
......
...@@ -42,11 +42,26 @@ public: ...@@ -42,11 +42,26 @@ public:
OutputArray descriptors, OutputArray descriptors,
bool useProvidedKeypoints = false); bool useProvidedKeypoints = false);
CV_PROP_RW double hessianThreshold; void setHessianThreshold(double hessianThreshold_) { hessianThreshold = hessianThreshold_; }
CV_PROP_RW int nOctaves; double getHessianThreshold() const { return hessianThreshold; }
CV_PROP_RW int nOctaveLayers;
CV_PROP_RW bool extended; void setNOctaves(int nOctaves_) { nOctaves = nOctaves_; }
CV_PROP_RW bool upright; 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 class SURF_OCL
......
...@@ -449,8 +449,8 @@ protected: ...@@ -449,8 +449,8 @@ protected:
fs.open( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::WRITE ); fs.open( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::WRITE );
if( fs.isOpened() ) if( fs.isOpened() )
{ {
SurfFeatureDetector fd; Ptr<SURF> fd = SURF::create();
fd.detect(img, keypoints); fd->detect(img, keypoints);
write( fs, "keypoints", keypoints ); write( fs, "keypoints", keypoints );
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment