如何使用C ++获取文件夹中的所有图像 [英] How to get all images in folder using c++
本文介绍了如何使用C ++获取文件夹中的所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有问题.我正在用openCV库编写C ++.我想获取一个文件夹中所有图像的数量,并想要加载该文件夹中的所有图像以进行C ++处理.
I have a problem. I'm writing C++ with the openCV library. I want to get the number of all images in a folder and I want to load all images in the folder for process in C++.
推荐答案
您可以使用全局以获取文件名列表:
you can use glob to get a list of filenames:
vector<cv::String> fn;
glob("/home/images/*.png", fn, false);
vector<Mat> images;
size_t count = fn.size(); //number of png files in images folder
for (size_t i=0; i<count; i++)
images.push_back(imread(fn[i]));
这篇关于如何使用C ++获取文件夹中的所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文