How to read files in sequence from a directory in OpenCV?
I am new to OpenCV . I want to read XML files in a directory. I am using FindFirstFile, but I do not understand how I can get the filenames to enter as input to cvLoad. Here is the code I'm using:
HANDLE hFind;
WIN32_FIND_DATA FindFileData;
wchar_t* file = L"D:\\zainb_s\\M.phil\\thesis\\dataset\\dataset_3\\RGB_3\\RGB\\s01_e01- Copy\\1_walking\\depth\\*.xml";
hFind = FindFirstFile(file, &FindFileData);
cout << FindFileData.cFileName[0];
FindClose(hFind);
I want to have the filenames in an array for further reading of the files.
+3
source to share
1 answer
If you are using the newest version of OpenCV you are better off avoiding OS specific methods:
vector<string> fn; // std::string in opencv2.4, but cv::String in 3.0
string path = "e:/code/vlc/faces2/*.png";
cv::glob(path,fn,false);
// Now you got a list of filenames in fn.
(Oh, and again, avoid legacy C-API functions like cvLoad like hell!)
+10
source to share