Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

with the help of glob it is pretty easy:

cv::String path("lfw3d_9000/*.jpg"); //select only jpg
vector<cv::String> fn;
vector<cv::Mat> data;
cv::glob(path,fn,true); // recurse
for (size_t k=0; k<fn.size(); ++k)
{
     cv::Mat im = cv::imread(fn[k], 0);
     data.push_back(im);
}

with the help of glob it is pretty easy:

cv::String path("lfw3d_9000/*.jpg"); //select only jpg
vector<cv::String> fn;
vector<cv::Mat> data;
cv::glob(path,fn,true); // recurse
for (size_t k=0; k<fn.size(); ++k)
{
     cv::Mat im = cv::imread(fn[k], 0);
     // you probably want to do some preprocessing
     data.push_back(im);
}

with the help of glob it is pretty easy:

cv::String path("lfw3d_9000/*.jpg"); //select only jpg
vector<cv::String> fn;
vector<cv::Mat> data;
cv::glob(path,fn,true); // recurse
for (size_t k=0; k<fn.size(); ++k)
{
     cv::Mat im = cv::imread(fn[k], 0);
cv::imread(fn[k]);
     // you probably want to do some preprocessing
     data.push_back(im);
}

with the help of glob it is pretty easy:

cv::String path("lfw3d_9000/*.jpg"); //select only jpg
vector<cv::String> fn;
vector<cv::Mat> data;
cv::glob(path,fn,true); // recurse
for (size_t k=0; k<fn.size(); ++k)
{
     cv::Mat im = cv::imread(fn[k]);
     if (im.empty()) continue; //img might still be corrupt
     // you probably want to do some preprocessing
     data.push_back(im);
}

with the help of glob it is pretty easy:

cv::String path("lfw3d_9000/*.jpg"); //select only jpg
vector<cv::String> fn;
vector<cv::Mat> data;
cv::glob(path,fn,true); // recurse
for (size_t k=0; k<fn.size(); ++k)
{
     cv::Mat im = cv::imread(fn[k]);
     if (im.empty()) continue; //img might still be corrupt
//only proceed if sucsessful
     // you probably want to do some preprocessing
     data.push_back(im);
}