perf_convertTo.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "perf_precomp.hpp"
  2. namespace opencv_test
  3. {
  4. using namespace perf;
  5. typedef tuple<Size, MatType, MatType, int, double> Size_DepthSrc_DepthDst_Channels_alpha_t;
  6. typedef perf::TestBaseWithParam<Size_DepthSrc_DepthDst_Channels_alpha_t> Size_DepthSrc_DepthDst_Channels_alpha;
  7. PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,
  8. testing::Combine
  9. (
  10. testing::Values(szVGA, sz1080p),
  11. testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
  12. testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),
  13. testing::Values(1, 4),
  14. testing::Values(1.0, 1./255)
  15. )
  16. )
  17. {
  18. Size sz = get<0>(GetParam());
  19. int depthSrc = get<1>(GetParam());
  20. int depthDst = get<2>(GetParam());
  21. int channels = get<3>(GetParam());
  22. double alpha = get<4>(GetParam());
  23. int maxValue = 255;
  24. Mat src(sz, CV_MAKETYPE(depthSrc, channels));
  25. randu(src, 0, maxValue);
  26. Mat dst(sz, CV_MAKETYPE(depthDst, channels));
  27. int runs = (sz.width <= 640) ? 8 : 1;
  28. TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha);
  29. double eps = depthSrc <= CV_32S && (depthDst <= CV_32S || depthDst == CV_64F) ? 1e-12 : (FLT_EPSILON * maxValue);
  30. eps = eps * std::max(1.0, fabs(alpha));
  31. SANITY_CHECK(dst, eps);
  32. }
  33. } // namespace