Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all images in folder using 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++.

like image 737
Nungning Avatar asked Jul 10 '15 16:07

Nungning


People also ask

How to get all images from folder in c#?

Have a look at the DirectoryInfo. GetFiles overload that takes a SearchOption argument and pass SearchOption. AllDirectories to get the files including all sub-directories.

How do I get a list of images in a specific folder on Android?

You can use below code to get all images from specific folder. 1) First you need to define File object to get the storage and appened the name of the folder you want to read. File folder = new File(Environment. getExternalStorageDirectory().


1 Answers

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]));
like image 129
berak Avatar answered Oct 09 '22 21:10

berak