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);
}