Skip to content

Commit ef42baf

Browse files
okriofalalek
authored andcommitted
Merge pull request opencv#13361 from okriof:brisk_getset
* Get/Set functions for BRISK parameters, issue opencv#11527. Allows setting threshold and octaves parameters after creating a brisk object. These parameters do not affect the initial pattern initialization and can be changed later without re-initialization. * Fix doc parameter name. * Brisk get/set functions tests. Check for correct value and make tests independent of default parameter values. * Add dummy implementations for BRISK get/set functions not to break API in case someone has overloaded the Feature2d::BRISK interface. This makes BRISK different from the other detectors/descriptors on the other hand, where get/set functions are pure virtual in the interface.
1 parent e55ad25 commit ef42baf

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

modules/features2d/include/opencv2/features2d.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,18 @@ class CV_EXPORTS_W BRISK : public Feature2D
285285
const std::vector<int> &numberList, float dMax=5.85f, float dMin=8.2f,
286286
const std::vector<int>& indexChange=std::vector<int>());
287287
CV_WRAP virtual String getDefaultName() const CV_OVERRIDE;
288+
289+
/** @brief Set detection threshold.
290+
@param threshold AGAST detection threshold score.
291+
*/
292+
CV_WRAP virtual void setThreshold(int threshold) { CV_UNUSED(threshold); return; };
293+
CV_WRAP virtual int getThreshold() const { return -1; };
294+
295+
/** @brief Set detection octaves.
296+
@param octaves detection octaves. Use 0 to do single scale.
297+
*/
298+
CV_WRAP virtual void setOctaves(int octaves) { CV_UNUSED(octaves); return; };
299+
CV_WRAP virtual int getOctaves() const { return -1; };
288300
};
289301

290302
/** @brief Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor

modules/features2d/src/brisk.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ class BRISK_Impl CV_FINAL : public BRISK
8080
return NORM_HAMMING;
8181
}
8282

83+
virtual void setThreshold(int threshold_in) CV_OVERRIDE
84+
{
85+
threshold = threshold_in;
86+
}
87+
88+
virtual int getThreshold() const CV_OVERRIDE
89+
{
90+
return threshold;
91+
}
92+
93+
virtual void setOctaves(int octaves_in) CV_OVERRIDE
94+
{
95+
octaves = octaves_in;
96+
}
97+
98+
virtual int getOctaves() const CV_OVERRIDE
99+
{
100+
return octaves;
101+
}
102+
83103
// call this to generate the kernel:
84104
// circle of radius r (pixels), with n points;
85105
// short pairings with dMax, long pairings with dMin

modules/features2d/test/test_brisk.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ void CV_BRISKTest::run( int )
7373

7474
Ptr<FeatureDetector> detector = BRISK::create();
7575

76+
// Check parameter get/set functions.
77+
BRISK* detectorTyped = dynamic_cast<BRISK*>(detector.get());
78+
ASSERT_NE(nullptr, detectorTyped);
79+
detectorTyped->setOctaves(3);
80+
detectorTyped->setThreshold(30);
81+
ASSERT_EQ(detectorTyped->getOctaves(), 3);
82+
ASSERT_EQ(detectorTyped->getThreshold(), 30);
83+
detectorTyped->setOctaves(4);
84+
detectorTyped->setThreshold(29);
85+
ASSERT_EQ(detectorTyped->getOctaves(), 4);
86+
ASSERT_EQ(detectorTyped->getThreshold(), 29);
87+
7688
vector<KeyPoint> keypoints1;
7789
vector<KeyPoint> keypoints2;
7890
detector->detect(image1, keypoints1);

0 commit comments

Comments
 (0)