1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

quickly corrected the previous refactoring of features2d: moved from set(SOME_PROP, val) to setSomeProp(val)

This commit is contained in:
Vadim Pisarevsky
2014-10-18 20:44:26 +04:00
parent 22ff1e8826
commit d2b9dc5530
29 changed files with 278 additions and 312 deletions
+110 -21
View File
@@ -163,17 +163,37 @@ public:
class CV_EXPORTS_W ORB : public Feature2D
{
public:
// the size of the signature in bytes
enum
{
kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1,
NFEATURES=10000, SCALE_FACTOR=10001, NLEVELS=10002,
EDGE_THRESHOLD=10003, FIRST_LEVEL=10004, WTA_K=10005,
SCORE_TYPE=10006, PATCH_SIZE=10007, FAST_THRESHOLD=10008
};
enum { kBytes = 32, HARRIS_SCORE=0, FAST_SCORE=1 };
CV_WRAP static Ptr<ORB> create(int nfeatures = 500, float scaleFactor = 1.2f, int nlevels = 8, int edgeThreshold = 31,
int firstLevel = 0, int WTA_K=2, int scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold = 20);
CV_WRAP static Ptr<ORB> create(int nfeatures=500, float scaleFactor=1.2f, int nlevels=8, int edgeThreshold=31,
int firstLevel=0, int WTA_K=2, int scoreType=ORB::HARRIS_SCORE, int patchSize=31, int fastThreshold=20);
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
CV_WRAP virtual int getMaxFeatures() const = 0;
CV_WRAP virtual void setScaleFactor(double scaleFactor) = 0;
CV_WRAP virtual double getScaleFactor() const = 0;
CV_WRAP virtual void setNLevels(int nlevels) = 0;
CV_WRAP virtual int getNLevels() const = 0;
CV_WRAP virtual void setEdgeThreshold(int edgeThreshold) = 0;
CV_WRAP virtual int getEdgeThreshold() const = 0;
CV_WRAP virtual void setFirstLevel(int firstLevel) = 0;
CV_WRAP virtual int getFirstLevel() const = 0;
CV_WRAP virtual void setWTA_K(int wta_k) = 0;
CV_WRAP virtual int getWTA_K() const = 0;
CV_WRAP virtual void setScoreType(int scoreType) = 0;
CV_WRAP virtual int getScoreType() const = 0;
CV_WRAP virtual void setPatchSize(int patchSize) = 0;
CV_WRAP virtual int getPatchSize() const = 0;
CV_WRAP virtual void setFastThreshold(int fastThreshold) = 0;
CV_WRAP virtual int getFastThreshold() const = 0;
};
/*!
@@ -188,13 +208,6 @@ public:
class CV_EXPORTS_W MSER : public Feature2D
{
public:
enum
{
DELTA=10000, MIN_AREA=10001, MAX_AREA=10002, PASS2_ONLY=10003,
MAX_EVOLUTION=10004, AREA_THRESHOLD=10005,
MIN_MARGIN=10006, EDGE_BLUR_SIZE=10007
};
//! the full constructor
CV_WRAP static Ptr<MSER> create( int _delta=5, int _min_area=60, int _max_area=14400,
double _max_variation=0.25, double _min_diversity=.2,
@@ -204,6 +217,18 @@ public:
CV_WRAP virtual void detectRegions( InputArray image,
std::vector<std::vector<Point> >& msers,
std::vector<Rect>& bboxes ) = 0;
CV_WRAP virtual void setDelta(int delta) = 0;
CV_WRAP virtual int getDelta() const = 0;
CV_WRAP virtual void setMinArea(int minArea) = 0;
CV_WRAP virtual int getMinArea() const = 0;
CV_WRAP virtual void setMaxArea(int maxArea) = 0;
CV_WRAP virtual int getMaxArea() const = 0;
CV_WRAP virtual void setPass2Only(bool f) = 0;
CV_WRAP virtual bool getPass2Only() const = 0;
};
//! detects corners using FAST algorithm by E. Rosten
@@ -225,15 +250,40 @@ public:
CV_WRAP static Ptr<FastFeatureDetector> create( int threshold=10,
bool nonmaxSuppression=true,
int type=FastFeatureDetector::TYPE_9_16 );
CV_WRAP virtual void setThreshold(int threshold) = 0;
CV_WRAP virtual int getThreshold() const = 0;
CV_WRAP virtual void setNonmaxSuppression(bool f) = 0;
CV_WRAP virtual bool getNonmaxSuppression() const = 0;
CV_WRAP virtual void setType(int type) = 0;
CV_WRAP virtual int getType() const = 0;
};
class CV_EXPORTS_W GFTTDetector : public Feature2D
{
public:
enum { USE_HARRIS_DETECTOR=10000 };
CV_WRAP static Ptr<GFTTDetector> create( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1,
int blockSize=3, bool useHarrisDetector=false, double k=0.04 );
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
CV_WRAP virtual int getMaxFeatures() const = 0;
CV_WRAP virtual void setQualityLevel(double qlevel) = 0;
CV_WRAP virtual double getQualityLevel() const = 0;
CV_WRAP virtual void setMinDistance(double minDistance) = 0;
CV_WRAP virtual double getMinDistance() const = 0;
CV_WRAP virtual void setBlockSize(int blockSize) = 0;
CV_WRAP virtual int getBlockSize() const = 0;
CV_WRAP virtual void setHarrisDetector(bool val) = 0;
CV_WRAP virtual bool getHarrisDetector() const = 0;
CV_WRAP virtual void setK(double k) = 0;
CV_WRAP virtual double getK() const = 0;
};
@@ -289,8 +339,26 @@ public:
CV_WRAP static Ptr<KAZE> create(bool extended=false, bool upright=false,
float threshold = 0.001f,
int octaves = 4, int sublevels = 4,
int nOctaves = 4, int nOctaveLayers = 4,
int diffusivity = KAZE::DIFF_PM_G2);
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;
CV_WRAP virtual void setThreshold(double threshold) = 0;
CV_WRAP virtual double getThreshold() const = 0;
CV_WRAP virtual void setNOctaves(int octaves) = 0;
CV_WRAP virtual int getNOctaves() const = 0;
CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0;
CV_WRAP virtual int getNOctaveLayers() const = 0;
CV_WRAP virtual void setDiffusivity(int diff) = 0;
CV_WRAP virtual int getDiffusivity() const = 0;
};
/*!
@@ -310,8 +378,29 @@ public:
CV_WRAP static Ptr<AKAZE> create(int descriptor_type=AKAZE::DESCRIPTOR_MLDB,
int descriptor_size = 0, int descriptor_channels = 3,
float threshold = 0.001f, int octaves = 4,
int sublevels = 4, int diffusivity = KAZE::DIFF_PM_G2);
float threshold = 0.001f, int nOctaves = 4,
int nOctaveLayers = 4, int diffusivity = KAZE::DIFF_PM_G2);
CV_WRAP virtual void setDescriptorType(int dtype) = 0;
CV_WRAP virtual int getDescriptorType() const = 0;
CV_WRAP virtual void setDescriptorSize(int dsize) = 0;
CV_WRAP virtual int getDescriptorSize() const = 0;
CV_WRAP virtual void setDescriptorChannels(int dch) = 0;
CV_WRAP virtual int getDescriptorChannels() const = 0;
CV_WRAP virtual void setThreshold(double threshold) = 0;
CV_WRAP virtual double getThreshold() const = 0;
CV_WRAP virtual void setNOctaves(int octaves) = 0;
CV_WRAP virtual int getNOctaves() const = 0;
CV_WRAP virtual void setNOctaveLayers(int octaveLayers) = 0;
CV_WRAP virtual int getNOctaveLayers() const = 0;
CV_WRAP virtual void setDiffusivity(int diff) = 0;
CV_WRAP virtual int getDiffusivity() const = 0;
};
/****************************************************************************************\
+21
View File
@@ -77,6 +77,27 @@ namespace cv
}
void setDescriptorType(int dtype) { descriptor = dtype; }
int getDescriptorType() const { return descriptor; }
void setDescriptorSize(int dsize) { descriptor_size = dsize; }
int getDescriptorSize() const { return descriptor_size; }
void setDescriptorChannels(int dch) { descriptor_channels = dch; }
int getDescriptorChannels() const { return descriptor_channels; }
void setThreshold(double threshold_) { threshold = threshold_; }
double getThreshold() const { return threshold; }
void setNOctaves(int octaves_) { octaves = octaves_; }
int getNOctaves() const { return octaves; }
void setNOctaveLayers(int octaveLayers_) { sublevels = octaveLayers_; }
int getNOctaveLayers() const { return sublevels; }
void setDiffusivity(int diff_) { diffusivity = diff_; }
int getDiffusivity() const { return diffusivity; }
// returns the descriptor size in bytes
int descriptorSize() const
{
+1 -1
View File
@@ -2099,7 +2099,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode)
void
BriskLayer::getAgastPoints(int threshold, std::vector<KeyPoint>& keypoints)
{
fast_9_16_->set(FastFeatureDetector::THRESHOLD, threshold);
fast_9_16_->setThreshold(threshold);
fast_9_16_->detect(img_, keypoints);
// also write scores
+9
View File
@@ -407,6 +407,15 @@ public:
return 0;
}
void setThreshold(int threshold_) { threshold = threshold_; }
int getThreshold() const { return threshold; }
void setNonmaxSuppression(bool f) { nonmaxSuppression = f; }
bool getNonmaxSuppression() const { return nonmaxSuppression; }
void setType(int type_) { type = type_; }
int getType() const { return type; }
int threshold;
bool nonmaxSuppression;
int type;
+16 -16
View File
@@ -55,23 +55,23 @@ public:
{
}
void set(int prop, double value)
{
if( prop == USE_HARRIS_DETECTOR )
useHarrisDetector = value != 0;
else
CV_Error(Error::StsBadArg, "");
}
void setMaxFeatures(int maxFeatures) { nfeatures = maxFeatures; }
int getMaxFeatures() const { return nfeatures; }
double get(int prop) const
{
double value = 0;
if( prop == USE_HARRIS_DETECTOR )
value = useHarrisDetector;
else
CV_Error(Error::StsBadArg, "");
return value;
}
void setQualityLevel(double qlevel) { qualityLevel = qlevel; }
double getQualityLevel() const { return qualityLevel; }
void setMinDistance(double minDistance_) { minDistance = minDistance_; }
double getMinDistance() const { return minDistance; }
void setBlockSize(int blockSize_) { blockSize = blockSize_; }
int getBlockSize() const { return blockSize; }
void setHarrisDetector(bool val) { useHarrisDetector = val; }
bool getHarrisDetector() const { return useHarrisDetector; }
void setK(double k_) { k = k_; }
double getK() const { return k; }
void detect( InputArray _image, std::vector<KeyPoint>& keypoints, InputArray _mask )
{
+18
View File
@@ -69,6 +69,24 @@ namespace cv
virtual ~KAZE_Impl() {}
void setExtended(bool extended_) { extended = extended_; }
bool getExtended() const { return extended; }
void setUpright(bool upright_) { upright = upright_; }
bool getUpright() const { return upright; }
void setThreshold(double threshold_) { threshold = threshold_; }
double getThreshold() const { return threshold; }
void setNOctaves(int octaves_) { octaves = octaves_; }
int getNOctaves() const { return octaves; }
void setNOctaveLayers(int octaveLayers_) { sublevels = octaveLayers_; }
int getNOctaveLayers() const { return sublevels; }
void setDiffusivity(int diff_) { diffusivity = diff_; }
int getDiffusivity() const { return diffusivity; }
// returns the descriptor size in bytes
int descriptorSize() const
{
+10 -28
View File
@@ -86,35 +86,17 @@ public:
virtual ~MSER_Impl() {}
void set(int propId, double value)
{
if( propId == DELTA )
params.delta = cvRound(value);
else if( propId == MIN_AREA )
params.minArea = cvRound(value);
else if( propId == MAX_AREA )
params.maxArea = cvRound(value);
else if( propId == PASS2_ONLY )
params.pass2Only = value != 0;
else
CV_Error(CV_StsBadArg, "Unknown parameter id");
}
void setDelta(int delta) { params.delta = delta; }
int getDelta() const { return params.delta; }
double get(int propId) const
{
double value = 0;
if( propId == DELTA )
value = params.delta;
else if( propId == MIN_AREA )
value = params.minArea;
else if( propId == MAX_AREA )
value = params.maxArea;
else if( propId == PASS2_ONLY )
value = params.pass2Only;
else
CV_Error(CV_StsBadArg, "Unknown parameter id");
return value;
}
void setMinArea(int minArea) { params.minArea = minArea; }
int getMinArea() const { return params.minArea; }
void setMaxArea(int maxArea) { params.maxArea = maxArea; }
int getMaxArea() const { return params.maxArea; }
void setPass2Only(bool f) { params.pass2Only = f; }
bool getPass2Only() const { return params.pass2Only; }
enum { DIR_SHIFT = 29, NEXT_MASK = ((1<<DIR_SHIFT)-1) };
+25 -48
View File
@@ -660,55 +660,32 @@ public:
scoreType(_scoreType), patchSize(_patchSize), fastThreshold(_fastThreshold)
{}
void set(int prop, double value)
{
if( prop == NFEATURES )
nfeatures = cvRound(value);
else if( prop == SCALE_FACTOR )
scaleFactor = value;
else if( prop == NLEVELS )
nlevels = cvRound(value);
else if( prop == EDGE_THRESHOLD )
edgeThreshold = cvRound(value);
else if( prop == FIRST_LEVEL )
firstLevel = cvRound(value);
else if( prop == WTA_K )
wta_k = cvRound(value);
else if( prop == SCORE_TYPE )
scoreType = cvRound(value);
else if( prop == PATCH_SIZE )
patchSize = cvRound(value);
else if( prop == FAST_THRESHOLD )
fastThreshold = cvRound(value);
else
CV_Error(Error::StsBadArg, "");
}
void setMaxFeatures(int maxFeatures) { nfeatures = maxFeatures; }
int getMaxFeatures() const { return nfeatures; }
double get(int prop) const
{
double value = 0;
if( prop == NFEATURES )
value = nfeatures;
else if( prop == SCALE_FACTOR )
value = scaleFactor;
else if( prop == NLEVELS )
value = nlevels;
else if( prop == EDGE_THRESHOLD )
value = edgeThreshold;
else if( prop == FIRST_LEVEL )
value = firstLevel;
else if( prop == WTA_K )
value = wta_k;
else if( prop == SCORE_TYPE )
value = scoreType;
else if( prop == PATCH_SIZE )
value = patchSize;
else if( prop == FAST_THRESHOLD )
value = fastThreshold;
else
CV_Error(Error::StsBadArg, "");
return value;
}
void setScaleFactor(double scaleFactor_) { scaleFactor = scaleFactor_; }
double getScaleFactor() const { return scaleFactor; }
void setNLevels(int nlevels_) { nlevels = nlevels_; }
int getNLevels() const { return nlevels; }
void setEdgeThreshold(int edgeThreshold_) { edgeThreshold = edgeThreshold_; }
int getEdgeThreshold() const { return edgeThreshold; }
void setFirstLevel(int firstLevel_) { firstLevel = firstLevel_; }
int getFirstLevel() const { return firstLevel; }
void setWTA_K(int wta_k_) { wta_k = wta_k_; }
int getWTA_K() const { return wta_k; }
void setScoreType(int scoreType_) { scoreType = scoreType_; }
int getScoreType() const { return scoreType; }
void setPatchSize(int patchSize_) { patchSize = patchSize_; }
int getPatchSize() const { return patchSize; }
void setFastThreshold(int fastThreshold_) { fastThreshold = fastThreshold_; }
int getFastThreshold() const { return fastThreshold; }
// returns the descriptor size in bytes
int descriptorSize() const;
@@ -255,8 +255,8 @@ protected:
fs.open( string(ts->get_data_path()) + FEATURES2D_DIR + "/keypoints.xml.gz", FileStorage::WRITE );
if( fs.isOpened() )
{
ORB fd;
fd.detect(img, keypoints);
Ptr<ORB> fd = ORB::create();
fd->detect(img, keypoints);
write( fs, "keypoints", keypoints );
}
else
@@ -267,8 +267,8 @@ TEST( Features2d_Detector_GFTT, regression )
TEST( Features2d_Detector_Harris, regression )
{
Ptr<FeatureDetector> gftt = GFTTDetector::create();
gftt->set(GFTTDetector::USE_HARRIS_DETECTOR, 1);
Ptr<GFTTDetector> gftt = GFTTDetector::create();
gftt->setHarrisDetector(true);
CV_FeatureDetectorTest test( "detector-harris", gftt);
test.safe_run();
}
+2 -2
View File
@@ -140,8 +140,8 @@ TEST(Features2d_Detector_Keypoints_HARRIS, validation)
TEST(Features2d_Detector_Keypoints_GFTT, validation)
{
Ptr<FeatureDetector> gftt = GFTTDetector::create();
gftt->set(GFTTDetector::USE_HARRIS_DETECTOR, 1);
Ptr<GFTTDetector> gftt = GFTTDetector::create();
gftt->setHarrisDetector(true);
CV_FeatureDetectorKeypointsTest test(gftt);
test.safe_run();
}