void splitStr(const std::string& s, std::vector<std::string>& v, const std::string& c){
std::string::size_type pos1, pos2;
pos2 = s.find(c);
pos1 = 0;
while (std::string::npos != pos2)
{
v.push_back(s.substr(pos1, pos2 - pos1));
pos1 = pos2 + c.size();
pos2 = s.find(c, pos1);
}
if (pos1 != s.length())
v.push_back(s.substr(pos1));
}
//获取特定格式的图像文件名
void GetAllImgFiles(string path, vector<string>& imgFiles){
cv::glob(path, imgFiles, true);
}
//获取的文件名
void GetAllFiles(string path, vector<string>& fileDirs, vector<string>& fileNames) {
intptr_t hFile = 0; //文件信息
struct _finddata_t fileinfo;//用来存储文件信息的结构体
string p;
if((hFile = _findfirst(p.assign(path).append("\\*").c_str(),&fileinfo)) != -1){ //第一次查找
do{
if((fileinfo.attrib & _A_SUBDIR)){ //如果查找到的是文件夹
if(strcmp(fileinfo.name,".") != 0 && strcmp(fileinfo.name,"..") != 0){ //进入文件夹查找
GetAllFiles( p.assign(path).append("\\").append(fileinfo.name), fileDirs, fileNames);
}
}
else{ //如果查找到的不是是文件夹
fileNames.push_back(p.assign(fileinfo.name)); //将文件路径保存,也可以只保存文件名:
fileDirs.push_back(p.assign(path).append("\\").append(fileinfo.name));
}
}while(_findnext(hFile, &fileinfo) == 0);
_findclose(hFile); //结束查找
}
}
02-24
2293
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-12
588
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-02
969
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)