static Mat createSamplesFromFolder(String pattern, Size resize, int type = CV_8UC1, bool recursive = false)
{
std::vector<cv::String> files;
cv::glob(pattern, files, recursive);
int nFiles = files.size();
Mat img, samples(Size(resize.width*resize.height, nFiles), type);
for (int i = 0; i < nFiles; i++)
{
img = cv::imread(files[i], IMREAD_GRAYSCALE);
cv::resize(img, img, resize, 0, 0, CV_INTER_AREA);
img = img.reshape(1, 1);
img.row(0).copyTo(samples.row(i));
}
return samples;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.