1793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "perf_precomp.hpp"
2793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
3793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing namespace std;
4793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing namespace cv;
5793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing namespace perf;
6793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing std::tr1::make_tuple;
7793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerusing std::tr1::get;
8793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
9793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslertypedef perf::TestBaseWithParam<std::string> orb;
10793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
11793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define ORB_IMAGES \
12793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
13793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    "stitching/a3.png"
14793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
15793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerPERF_TEST_P(orb, detect, testing::Values(ORB_IMAGES))
16793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{
17793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    string filename = getDataPath(GetParam());
18793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat frame = imread(filename, IMREAD_GRAYSCALE);
19793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
20793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    if (frame.empty())
21793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        FAIL() << "Unable to load source image " << filename;
22793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
23793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat mask;
24793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    declare.in(frame);
25793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
26793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    vector<KeyPoint> points;
27793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
28793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TEST_CYCLE() detector->detect(frame, points, mask);
29793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
30793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    sort(points.begin(), points.end(), comparators::KeypointGreater());
31793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    SANITY_CHECK_KEYPOINTS(points, 1e-5);
32793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler}
33793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
34793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerPERF_TEST_P(orb, extract, testing::Values(ORB_IMAGES))
35793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{
36793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    string filename = getDataPath(GetParam());
37793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat frame = imread(filename, IMREAD_GRAYSCALE);
38793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
39793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    if (frame.empty())
40793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        FAIL() << "Unable to load source image " << filename;
41793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
42793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat mask;
43793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    declare.in(frame);
44793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
45793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
46793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    vector<KeyPoint> points;
47793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    detector->detect(frame, points, mask);
48793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    sort(points.begin(), points.end(), comparators::KeypointGreater());
49793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
50793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat descriptors;
51793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
52793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TEST_CYCLE() detector->compute(frame, points, descriptors);
53793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
54793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    SANITY_CHECK(descriptors);
55793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler}
56793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
57793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerPERF_TEST_P(orb, full, testing::Values(ORB_IMAGES))
58793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{
59793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    string filename = getDataPath(GetParam());
60793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat frame = imread(filename, IMREAD_GRAYSCALE);
61793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
62793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    if (frame.empty())
63793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        FAIL() << "Unable to load source image " << filename;
64793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
65793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat mask;
66793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    declare.in(frame);
67793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
68793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
69793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    vector<KeyPoint> points;
70793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    Mat descriptors;
71793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
72793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false);
73793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
74793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    perf::sort(points, descriptors);
75793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    SANITY_CHECK_KEYPOINTS(points, 1e-5);
76793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    SANITY_CHECK(descriptors);
77793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler}
78