Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I read image file name using 'fs::directory_iterator' . How can i read this file by using imread in opencv c++

I wrote the following code to read the files from a directory , How can i use the imread function after that?

    string path = "C:/Users/Sam/Images2/";
   for (const auto & p : fs::directory_iterator(path))
   {
       cout << fs::path(p.path()).filename() << " " << " Image " << endl;
      Mat img = imread((fs::path(p.path()).filename()), IMREAD_GRAYSCALE);
}

I read image file name using 'fs::directory_iterator' . How can i read this file by using imread in opencv c++

I wrote the following code to read the files from a directory , How and ' fs::path(p.path()).filename()' this function returns the filename..How can i use the imread function after that?

    string path = "C:/Users/Sam/Images2/";
   for (const auto & p : fs::directory_iterator(path))
   {
       cout << fs::path(p.path()).filename() << " " << " Image " << endl;
      Mat img = imread((fs::path(p.path()).filename()), IMREAD_GRAYSCALE);
}