perf_merge.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "perf_precomp.hpp"
  2. namespace opencv_test
  3. {
  4. using namespace perf;
  5. typedef tuple<Size, MatType, int> Size_SrcDepth_DstChannels_t;
  6. typedef perf::TestBaseWithParam<Size_SrcDepth_DstChannels_t> Size_SrcDepth_DstChannels;
  7. PERF_TEST_P( Size_SrcDepth_DstChannels, merge,
  8. testing::Combine
  9. (
  10. testing::Values(TYPICAL_MAT_SIZES),
  11. testing::Values(CV_8U, CV_16S, CV_32S, CV_32F, CV_64F),
  12. testing::Values(2, 3, 4)
  13. )
  14. )
  15. {
  16. Size sz = get<0>(GetParam());
  17. int srcDepth = get<1>(GetParam());
  18. int dstChannels = get<2>(GetParam());
  19. int maxValue = 255;
  20. vector<Mat> mv;
  21. for( int i = 0; i < dstChannels; ++i )
  22. {
  23. mv.push_back( Mat(sz, CV_MAKETYPE(srcDepth, 1)) );
  24. randu(mv[i], 0, maxValue);
  25. }
  26. Mat dst;
  27. int runs = (sz.width <= 640) ? 8 : 1;
  28. TEST_CYCLE_MULTIRUN(runs) merge( (vector<Mat> &)mv, dst );
  29. double eps = srcDepth <= CV_32S ? 1e-12 : (FLT_EPSILON * maxValue);
  30. SANITY_CHECK(dst, eps);
  31. }
  32. } // namespace