Ask Your Question

Revision history [back]

Hi! You can get all the files names of a folder as follows. Thanks to Theodore for his nice answer.

int main()
{
    vector<String> filenames; // notice here that we are using the Opencv's embedded "String" class
    String folder = "<some_folder_path>"; // again we are using the Opencv's embedded "String" class

    glob(folder, filenames); // new function that does the job ;-)

    for(size_t i = 0; i < filenames.size(); ++i)
    {
        Mat src = imread(filenames[i]);

        if(!src.data)
            cerr << "Problem loading image!!!" << endl;

        /* do whatever you want with your images here */
    }
}