perf_goodFeaturesToTrack.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. namespace opencv_test {
  6. typedef tuple<string, int, double, int, int, bool> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris_t;
  7. typedef perf::TestBaseWithParam<Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris_t> Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris;
  8. PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris, goodFeaturesToTrack,
  9. testing::Combine(
  10. testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
  11. testing::Values( 100, 500 ),
  12. testing::Values( 0.1, 0.01 ),
  13. testing::Values( 3, 5 ),
  14. testing::Values( 3, 5 ),
  15. testing::Bool()
  16. )
  17. )
  18. {
  19. string filename = getDataPath(get<0>(GetParam()));
  20. int maxCorners = get<1>(GetParam());
  21. double qualityLevel = get<2>(GetParam());
  22. int blockSize = get<3>(GetParam());
  23. int gradientSize = get<4>(GetParam());
  24. bool useHarrisDetector = get<5>(GetParam());
  25. Mat image = imread(filename, IMREAD_GRAYSCALE);
  26. if (image.empty())
  27. FAIL() << "Unable to load source image" << filename;
  28. std::vector<Point2f> corners;
  29. double minDistance = 1;
  30. TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(), blockSize, gradientSize, useHarrisDetector);
  31. if (corners.size() > 50)
  32. corners.erase(corners.begin() + 50, corners.end());
  33. SANITY_CHECK(corners);
  34. }
  35. PERF_TEST_P(Image_MaxCorners_QualityLevel_MinDistance_BlockSize_gradientSize_UseHarris, goodFeaturesToTrackWithQuality,
  36. testing::Combine(
  37. testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
  38. testing::Values( 50 ),
  39. testing::Values( 0.01 ),
  40. testing::Values( 3 ),
  41. testing::Values( 3 ),
  42. testing::Bool()
  43. )
  44. )
  45. {
  46. string filename = getDataPath(get<0>(GetParam()));
  47. int maxCorners = get<1>(GetParam());
  48. double qualityLevel = get<2>(GetParam());
  49. int blockSize = get<3>(GetParam());
  50. int gradientSize = get<4>(GetParam());
  51. bool useHarrisDetector = get<5>(GetParam());
  52. double minDistance = 1;
  53. Mat image = imread(filename, IMREAD_GRAYSCALE);
  54. if (image.empty())
  55. FAIL() << "Unable to load source image" << filename;
  56. std::vector<Point2f> corners;
  57. std::vector<float> cornersQuality;
  58. TEST_CYCLE() goodFeaturesToTrack(image, corners, maxCorners, qualityLevel, minDistance, noArray(),
  59. cornersQuality, blockSize, gradientSize, useHarrisDetector);
  60. SANITY_CHECK(corners);
  61. SANITY_CHECK(cornersQuality, 1e-6);
  62. }
  63. } // namespace