sr_bsds.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_bsds.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 (images, iids_train.txt, iids_test.txt) }";
  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_bsds> dataset = SR_bsds::create();
  25. dataset->load(path);
  26. // ***************
  27. // Dataset train & test contain names of appropriate images.
  28. // For example, let's output full path & name for first train and test images.
  29. // And dataset sizes.
  30. printf("train size: %u\n", (unsigned int)dataset->getTrain().size());
  31. printf("test size: %u\n", (unsigned int)dataset->getTest().size());
  32. SR_bsdsObj *example1 = static_cast<SR_bsdsObj *>(dataset->getTrain()[0].get());
  33. string fullPath(path + "images/train/" + example1->imageName + ".jpg");
  34. printf("first train image: %s\n", fullPath.c_str());
  35. SR_bsdsObj *example2 = static_cast<SR_bsdsObj *>(dataset->getTest()[0].get());
  36. fullPath = path + "images/test/" + example2->imageName + ".jpg";
  37. printf("first test image: %s\n", fullPath.c_str());
  38. return 0;
  39. }