Commit 49102c7e authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #118 from vpisarev/refactor_algorithms2

quickly corrected the previous refactoring of features2d/xfeatures2d
parents 99a5f4cf e2755362
......@@ -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 = ORB::create();
orb->setMaxFeatures(2000);
orb->setScaleFactor(1.15);
orb->setNLevels(30);
detector = orb;
}
detector->detect(img_roi, keypoints);
......
......@@ -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<SURF> 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;
......
......@@ -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; }
......
......@@ -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
......
......@@ -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<SURF> fd = SURF::create();
fd->detect(img, keypoints);
write( fs, "keypoints", keypoints );
}
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