Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/features2d/test/ocl/test_feature2d.cpp
16358 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html
4
5
#include "../test_precomp.hpp"
6
#include "cvconfig.h"
7
#include "opencv2/ts/ocl_test.hpp"
8
9
#ifdef HAVE_OPENCL
10
11
namespace opencv_test {
12
namespace ocl {
13
14
#define TEST_IMAGES testing::Values(\
15
"detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
16
"../stitching/a3.png", \
17
"../stitching/s2.jpg")
18
19
PARAM_TEST_CASE(Feature2DFixture, Ptr<Feature2D>, std::string)
20
{
21
std::string filename;
22
Mat image, descriptors;
23
vector<KeyPoint> keypoints;
24
UMat uimage, udescriptors;
25
vector<KeyPoint> ukeypoints;
26
Ptr<Feature2D> feature;
27
28
virtual void SetUp()
29
{
30
feature = GET_PARAM(0);
31
filename = GET_PARAM(1);
32
33
image = readImage(filename);
34
35
ASSERT_FALSE(image.empty());
36
37
image.copyTo(uimage);
38
39
OCL_OFF(feature->detect(image, keypoints));
40
OCL_ON(feature->detect(uimage, ukeypoints));
41
// note: we use keypoints from CPU for GPU too, to test descriptors separately
42
OCL_OFF(feature->compute(image, keypoints, descriptors));
43
OCL_ON(feature->compute(uimage, keypoints, udescriptors));
44
}
45
};
46
47
OCL_TEST_P(Feature2DFixture, KeypointsSame)
48
{
49
EXPECT_EQ(keypoints.size(), ukeypoints.size());
50
51
for (size_t i = 0; i < keypoints.size(); ++i)
52
{
53
EXPECT_GE(KeyPoint::overlap(keypoints[i], ukeypoints[i]), 0.95);
54
EXPECT_NEAR(keypoints[i].angle, ukeypoints[i].angle, 0.001);
55
}
56
}
57
58
OCL_TEST_P(Feature2DFixture, DescriptorsSame)
59
{
60
EXPECT_MAT_NEAR(descriptors, udescriptors, 0.001);
61
}
62
63
OCL_INSTANTIATE_TEST_CASE_P(AKAZE, Feature2DFixture,
64
testing::Combine(testing::Values(AKAZE::create()), TEST_IMAGES));
65
66
OCL_INSTANTIATE_TEST_CASE_P(AKAZE_DESCRIPTOR_KAZE, Feature2DFixture,
67
testing::Combine(testing::Values(AKAZE::create(AKAZE::DESCRIPTOR_KAZE)), TEST_IMAGES));
68
69
}//ocl
70
}//cvtest
71
72
#endif //HAVE_OPENCL
73
74