perf_inpaint.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "perf_precomp.hpp"
  2. namespace opencv_test
  3. {
  4. CV_ENUM(InpaintingMethod, INPAINT_NS, INPAINT_TELEA)
  5. typedef tuple<Size, InpaintingMethod> InpaintArea_InpaintingMethod_t;
  6. typedef perf::TestBaseWithParam<InpaintArea_InpaintingMethod_t> InpaintArea_InpaintingMethod;
  7. typedef perf::TestBaseWithParam<InpaintingMethod> Perf_InpaintingMethod;
  8. PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint,
  9. testing::Combine(
  10. testing::Values(::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64),
  11. InpaintingMethod::all()
  12. )
  13. )
  14. {
  15. Mat src = imread(getDataPath("gpu/hog/road.png"));
  16. Size sz = get<0>(GetParam());
  17. int inpaintingMethod = get<1>(GetParam());
  18. Mat mask(src.size(), CV_8UC1, Scalar(0));
  19. Mat result(src.size(), src.type());
  20. Rect inpaintArea(src.cols/3, src.rows/3, sz.width, sz.height);
  21. mask(inpaintArea).setTo(255);
  22. declare.in(src, mask).out(result).time(120);
  23. TEST_CYCLE() inpaint(src, mask, result, 10.0, inpaintingMethod);
  24. Mat inpaintedArea = result(inpaintArea);
  25. SANITY_CHECK(inpaintedArea);
  26. }
  27. PERF_TEST_P(Perf_InpaintingMethod, inpaintDots, InpaintingMethod::all())
  28. {
  29. Mat src = imread(getDataPath("gpu/hog/road.png"));
  30. int inpaintingMethod = GetParam();
  31. Mat mask(src.size(), CV_8UC1, Scalar(0));
  32. Mat result(src.size(), src.type());
  33. for (int i = 0; i < src.size().height; i += 16) {
  34. for (int j = 0; j < src.size().width; j += 16) {
  35. mask.at<unsigned char>(i, j) = 255;
  36. }
  37. }
  38. declare.in(src, mask).out(result).time(120);
  39. TEST_CYCLE() inpaint(src, mask, result, 10.0, inpaintingMethod);
  40. SANITY_CHECK_NOTHING();
  41. }
  42. } // namespace