diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 450ba77d0a..75eb028747 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -285,6 +285,18 @@ public: const std::vector &numberList, float dMax=5.85f, float dMin=8.2f, const std::vector& indexChange=std::vector()); CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; + + /** @brief Set detection threshold. + @param threshold AGAST detection threshold score. + */ + CV_WRAP virtual void setThreshold(int threshold) { CV_UNUSED(threshold); return; }; + CV_WRAP virtual int getThreshold() const { return -1; }; + + /** @brief Set detection octaves. + @param octaves detection octaves. Use 0 to do single scale. + */ + CV_WRAP virtual void setOctaves(int octaves) { CV_UNUSED(octaves); return; }; + CV_WRAP virtual int getOctaves() const { return -1; }; }; /** @brief Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index 4038279d75..67c412316a 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -80,6 +80,26 @@ public: return NORM_HAMMING; } + virtual void setThreshold(int threshold_in) CV_OVERRIDE + { + threshold = threshold_in; + } + + virtual int getThreshold() const CV_OVERRIDE + { + return threshold; + } + + virtual void setOctaves(int octaves_in) CV_OVERRIDE + { + octaves = octaves_in; + } + + virtual int getOctaves() const CV_OVERRIDE + { + return octaves; + } + // call this to generate the kernel: // circle of radius r (pixels), with n points; // short pairings with dMax, long pairings with dMin diff --git a/modules/features2d/test/test_brisk.cpp b/modules/features2d/test/test_brisk.cpp index 22f08e59a5..783b694f89 100644 --- a/modules/features2d/test/test_brisk.cpp +++ b/modules/features2d/test/test_brisk.cpp @@ -73,6 +73,18 @@ void CV_BRISKTest::run( int ) Ptr detector = BRISK::create(); + // Check parameter get/set functions. + BRISK* detectorTyped = dynamic_cast(detector.get()); + ASSERT_NE(nullptr, detectorTyped); + detectorTyped->setOctaves(3); + detectorTyped->setThreshold(30); + ASSERT_EQ(detectorTyped->getOctaves(), 3); + ASSERT_EQ(detectorTyped->getThreshold(), 30); + detectorTyped->setOctaves(4); + detectorTyped->setThreshold(29); + ASSERT_EQ(detectorTyped->getOctaves(), 4); + ASSERT_EQ(detectorTyped->getThreshold(), 29); + vector keypoints1; vector keypoints2; detector->detect(image1, keypoints1);