Create Samples Vector from Folder

static vector<Mat> createSamplesVecFromFolder(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; vector<Mat> samples; for (int i = 0; i < nFiles; i++) { cout << "\r" << i; img = cv::imread(files[i], IMREAD_GRAYSCALE); cv::resize(img, img, resize, 0, 0, CV_INTER_AREA); samples.push_back(img); } cout << endl; 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.