perf_accumulate.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 Size_MatType Accumulate;
  7. #define MAT_TYPES_ACCUMLATE CV_8UC1, CV_16UC1, CV_32FC1
  8. #define MAT_TYPES_ACCUMLATE_C MAT_TYPES_ACCUMLATE, CV_8UC3, CV_16UC3, CV_32FC3
  9. #define MAT_TYPES_ACCUMLATE_D MAT_TYPES_ACCUMLATE, CV_64FC1
  10. #define MAT_TYPES_ACCUMLATE_D_C MAT_TYPES_ACCUMLATE_C, CV_64FC1, CV_64FC1
  11. #define PERF_ACCUMULATE_INIT(_FLTC) \
  12. const Size srcSize = get<0>(GetParam()); \
  13. const int srcType = get<1>(GetParam()); \
  14. const int dstType = _FLTC(CV_MAT_CN(srcType)); \
  15. Mat src1(srcSize, srcType), dst(srcSize, dstType); \
  16. declare.in(src1, dst, WARMUP_RNG).out(dst);
  17. #define PERF_ACCUMULATE_MASK_INIT(_FLTC) \
  18. PERF_ACCUMULATE_INIT(_FLTC) \
  19. Mat mask(srcSize, CV_8UC1); \
  20. declare.in(mask, WARMUP_RNG);
  21. #define PERF_TEST_P_ACCUMULATE(_NAME, _TYPES, _INIT, _FUN) \
  22. PERF_TEST_P(Accumulate, _NAME, \
  23. testing::Combine( \
  24. testing::Values(sz1080p, sz720p, szVGA, szQVGA, szODD), \
  25. testing::Values(_TYPES) \
  26. ) \
  27. ) \
  28. { \
  29. _INIT \
  30. TEST_CYCLE() _FUN; \
  31. SANITY_CHECK_NOTHING(); \
  32. }
  33. /////////////////////////////////// Accumulate ///////////////////////////////////
  34. PERF_TEST_P_ACCUMULATE(Accumulate, MAT_TYPES_ACCUMLATE,
  35. PERF_ACCUMULATE_INIT(CV_32FC), accumulate(src1, dst))
  36. PERF_TEST_P_ACCUMULATE(AccumulateMask, MAT_TYPES_ACCUMLATE_C,
  37. PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulate(src1, dst, mask))
  38. PERF_TEST_P_ACCUMULATE(AccumulateDouble, MAT_TYPES_ACCUMLATE_D,
  39. PERF_ACCUMULATE_INIT(CV_64FC), accumulate(src1, dst))
  40. PERF_TEST_P_ACCUMULATE(AccumulateDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
  41. PERF_ACCUMULATE_MASK_INIT(CV_64FC), accumulate(src1, dst, mask))
  42. ///////////////////////////// AccumulateSquare ///////////////////////////////////
  43. PERF_TEST_P_ACCUMULATE(Square, MAT_TYPES_ACCUMLATE,
  44. PERF_ACCUMULATE_INIT(CV_32FC), accumulateSquare(src1, dst))
  45. PERF_TEST_P_ACCUMULATE(SquareMask, MAT_TYPES_ACCUMLATE_C,
  46. PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulateSquare(src1, dst, mask))
  47. PERF_TEST_P_ACCUMULATE(SquareDouble, MAT_TYPES_ACCUMLATE_D,
  48. PERF_ACCUMULATE_INIT(CV_64FC), accumulateSquare(src1, dst))
  49. PERF_TEST_P_ACCUMULATE(SquareDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
  50. PERF_ACCUMULATE_MASK_INIT(CV_64FC), accumulateSquare(src1, dst, mask))
  51. ///////////////////////////// AccumulateProduct ///////////////////////////////////
  52. #define PERF_ACCUMULATE_INIT_2(_FLTC) \
  53. PERF_ACCUMULATE_INIT(_FLTC) \
  54. Mat src2(srcSize, srcType); \
  55. declare.in(src2);
  56. #define PERF_ACCUMULATE_MASK_INIT_2(_FLTC) \
  57. PERF_ACCUMULATE_MASK_INIT(_FLTC) \
  58. Mat src2(srcSize, srcType); \
  59. declare.in(src2);
  60. PERF_TEST_P_ACCUMULATE(Product, MAT_TYPES_ACCUMLATE,
  61. PERF_ACCUMULATE_INIT_2(CV_32FC), accumulateProduct(src1, src2, dst))
  62. PERF_TEST_P_ACCUMULATE(ProductMask, MAT_TYPES_ACCUMLATE_C,
  63. PERF_ACCUMULATE_MASK_INIT_2(CV_32FC), accumulateProduct(src1, src2, dst, mask))
  64. PERF_TEST_P_ACCUMULATE(ProductDouble, MAT_TYPES_ACCUMLATE_D,
  65. PERF_ACCUMULATE_INIT_2(CV_64FC), accumulateProduct(src1, src2, dst))
  66. PERF_TEST_P_ACCUMULATE(ProductDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
  67. PERF_ACCUMULATE_MASK_INIT_2(CV_64FC), accumulateProduct(src1, src2, dst, mask))
  68. ///////////////////////////// AccumulateWeighted ///////////////////////////////////
  69. PERF_TEST_P_ACCUMULATE(Weighted, MAT_TYPES_ACCUMLATE,
  70. PERF_ACCUMULATE_INIT(CV_32FC), accumulateWeighted(src1, dst, 0.123))
  71. PERF_TEST_P_ACCUMULATE(WeightedMask, MAT_TYPES_ACCUMLATE_C,
  72. PERF_ACCUMULATE_MASK_INIT(CV_32FC), accumulateWeighted(src1, dst, 0.123, mask))
  73. PERF_TEST_P_ACCUMULATE(WeightedDouble, MAT_TYPES_ACCUMLATE_D,
  74. PERF_ACCUMULATE_INIT(CV_64FC), accumulateWeighted(src1, dst, 0.123456))
  75. PERF_TEST_P_ACCUMULATE(WeightedDoubleMask, MAT_TYPES_ACCUMLATE_D_C,
  76. PERF_ACCUMULATE_MASK_INIT(CV_64FC), accumulateWeighted(src1, dst, 0.123456, mask))
  77. } // namespace