opencv 获取一个目录下子目录_如何从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:

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.

解决方案

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

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值