perf_minmaxloc.cpp 874 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "perf_precomp.hpp"
  2. namespace opencv_test
  3. {
  4. using namespace perf;
  5. PERF_TEST_P(Size_MatType, minMaxLoc, testing::Combine(
  6. testing::Values(TYPICAL_MAT_SIZES),
  7. testing::Values(CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1)
  8. )
  9. )
  10. {
  11. Size sz = get<0>(GetParam());
  12. int matType = get<1>(GetParam());
  13. Mat src(sz, matType);
  14. double minVal, maxVal;
  15. Point minLoc, maxLoc;
  16. if (matType == CV_8U)
  17. randu(src, 1, 254 /*do not include 0 and 255 to avoid early exit on 1 byte data*/);
  18. else if (matType == CV_8S)
  19. randu(src, -127, 126);
  20. else
  21. warmup(src, WARMUP_RNG);
  22. declare.in(src);
  23. TEST_CYCLE() minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);
  24. SANITY_CHECK(minVal, 1e-12);
  25. SANITY_CHECK(maxVal, 1e-12);
  26. }
  27. } // namespace