sr_div2k.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 "opencv2/datasets/sr_div2k.hpp"
  5. #include <opencv2/core.hpp>
  6. #include <cstdio>
  7. #include <string>
  8. #include <vector>
  9. using namespace std;
  10. using namespace cv;
  11. using namespace cv::datasets;
  12. int main(int argc, char *argv[])
  13. {
  14. const char *keys =
  15. "{ help h usage ? | | show this message }"
  16. "{ path p |true| path to dataset (Div2k dataset folder containing the images) }";
  17. CommandLineParser parser(argc, argv, keys);
  18. string path(parser.get<string>("path"));
  19. if (parser.has("help") || path=="true")
  20. {
  21. parser.printMessage();
  22. return -1;
  23. }
  24. Ptr<SR_div2k> dataset = SR_div2k::create();
  25. dataset->load(path);
  26. // ***************
  27. // Dataset contains all images.
  28. // For example, let's output dataset size; first image name; and second image full path.
  29. printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size());
  30. SR_div2kObj *example = static_cast<SR_div2kObj *>(dataset->getTrain()[0].get());
  31. printf("first image name: %s\n", example->imageName.c_str());
  32. SR_div2kObj *example2 = static_cast<SR_div2kObj *>(dataset->getTrain()[1].get());
  33. string fullPath = path + "/" + example2->imageName.c_str();
  34. printf("second image full path: %s\n", fullPath.c_str());
  35. return 0;
  36. }