perf_pyramids.cpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. PERF_TEST_P(Size_MatType, pyrDown, testing::Combine(
  7. testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
  8. testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
  9. )
  10. )
  11. {
  12. Size sz = get<0>(GetParam());
  13. int matType = get<1>(GetParam());
  14. const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
  15. perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
  16. Mat src(sz, matType);
  17. Mat dst((sz.height + 1)/2, (sz.width + 1)/2, matType);
  18. declare.in(src, WARMUP_RNG).out(dst);
  19. TEST_CYCLE() pyrDown(src, dst);
  20. SANITY_CHECK(dst, eps, error_type);
  21. }
  22. PERF_TEST_P(Size_MatType, DISABLED_pyrDown_ovx, testing::Combine(
  23. testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
  24. testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
  25. )
  26. )
  27. {
  28. Size sz = get<0>(GetParam());
  29. int matType = get<1>(GetParam());
  30. const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
  31. perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
  32. Mat src(sz, matType);
  33. Mat dst((sz.height + 1) / 2, (sz.width + 1) / 2, matType);
  34. declare.in(src, WARMUP_RNG).out(dst);
  35. TEST_CYCLE() pyrDown(src, dst, cv::Size(), BORDER_REPLICATE);
  36. SANITY_CHECK(dst, eps, error_type);
  37. }
  38. PERF_TEST_P(Size_MatType, pyrUp, testing::Combine(
  39. testing::Values(sz720p, szVGA, szQVGA, szODD),
  40. testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4)
  41. )
  42. )
  43. {
  44. Size sz = get<0>(GetParam());
  45. int matType = get<1>(GetParam());
  46. const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
  47. perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
  48. Mat src(sz, matType);
  49. Mat dst(sz.height*2, sz.width*2, matType);
  50. declare.in(src, WARMUP_RNG).out(dst);
  51. TEST_CYCLE() pyrUp(src, dst);
  52. SANITY_CHECK(dst, eps, error_type);
  53. }
  54. PERF_TEST_P(Size_MatType, buildPyramid, testing::Combine(
  55. testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD),
  56. testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)
  57. )
  58. )
  59. {
  60. Size sz = get<0>(GetParam());
  61. int matType = get<1>(GetParam());
  62. int maxLevel = 5;
  63. const double eps = CV_MAT_DEPTH(matType) <= CV_32S ? 1 : 1e-5;
  64. perf::ERROR_TYPE error_type = CV_MAT_DEPTH(matType) <= CV_32S ? ERROR_ABSOLUTE : ERROR_RELATIVE;
  65. Mat src(sz, matType);
  66. std::vector<Mat> dst(maxLevel);
  67. declare.in(src, WARMUP_RNG);
  68. TEST_CYCLE() buildPyramid(src, dst, maxLevel);
  69. Mat dst0 = dst[0], dst1 = dst[1], dst2 = dst[2], dst3 = dst[3], dst4 = dst[4];
  70. SANITY_CHECK(dst0, eps, error_type);
  71. SANITY_CHECK(dst1, eps, error_type);
  72. SANITY_CHECK(dst2, eps, error_type);
  73. SANITY_CHECK(dst3, eps, error_type);
  74. SANITY_CHECK(dst4, eps, error_type);
  75. }
  76. } // namespace