1#include "../perf_precomp.hpp"
2#include "opencv2/ts/ocl_perf.hpp"
3
4#ifdef HAVE_OPENCL
5
6namespace cvtest {
7namespace ocl {
8
9typedef ::perf::TestBaseWithParam<std::string> ORBFixture;
10
11#define ORB_IMAGES OCL_PERF_ENUM("cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png", "stitching/a3.png")
12
13OCL_PERF_TEST_P(ORBFixture, ORB_Detect, ORB_IMAGES)
14{
15    string filename = getDataPath(GetParam());
16    Mat mframe = imread(filename, IMREAD_GRAYSCALE);
17
18    if (mframe.empty())
19        FAIL() << "Unable to load source image " << filename;
20
21    UMat frame, mask;
22    mframe.copyTo(frame);
23
24    declare.in(frame);
25    Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
26    vector<KeyPoint> points;
27
28    OCL_TEST_CYCLE() detector->detect(frame, points, mask);
29
30    std::sort(points.begin(), points.end(), comparators::KeypointGreater());
31    SANITY_CHECK_KEYPOINTS(points, 1e-5);
32}
33
34OCL_PERF_TEST_P(ORBFixture, ORB_Extract, ORB_IMAGES)
35{
36    string filename = getDataPath(GetParam());
37    Mat mframe = imread(filename, IMREAD_GRAYSCALE);
38
39    if (mframe.empty())
40        FAIL() << "Unable to load source image " << filename;
41
42    UMat mask, frame;
43    mframe.copyTo(frame);
44
45    declare.in(frame);
46
47    Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
48    vector<KeyPoint> points;
49    detector->detect(frame, points, mask);
50    std::sort(points.begin(), points.end(), comparators::KeypointGreater());
51
52    UMat descriptors;
53
54    OCL_TEST_CYCLE() detector->compute(frame, points, descriptors);
55
56    SANITY_CHECK(descriptors);
57}
58
59OCL_PERF_TEST_P(ORBFixture, ORB_Full, ORB_IMAGES)
60{
61    string filename = getDataPath(GetParam());
62    Mat mframe = imread(filename, IMREAD_GRAYSCALE);
63
64    double desc_eps = 1e-6;
65#ifdef ANDROID
66    if (cv::ocl::Device::getDefault().isNVidia())
67        desc_eps = 2;
68#endif
69
70    if (mframe.empty())
71        FAIL() << "Unable to load source image " << filename;
72
73    UMat mask, frame;
74    mframe.copyTo(frame);
75
76    declare.in(frame);
77    Ptr<ORB> detector = ORB::create(1500, 1.3f, 1);
78
79    vector<KeyPoint> points;
80    UMat descriptors;
81
82    OCL_TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false);
83
84    ::perf::sort(points, descriptors);
85    SANITY_CHECK_KEYPOINTS(points, 1e-5);
86    SANITY_CHECK(descriptors, desc_eps);
87}
88
89} // ocl
90} // cvtest
91
92#endif // HAVE_OPENCL
93