Use Boost Filesystem for C++. You can load all files in a directory and pass the file location to OpenCV in a string.
string folder = "../images/";
vector<string> imageFileLocations;
namespace fs = boost::filesystem;
vec v;
copy(fs::directory_iterator(folder), fs::directory_iterator(), back_inserter(v));
sort(v.begin(), v.end());
for (vec::const_iterator it(v.begin()); it != v.end(); ++it) {
if (fs::is_regular_file(*it)) {
string location = it->string();
imageFileLocations.push_back(location);
}
}
You'll have to add something recursive to be able to go into other folders. You can do that by checking if the iteraotr is at a file or a folder. See the Boost website for examples.