How to get all images in folder using c++

北城以北 提交于 2019-12-12 08:49:08

问题


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++.


回答1:


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]));


来源:https://stackoverflow.com/questions/31346132/how-to-get-all-images-in-folder-using-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!