Skip to content

Commit ae7e5a5

Browse files
committed
Merge pull request #162 from cbalint13/agast
Add AGAST detector
2 parents a1313db + eeb00c8 commit ae7e5a5

File tree

7 files changed

+17347
-0
lines changed

7 files changed

+17347
-0
lines changed

modules/xfeatures2d/doc/xfeatures2d.bib

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ @inproceedings{AOV12
4545
organization={Ieee}
4646
}
4747

48+
@inproceedings{mair2010_agast,
49+
title={Adaptive and Generic Corner Detection Based on the Accelerated Segment Test"},
50+
author={"Elmar Mair and Gregory D. Hager and Darius Burschka and Michael Suppa and Gerhard Hirzinger"},
51+
year={"2010"},
52+
month={"September"},
53+
booktitle={"European Conference on Computer Vision (ECCV'10)"},
54+
url={"http://www6.in.tum.de/Main/ResearchAgast"
55+
}
56+
4857
@incollection{LUCID,
4958
title={Locally uniform comparison image descriptor},
5059
author={Ziegler, Andrew, Eric Christiansen, David Kriegman, and Serge J. Belongie}

modules/xfeatures2d/include/opencv2/xfeatures2d.hpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,52 @@ class CV_EXPORTS BriefDescriptorExtractor : public DescriptorExtractor
129129
static Ptr<BriefDescriptorExtractor> create( int bytes = 32 );
130130
};
131131

132+
/** @overload */
133+
CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
134+
int threshold, bool nonmaxSuppression=true );
135+
136+
/** @brief Detects corners using the AGAST algorithm
137+
138+
@param image grayscale image where keypoints (corners) are detected.
139+
@param keypoints keypoints detected on the image.
140+
@param threshold threshold on difference between intensity of the central pixel and pixels of a
141+
circle around this pixel.
142+
@param nonmaxSuppression if true, non-maximum suppression is applied to detected corners
143+
(keypoints).
144+
@param type one of the four neighborhoods as defined in the paper:
145+
AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d,
146+
AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16
147+
148+
Detects corners using the AGAST algorithm by @cite mair2010_agast .
149+
150+
*/
151+
CV_EXPORTS void AGAST( InputArray image, CV_OUT std::vector<KeyPoint>& keypoints,
152+
int threshold, bool nonmaxSuppression, int type );
153+
154+
/** @brief Wrapping class for feature detection using the AGAST method. :
155+
*/
156+
class CV_EXPORTS_W AgastFeatureDetector : public Feature2D
157+
{
158+
public:
159+
enum
160+
{
161+
AGAST_5_8 = 0, AGAST_7_12d = 1, AGAST_7_12s = 2, OAST_9_16 = 3,
162+
THRESHOLD = 10000, NONMAX_SUPPRESSION = 10001,
163+
};
164+
165+
CV_WRAP static Ptr<AgastFeatureDetector> create( int threshold=10,
166+
bool nonmaxSuppression=true,
167+
int type=AgastFeatureDetector::OAST_9_16 );
168+
169+
CV_WRAP virtual void setThreshold(int threshold) = 0;
170+
CV_WRAP virtual int getThreshold() const = 0;
171+
172+
CV_WRAP virtual void setNonmaxSuppression(bool f) = 0;
173+
CV_WRAP virtual bool getNonmaxSuppression() const = 0;
174+
175+
CV_WRAP virtual void setType(int type) = 0;
176+
CV_WRAP virtual int getType() const = 0;
177+
};
132178

133179
/** @brief Class implementing the locally uniform comparison image descriptor, described in @cite LUCID
134180
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include "perf_precomp.hpp"
2+
3+
using namespace std;
4+
using namespace cv;
5+
using namespace cv::xfeatures2d;
6+
using namespace perf;
7+
using std::tr1::make_tuple;
8+
using std::tr1::get;
9+
10+
CV_ENUM(AgastType, AgastFeatureDetector::AGAST_5_8, AgastFeatureDetector::AGAST_7_12d,
11+
AgastFeatureDetector::AGAST_7_12s, AgastFeatureDetector::OAST_9_16)
12+
13+
typedef std::tr1::tuple<string, AgastType> File_Type_t;
14+
typedef perf::TestBaseWithParam<File_Type_t> agast;
15+
16+
#define AGAST_IMAGES \
17+
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
18+
"stitching/a3.png"
19+
20+
PERF_TEST_P(agast, detect, testing::Combine(
21+
testing::Values(AGAST_IMAGES),
22+
AgastType::all()
23+
))
24+
{
25+
string filename = getDataPath(get<0>(GetParam()));
26+
int type = get<1>(GetParam());
27+
Mat frame = imread(filename, IMREAD_GRAYSCALE);
28+
29+
if (frame.empty())
30+
FAIL() << "Unable to load source image " << filename;
31+
32+
declare.in(frame);
33+
34+
Ptr<FeatureDetector> fd = AgastFeatureDetector::create(20, true, type);
35+
ASSERT_FALSE( fd.empty() );
36+
vector<KeyPoint> points;
37+
38+
TEST_CYCLE() fd->detect(frame, points);
39+
40+
SANITY_CHECK_KEYPOINTS(points);
41+
}

0 commit comments

Comments
 (0)