sr_general100.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_general100.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 (General-100 dataset folder) }";
  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_general100> dataset = SR_general100::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_general100Obj *example = static_cast<SR_general100Obj *>(dataset->getTrain()[0].get());
  31. printf("first image name: %s\n", example->imageName.c_str());
  32. SR_general100Obj *example2 = static_cast<SR_general100Obj *>(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. }