perf_addWeighted.cpp 992 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "perf_precomp.hpp"
  2. namespace opencv_test
  3. {
  4. using namespace perf;
  5. #define TYPICAL_MAT_TYPES_ADWEIGHTED CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1
  6. #define TYPICAL_MATS_ADWEIGHTED testing::Combine(testing::Values(szVGA, sz720p, sz1080p), testing::Values(TYPICAL_MAT_TYPES_ADWEIGHTED))
  7. PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED)
  8. {
  9. Size size = get<0>(GetParam());
  10. int type = get<1>(GetParam());
  11. int depth = CV_MAT_DEPTH(type);
  12. Mat src1(size, type);
  13. Mat src2(size, type);
  14. double alpha = 3.75;
  15. double beta = -0.125;
  16. double gamma = 100.0;
  17. Mat dst(size, type);
  18. declare.in(src1, src2, dst, WARMUP_RNG).out(dst);
  19. if (depth == CV_32S)
  20. {
  21. // there might be not enough precision for integers
  22. src1 /= 2048;
  23. src2 /= 2048;
  24. }
  25. TEST_CYCLE() cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() );
  26. SANITY_CHECK(dst, depth == CV_32S ? 4 : 1);
  27. }
  28. } // namespace