Advertisement
frodyan

All files in directory (for OpenCV train)

Jul 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <opencv2/core/core.hpp>
  2. #include <opencv2/highgui/highgui.hpp>
  3. #include <opencv2\imgproc\imgproc.hpp>
  4. #include <fstream>
  5. #include <filesystem>
  6. #include <string>
  7.  
  8. int main()
  9. {
  10.     Mat image;
  11.     std::ofstream data("Bad.dat");
  12.     data.clear();
  13.     for (auto& p : std::experimental::filesystem::directory_iterator("Bad")) //in c++17 std::filesystem::directory_iterator
  14.     {
  15.         std::string path(p.path().string());
  16.         image = imread(path, IMREAD_COLOR);
  17.         //Good:
  18.        // data << p << " 1 0 0 " << image.cols << ' ' << image.rows<<std::endl;
  19.         //Bad:
  20.         data << p << std::endl;
  21.     }
  22.     data.close();
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement