|
| 1 | +#include "../perf_precomp.hpp" |
| 2 | +#include "opencv2/ts/ocl_perf.hpp" |
| 3 | +#include "../perf_feature2d.hpp" |
| 4 | + |
| 5 | +#ifdef HAVE_OPENCL |
| 6 | + |
| 7 | +namespace cvtest { |
| 8 | +namespace ocl { |
| 9 | + |
| 10 | +OCL_PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES)) |
| 11 | +{ |
| 12 | + Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam())); |
| 13 | + std::string filename = getDataPath(get<1>(GetParam())); |
| 14 | + Mat mimg = imread(filename, IMREAD_GRAYSCALE); |
| 15 | + |
| 16 | + ASSERT_FALSE(mimg.empty()); |
| 17 | + ASSERT_TRUE(detector); |
| 18 | + |
| 19 | + UMat img, mask; |
| 20 | + mimg.copyTo(img); |
| 21 | + declare.in(img); |
| 22 | + vector<KeyPoint> points; |
| 23 | + |
| 24 | + OCL_TEST_CYCLE() detector->detect(img, points, mask); |
| 25 | + |
| 26 | + EXPECT_GT(points.size(), 20u); |
| 27 | + SANITY_CHECK_NOTHING(); |
| 28 | +} |
| 29 | + |
| 30 | +OCL_PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES)) |
| 31 | +{ |
| 32 | + Ptr<Feature2D> detector = AKAZE::create(); |
| 33 | + Ptr<Feature2D> extractor = getFeature2D(get<0>(GetParam())); |
| 34 | + std::string filename = getDataPath(get<1>(GetParam())); |
| 35 | + Mat mimg = imread(filename, IMREAD_GRAYSCALE); |
| 36 | + |
| 37 | + ASSERT_FALSE(mimg.empty()); |
| 38 | + ASSERT_TRUE(extractor); |
| 39 | + |
| 40 | + UMat img, mask; |
| 41 | + mimg.copyTo(img); |
| 42 | + declare.in(img); |
| 43 | + vector<KeyPoint> points; |
| 44 | + detector->detect(img, points, mask); |
| 45 | + |
| 46 | + EXPECT_GT(points.size(), 20u); |
| 47 | + |
| 48 | + UMat descriptors; |
| 49 | + |
| 50 | + OCL_TEST_CYCLE() extractor->compute(img, points, descriptors); |
| 51 | + |
| 52 | + EXPECT_EQ((size_t)descriptors.rows, points.size()); |
| 53 | + SANITY_CHECK_NOTHING(); |
| 54 | +} |
| 55 | + |
| 56 | +OCL_PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES)) |
| 57 | +{ |
| 58 | + Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam())); |
| 59 | + std::string filename = getDataPath(get<1>(GetParam())); |
| 60 | + Mat mimg = imread(filename, IMREAD_GRAYSCALE); |
| 61 | + |
| 62 | + ASSERT_FALSE(mimg.empty()); |
| 63 | + ASSERT_TRUE(detector); |
| 64 | + |
| 65 | + UMat img, mask; |
| 66 | + mimg.copyTo(img); |
| 67 | + declare.in(img); |
| 68 | + vector<KeyPoint> points; |
| 69 | + UMat descriptors; |
| 70 | + |
| 71 | + OCL_TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false); |
| 72 | + |
| 73 | + EXPECT_GT(points.size(), 20u); |
| 74 | + EXPECT_EQ((size_t)descriptors.rows, points.size()); |
| 75 | + SANITY_CHECK_NOTHING(); |
| 76 | +} |
| 77 | + |
| 78 | +} // ocl |
| 79 | +} // cvtest |
| 80 | + |
| 81 | +#endif // HAVE_OPENCL |
0 commit comments