本文介紹了如何從OpenCV中的目錄中依次讀取文件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我是 OpenCV 的新手.我想讀取目錄中的 XML 文件.我正在使用 FindFirstFile,但我不知道如何獲取文件名以進一步作為 cvLoad 的輸入.這是我正在使用的代碼:
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:
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.
推薦答案
如果您使用的是最新版本的 OpenCV,最好避免使用特定于操作系統的方法:
If you're using a recent version of OpenCV, you're 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.
(哦,再一次,避免不推薦使用的 C-API 函數,比如 cvLoad地獄,拜托?。?
(Ohh, and again, avoid deprecated C-API functions like cvLoad like hell, please!!)
這篇關于如何從OpenCV中的目錄中依次讀取文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!