Skip to content

Commit

Permalink
AgastFeatureDetector::DetectorType enum
Browse files Browse the repository at this point in the history
  • Loading branch information
cv3d committed Aug 24, 2018
1 parent 7099802 commit a01d44a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 43 deletions.
61 changes: 33 additions & 28 deletions modules/features2d/include/opencv2/features2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyPoint>& 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<KeyPoint>& keypoints,
int threshold, bool nonmaxSuppression, int type );
//! @} features2d_main

//! @addtogroup features2d_main
Expand All @@ -508,27 +484,56 @@ CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector<KeyPoint>& 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<AgastFeatureDetector> 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;

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<KeyPoint>& 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<KeyPoint>& 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
Expand Down
3 changes: 3 additions & 0 deletions modules/features2d/misc/python/pyopencv_features2d.hpp
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions modules/features2d/src/agast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7446,7 +7446,7 @@ static void OAST_9_16(InputArray _img, std::vector<KeyPoint>& keypoints, int thr

#else // !(defined __i386__ || defined(_M_IX86) || defined __x86_64__ || defined(_M_X64))

static void AGAST_ALL(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, int agasttype)
static void AGAST_ALL(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, AgastFeatureDetector::DetectorType agasttype)
{
cv::Mat img;
if(!_img.getMat().isContinuous())
Expand Down Expand Up @@ -7944,8 +7944,8 @@ void AGAST(InputArray _img, std::vector<KeyPoint>& 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<KeyPoint>& keypoints, InputArray _mask ) CV_OVERRIDE
Expand Down Expand Up @@ -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> AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, int type )
Ptr<AgastFeatureDetector> AgastFeatureDetector::create( int threshold, bool nonmaxSuppression, AgastFeatureDetector::DetectorType type )
{
return makePtr<AgastFeatureDetector_Impl>(threshold, nonmaxSuppression, type);
}

void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, int type)
void AGAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool nonmax_suppression, AgastFeatureDetector::DetectorType type)
{
CV_INSTRUMENT_REGION()

Expand Down
4 changes: 2 additions & 2 deletions modules/features2d/src/agast_score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The references are:
namespace cv
{

void makeAgastOffsets(int pixel[16], int rowStride, int type)
void makeAgastOffsets(int pixel[16], int rowStride, AgastFeatureDetector::DetectorType type)
{
static const int offsets16[][2] =
{
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions modules/features2d/src/agast_score.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ 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))


void makeAgastOffsets(int pixel[16], int row_stride, int type);
void makeAgastOffsets(int pixel[16], int row_stride, AgastFeatureDetector::DetectorType type);

template<int type>
template<AgastFeatureDetector::DetectorType type>
int agast_cornerScore(const uchar* ptr, const int pixel[], int threshold);


Expand Down
4 changes: 2 additions & 2 deletions modules/features2d/test/test_agast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void CV_AgastTest::run( int )

vector<KeyPoint> keypoints1;
vector<KeyPoint> keypoints2;
AGAST(gray1, keypoints1, 30, true, type);
AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, type);
AGAST(gray1, keypoints1, 30, true, static_cast<AgastFeatureDetector::DetectorType>(type));
AGAST(gray2, keypoints2, (type > 0 ? 30 : 20), true, static_cast<AgastFeatureDetector::DetectorType>(type));

for(size_t i = 0; i < keypoints1.size(); ++i)
{
Expand Down

0 comments on commit a01d44a

Please sign in to comment.