Skip to content

Commit 2c49be8

Browse files
committed
feature2d: unify perf test
use the same test for all detectors/descriptors we have. * added AKAZE tests
1 parent 19538ca commit 2c49be8

File tree

4 files changed

+132
-185
lines changed

4 files changed

+132
-185
lines changed

modules/features2d/perf/perf_agast.cpp

Lines changed: 0 additions & 42 deletions
This file was deleted.

modules/features2d/perf/perf_fast.cpp

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#include "perf_precomp.hpp"
2+
3+
using namespace std;
4+
using namespace cv;
5+
using namespace perf;
6+
using std::tr1::make_tuple;
7+
using std::tr1::get;
8+
// detectors/descriptors configurations to test
9+
#define DETECTORS_ONLY \
10+
FAST_DEFAULT, FAST_20_TRUE_TYPE5_8, FAST_20_TRUE_TYPE7_12, FAST_20_TRUE_TYPE9_16, \
11+
FAST_20_FALSE_TYPE5_8, FAST_20_FALSE_TYPE7_12, FAST_20_FALSE_TYPE9_16, \
12+
\
13+
AGAST_DEFAULT, AGAST_5_8, AGAST_7_12d, AGAST_7_12s, AGAST_OAST_9_16
14+
15+
#define DETECTORS_DESCRIPTORS \
16+
ORB_DEFAULT, ORB_1500_13_1, \
17+
\
18+
AKAZE_DEFAULT, AKAZE_DESCRIPTOR_KAZE
19+
20+
enum { DETECTORS_DESCRIPTORS, DETECTORS_ONLY };
21+
CV_ENUM(Feature2DType, DETECTORS_DESCRIPTORS, DETECTORS_ONLY)
22+
23+
typedef std::tr1::tuple<Feature2DType, string> Feature2DType_String_t;
24+
typedef perf::TestBaseWithParam<Feature2DType_String_t> feature2d;
25+
26+
#define TEST_IMAGES testing::Values(\
27+
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
28+
"stitching/a3.png")
29+
30+
static inline Ptr<Feature2D> getFeature2D(Feature2DType type)
31+
{
32+
switch(type) {
33+
case ORB_DEFAULT:
34+
return ORB::create();
35+
case ORB_1500_13_1:
36+
return ORB::create(1500, 1.3f, 1);
37+
case FAST_DEFAULT:
38+
return FastFeatureDetector::create();
39+
case FAST_20_TRUE_TYPE5_8:
40+
return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_5_8);
41+
case FAST_20_TRUE_TYPE7_12:
42+
return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_7_12);
43+
case FAST_20_TRUE_TYPE9_16:
44+
return FastFeatureDetector::create(20, true, FastFeatureDetector::TYPE_9_16);
45+
case FAST_20_FALSE_TYPE5_8:
46+
return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_5_8);
47+
case FAST_20_FALSE_TYPE7_12:
48+
return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_7_12);
49+
case FAST_20_FALSE_TYPE9_16:
50+
return FastFeatureDetector::create(20, false, FastFeatureDetector::TYPE_9_16);
51+
case AGAST_DEFAULT:
52+
return AgastFeatureDetector::create();
53+
case AGAST_5_8:
54+
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_5_8);
55+
case AGAST_7_12d:
56+
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_7_12d);
57+
case AGAST_7_12s:
58+
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::AGAST_7_12s);
59+
case AGAST_OAST_9_16:
60+
return AgastFeatureDetector::create(70, true, AgastFeatureDetector::OAST_9_16);
61+
case AKAZE_DEFAULT:
62+
return AKAZE::create();
63+
case AKAZE_DESCRIPTOR_KAZE:
64+
return AKAZE::create(AKAZE::DESCRIPTOR_KAZE);
65+
default:
66+
return Ptr<Feature2D>();
67+
}
68+
}
69+
70+
PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))
71+
{
72+
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
73+
std::string filename = getDataPath(get<1>(GetParam()));
74+
Mat img = imread(filename, IMREAD_GRAYSCALE);
75+
76+
ASSERT_FALSE(img.empty());
77+
ASSERT_TRUE(detector);
78+
79+
declare.in(img);
80+
Mat mask;
81+
vector<KeyPoint> points;
82+
83+
TEST_CYCLE() detector->detect(img, points, mask);
84+
85+
EXPECT_GT(points.size(), 20u);
86+
SANITY_CHECK_NOTHING();
87+
}
88+
89+
PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_DESCRIPTORS), TEST_IMAGES))
90+
{
91+
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
92+
std::string filename = getDataPath(get<1>(GetParam()));
93+
Mat img = imread(filename, IMREAD_GRAYSCALE);
94+
95+
ASSERT_FALSE(img.empty());
96+
ASSERT_TRUE(detector);
97+
98+
declare.in(img);
99+
Mat mask;
100+
vector<KeyPoint> points;
101+
detector->detect(img, points, mask);
102+
103+
EXPECT_GT(points.size(), 20u);
104+
105+
Mat descriptors;
106+
107+
TEST_CYCLE() detector->compute(img, points, descriptors);
108+
109+
EXPECT_EQ((size_t)descriptors.rows, points.size());
110+
SANITY_CHECK_NOTHING();
111+
}
112+
113+
PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_DESCRIPTORS), TEST_IMAGES))
114+
{
115+
Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));
116+
std::string filename = getDataPath(get<1>(GetParam()));
117+
Mat img = imread(filename, IMREAD_GRAYSCALE);
118+
119+
ASSERT_FALSE(img.empty());
120+
ASSERT_TRUE(detector);
121+
122+
declare.in(img);
123+
Mat mask;
124+
vector<KeyPoint> points;
125+
Mat descriptors;
126+
127+
TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false);
128+
129+
EXPECT_GT(points.size(), 20u);
130+
EXPECT_EQ((size_t)descriptors.rows, points.size());
131+
SANITY_CHECK_NOTHING();
132+
}

modules/features2d/perf/perf_orb.cpp

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)