Path: blob/master/modules/features2d/perf/perf_feature2d.cpp
16354 views
#include "perf_feature2d.hpp"12namespace opencv_test3{4using namespace perf;56PERF_TEST_P(feature2d, detect, testing::Combine(Feature2DType::all(), TEST_IMAGES))7{8Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));9std::string filename = getDataPath(get<1>(GetParam()));10Mat img = imread(filename, IMREAD_GRAYSCALE);1112ASSERT_FALSE(img.empty());13ASSERT_TRUE(detector);1415declare.in(img);16Mat mask;17vector<KeyPoint> points;1819TEST_CYCLE() detector->detect(img, points, mask);2021EXPECT_GT(points.size(), 20u);22SANITY_CHECK_NOTHING();23}2425PERF_TEST_P(feature2d, extract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))26{27Ptr<Feature2D> detector = AKAZE::create();28Ptr<Feature2D> extractor = getFeature2D(get<0>(GetParam()));29std::string filename = getDataPath(get<1>(GetParam()));30Mat img = imread(filename, IMREAD_GRAYSCALE);3132ASSERT_FALSE(img.empty());33ASSERT_TRUE(extractor);3435declare.in(img);36Mat mask;37vector<KeyPoint> points;38detector->detect(img, points, mask);3940EXPECT_GT(points.size(), 20u);4142Mat descriptors;4344TEST_CYCLE() extractor->compute(img, points, descriptors);4546EXPECT_EQ((size_t)descriptors.rows, points.size());47SANITY_CHECK_NOTHING();48}4950PERF_TEST_P(feature2d, detectAndExtract, testing::Combine(testing::Values(DETECTORS_EXTRACTORS), TEST_IMAGES))51{52Ptr<Feature2D> detector = getFeature2D(get<0>(GetParam()));53std::string filename = getDataPath(get<1>(GetParam()));54Mat img = imread(filename, IMREAD_GRAYSCALE);5556ASSERT_FALSE(img.empty());57ASSERT_TRUE(detector);5859declare.in(img);60Mat mask;61vector<KeyPoint> points;62Mat descriptors;6364TEST_CYCLE() detector->detectAndCompute(img, mask, points, descriptors, false);6566EXPECT_GT(points.size(), 20u);67EXPECT_EQ((size_t)descriptors.rows, points.size());68SANITY_CHECK_NOTHING();69}7071} // namespace727374