perf_surf.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "perf_precomp.hpp"
  5. #ifdef OPENCV_ENABLE_NONFREE
  6. namespace opencv_test { namespace {
  7. typedef perf::TestBaseWithParam<std::string> surf;
  8. #define SURF_IMAGES \
  9. "cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
  10. "stitching/a3.png"
  11. PERF_TEST_P(surf, detect, testing::Values(SURF_IMAGES))
  12. {
  13. string filename = getDataPath(GetParam());
  14. Mat frame = imread(filename, IMREAD_GRAYSCALE);
  15. ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
  16. Mat mask;
  17. declare.in(frame).time(90);
  18. Ptr<SURF> detector = SURF::create();
  19. vector<KeyPoint> points;
  20. TEST_CYCLE() detector->detect(frame, points, mask);
  21. SANITY_CHECK_NOTHING();
  22. }
  23. PERF_TEST_P(surf, extract, testing::Values(SURF_IMAGES))
  24. {
  25. string filename = getDataPath(GetParam());
  26. Mat frame = imread(filename, IMREAD_GRAYSCALE);
  27. ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
  28. Mat mask;
  29. declare.in(frame).time(90);
  30. Ptr<SURF> detector = SURF::create();
  31. vector<KeyPoint> points;
  32. Mat descriptors;
  33. detector->detect(frame, points, mask);
  34. TEST_CYCLE() detector->compute(frame, points, descriptors);
  35. SANITY_CHECK_NOTHING();
  36. }
  37. PERF_TEST_P(surf, full, testing::Values(SURF_IMAGES))
  38. {
  39. string filename = getDataPath(GetParam());
  40. Mat frame = imread(filename, IMREAD_GRAYSCALE);
  41. ASSERT_FALSE(frame.empty()) << "Unable to load source image " << filename;
  42. Mat mask;
  43. declare.in(frame).time(90);
  44. Ptr<SURF> detector = SURF::create();
  45. vector<KeyPoint> points;
  46. Mat descriptors;
  47. TEST_CYCLE() detector->detectAndCompute(frame, mask, points, descriptors, false);
  48. SANITY_CHECK_NOTHING();
  49. }
  50. }} // namespace
  51. #endif // NONFREE