diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 4fd2a171a6f4..8d9993dfec36 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -474,30 +474,6 @@ class CV_EXPORTS_W FastFeatureDetector : public Feature2D CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; }; -/** @overload */ -CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, - int threshold, bool nonmaxSuppression=true ); - -/** @brief Detects corners using the AGAST algorithm - -@param image grayscale image where keypoints (corners) are detected. -@param keypoints keypoints detected on the image. -@param threshold threshold on difference between intensity of the central pixel and pixels of a -circle around this pixel. -@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners -(keypoints). -@param type one of the four neighborhoods as defined in the paper: -AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, -AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16 - -For non-Intel platforms, there is a tree optimised variant of AGAST with same numerical results. -The 32-bit binary tree tables were generated automatically from original code using perl script. -The perl script and examples of tree generation are placed in features2d/doc folder. -Detects corners using the AGAST algorithm by @cite mair2010_agast . - - */ -CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, - int threshold, bool nonmaxSuppression, int type ); //! @} features2d_main //! @addtogroup features2d_main @@ -508,15 +484,19 @@ CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints class CV_EXPORTS_W AgastFeatureDetector : public Feature2D { public: - enum + enum DetectorType { AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3, + }; + + enum + { THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001, }; CV_WRAP static Ptr create( int threshold=10, bool nonmaxSuppression=true, - int type=AgastFeatureDetector::OAST_9_16 ); + AgastFeatureDetector::DetectorType type = AgastFeatureDetector::OAST_9_16); CV_WRAP virtual void setThreshold(int threshold) = 0; CV_WRAP virtual int getThreshold() const = 0; @@ -524,11 +504,36 @@ class CV_EXPORTS_W AgastFeatureDetector : public Feature2D 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; + CV_WRAP virtual void setType(AgastFeatureDetector::DetectorType type) = 0; + CV_WRAP virtual AgastFeatureDetector::DetectorType getType() const = 0; CV_WRAP virtual String getDefaultName() const CV_OVERRIDE; }; +/** @overload */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression=true ); + +/** @brief Detects corners using the AGAST algorithm + +@param image grayscale image where keypoints (corners) are detected. +@param keypoints keypoints detected on the image. +@param threshold threshold on difference between intensity of the central pixel and pixels of a +circle around this pixel. +@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners +(keypoints). +@param type one of the four neighborhoods as defined in the paper: +AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d, +AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16 + +For non-Intel platforms, there is a tree optimised variant of AGAST with same numerical results. +The 32-bit binary tree tables were generated automatically from original code using perl script. +The perl script and examples of tree generation are placed in features2d/doc folder. +Detects corners using the AGAST algorithm by @cite mair2010_agast . + + */ +CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector& keypoints, + int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type ); + /** @brief Wrapping class for feature detection using the goodFeaturesToTrack function. : */ class CV_EXPORTS_W GFTTDetector : public Feature2D diff --git a/modules/features2d/misc/python/pyopencv_features2d.hpp b/modules/features2d/misc/python/pyopencv_features2d.hpp index c13dc0aa9b0e..82a6e80220bd 100644 --- a/modules/features2d/misc/python/pyopencv_features2d.hpp +++ b/modules/features2d/misc/python/pyopencv_features2d.hpp @@ -1,7 +1,10 @@ #ifdef HAVE_OPENCV_FEATURES2D typedef SimpleBlobDetector::Params SimpleBlobDetector_Params; typedef AKAZE::DescriptorType AKAZE_DescriptorType; +typedef AgastFeatureDetector::DetectorType AgastFeatureDetector_DetectorType; CV_PY_FROM_ENUM(AKAZE::DescriptorType); CV_PY_TO_ENUM(AKAZE::DescriptorType); +CV_PY_FROM_ENUM(AgastFeatureDetector::DetectorType); +CV_PY_TO_ENUM(AgastFeatureDetector::DetectorType); #endif \ No newline at end of file diff --git a/modules/features2d/src/agast.cpp b/modules/features2d/src/agast.cpp index 8b63234b29ad..6f467ceeec32 100644 --- a/modules/features2d/src/agast.cpp +++ b/modules/features2d/src/agast.cpp @@ -7446,7 +7446,7 @@ static void OAST_9_16(InputArray _img, std::vector& keypoints, int thr #else // !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64)) -static void AGAST_ALL(InputArray _img, std::vector& keypoints, int threshold, int agasttype) +static void AGAST_ALL(InputArray _img, std::vector& keypoints, int threshold, AgastFeatureDetector::DetectorType agasttype) { cv::Mat img; if(!_img.getMat().isContinuous()) @@ -7944,8 +7944,8 @@ void AGAST(InputArray _img, std::vector& keypoints, int threshold, boo class AgastFeatureDetector_Impl CV_FINAL : public AgastFeatureDetector { public: - AgastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, int _type ) - : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type((short)_type) + AgastFeatureDetector_Impl( int _threshold, bool _nonmaxSuppression, DetectorType _type ) + : threshold(_threshold), nonmaxSuppression(_nonmaxSuppression), type(_type) {} void detect( InputArray _image, std::vector& keypoints, InputArray _mask ) CV_OVERRIDE @@ -7998,20 +7998,20 @@ class AgastFeatureDetector_Impl CV_FINAL : public AgastFeatureDetector void setNonmaxSuppression(bool f) CV_OVERRIDE { nonmaxSuppression = f; } bool getNonmaxSuppression() const CV_OVERRIDE { return nonmaxSuppression; } - void setType(int type_) CV_OVERRIDE { type = type_; } - int getType() const CV_OVERRIDE { return type; } + void setType(DetectorType type_) CV_OVERRIDE{ type = type_; } + DetectorType getType() const CV_OVERRIDE{ return type; } int threshold; bool nonmaxSuppression; - int type; + DetectorType type; }; -Ptr AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, int type ) +Ptr AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type ) { return makePtr(threshold, nonmaxSuppression, type); } -void AGAST(InputArray _img, std::vector& keypoints, int threshold, bool nonmax_suppression, int type) +void AGAST(InputArray _img, std::vector& keypoints, int threshold, bool nonmax_suppression, AgastFeatureDetector::DetectorType type) { CV_INSTRUMENT_REGION() diff --git a/modules/features2d/src/agast_score.cpp b/modules/features2d/src/agast_score.cpp index 92a34a758ea9..432166a7e3f2 100644 --- a/modules/features2d/src/agast_score.cpp +++ b/modules/features2d/src/agast_score.cpp @@ -9400,7 +9400,7 @@ int agast_tree_search(const uint32_t table_struct32[], int pixel_[], const unsig } // universal pixel mask -int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, int agasttype) +int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, AgastFeatureDetector::DetectorType agasttype) { int bmin = threshold; int bmax = 255; diff --git a/modules/features2d/src/agast_score.hpp b/modules/features2d/src/agast_score.hpp index f7d668ba734a..62a15937330c 100644 --- a/modules/features2d/src/agast_score.hpp +++ b/modules/features2d/src/agast_score.hpp @@ -54,7 +54,7 @@ namespace cv #if !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64)) int agast_tree_search(const uint32_t table_struct32[], int pixel_[], const unsigned char* const ptr, int threshold); -int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, int agasttype); +int AGAST_ALL_SCORE(const uchar* ptr, const int pixel[], int threshold, AgastFeatureDetector::DetectorType agasttype); #endif //!(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64)) diff --git a/modules/features2d/test/test_agast.cpp b/modules/features2d/test/test_agast.cpp index 9bb15390f01c..64fa7507141f 100644 --- a/modules/features2d/test/test_agast.cpp +++ b/modules/features2d/test/test_agast.cpp @@ -75,8 +75,8 @@ void CV_AgastTest::run( int ) vector keypoints1; vector keypoints2; - AGAST(gray1, keypoints1, 30, true, type); - AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type); + AGAST(gray1, keypoints1, 30, true, static_cast(type)); + AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, static_cast(type)); for(size_t i = 0; i < keypoints1.size(); ++i) {