perf_dnn_superres.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #include "perf_precomp.hpp"
  5. using namespace std;
  6. using namespace cv;
  7. using namespace perf;
  8. namespace opencv_test { namespace {
  9. typedef perf::TestBaseWithParam<tuple<tuple<string,string,int>, string> > dnn_superres;
  10. #define MODEL testing::Values(tuple<string,string,int> {"espcn","ESPCN_x2.pb",2}, \
  11. tuple<string,string,int> {"lapsrn","LapSRN_x4.pb",4})
  12. #define IMAGES testing::Values("cv/dnn_superres/butterfly.png", "cv/shared/baboon.png", "cv/shared/lena.png")
  13. const string TEST_DIR = "cv/dnn_superres";
  14. PERF_TEST_P(dnn_superres, upsample, testing::Combine(MODEL, IMAGES))
  15. {
  16. tuple<string,string,int> model = get<0>( GetParam() );
  17. string image_name = get<1>( GetParam() );
  18. string model_name = get<0>(model);
  19. string model_filename = get<1>(model);
  20. int scale = get<2>(model);
  21. string model_path = cvtest::findDataFile(TEST_DIR + "/" + model_filename);
  22. string image_path = cvtest::findDataFile(image_name);
  23. DnnSuperResImpl sr;
  24. sr.readModel(model_path);
  25. sr.setModel(model_name, scale);
  26. Mat img = imread(image_path);
  27. ASSERT_FALSE(img.empty()) << image_path;
  28. Mat result;
  29. TEST_CYCLE() { sr.upsample(img, result); }
  30. ASSERT_FALSE(result.empty());
  31. SANITY_CHECK_NOTHING();
  32. }
  33. }}