perf_corners.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. CV_ENUM(BorderType, BORDER_REPLICATE, BORDER_CONSTANT, BORDER_REFLECT, BORDER_REFLECT_101)
  7. typedef tuple<string, int, int, double, BorderType> Img_BlockSize_ApertureSize_k_BorderType_t;
  8. typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_k_BorderType_t> Img_BlockSize_ApertureSize_k_BorderType;
  9. PERF_TEST_P(Img_BlockSize_ApertureSize_k_BorderType, cornerHarris,
  10. testing::Combine(
  11. testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
  12. testing::Values( 3, 5 ),
  13. testing::Values( 3, 5 ),
  14. testing::Values( 0.04, 0.1 ),
  15. BorderType::all()
  16. )
  17. )
  18. {
  19. string filename = getDataPath(get<0>(GetParam()));
  20. int blockSize = get<1>(GetParam());
  21. int apertureSize = get<2>(GetParam());
  22. double k = get<3>(GetParam());
  23. BorderType borderType = get<4>(GetParam());
  24. Mat src = imread(filename, IMREAD_GRAYSCALE);
  25. ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
  26. Mat dst;
  27. TEST_CYCLE() cornerHarris(src, dst, blockSize, apertureSize, k, borderType);
  28. SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
  29. }
  30. typedef tuple<string, int, int, BorderType> Img_BlockSize_ApertureSize_BorderType_t;
  31. typedef perf::TestBaseWithParam<Img_BlockSize_ApertureSize_BorderType_t> Img_BlockSize_ApertureSize_BorderType;
  32. PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerEigenValsAndVecs,
  33. testing::Combine(
  34. testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
  35. testing::Values( 3, 5 ),
  36. testing::Values( 3, 5 ),
  37. BorderType::all()
  38. )
  39. )
  40. {
  41. string filename = getDataPath(get<0>(GetParam()));
  42. int blockSize = get<1>(GetParam());
  43. int apertureSize = get<2>(GetParam());
  44. BorderType borderType = get<3>(GetParam());
  45. Mat src = imread(filename, IMREAD_GRAYSCALE);
  46. ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
  47. Mat dst;
  48. TEST_CYCLE() cornerEigenValsAndVecs(src, dst, blockSize, apertureSize, borderType);
  49. Mat l1;
  50. extractChannel(dst, l1, 0);
  51. SANITY_CHECK(l1, 2e-5, ERROR_RELATIVE);
  52. }
  53. PERF_TEST_P(Img_BlockSize_ApertureSize_BorderType, cornerMinEigenVal,
  54. testing::Combine(
  55. testing::Values( "stitching/a1.png", "cv/shared/pic5.png"),
  56. testing::Values( 3, 5 ),
  57. testing::Values( 3, 5 ),
  58. BorderType::all()
  59. )
  60. )
  61. {
  62. string filename = getDataPath(get<0>(GetParam()));
  63. int blockSize = get<1>(GetParam());
  64. int apertureSize = get<2>(GetParam());
  65. BorderType borderType = get<3>(GetParam());
  66. Mat src = imread(filename, IMREAD_GRAYSCALE);
  67. ASSERT_FALSE(src.empty()) << "Unable to load source image: " << filename;
  68. Mat dst;
  69. TEST_CYCLE() cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
  70. SANITY_CHECK(dst, 2e-5, ERROR_RELATIVE);
  71. }
  72. } // namespace