如何從OpenCV中的目錄順序讀取文件?

[英]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 am not getting how can I get file names to give as input to cvLoad further. Here is the code I am using:

我是OpenCV的新手。我想讀取目錄中的XML文件。我正在使用FindFirstFile,但我沒有得到如何讓文件名作為cvLoad的輸入進一步提供。這是我正在使用的代碼:

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 filenames in an array to read files further to process.

我希望在一個數組中有文件名來進一步讀取文件進行處理。

1 个解决方案

#1


11  

If you're using a recent version of OpenCV, you're better off avoiding OS-specific methods:

如果您使用的是最新版本的OpenCV,最好避免使用特定於操作系統的方法:

vector<string> fn; // std::string in opencv2.4, but cv::String in 3.0string path = "e:/code/vlc/faces2/*.png";cv::glob(path,fn,false);// Now you got a list of filenames in fn.

(Ohh, and again, avoid deprecated C-API functions like cvLoad like hell, please!!)

(哦,再次,請避免像cvLoad這樣的C-API函數,比如地獄!)!


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/10/23/c7eab1c87594a8ec329d96fa5003e66a.html



 
  © 2014-2022 ITdaan.com 联系我们: