#include <iostream>
#include <string>
#include <vector>
#include <dirent.h>
using namespace std;
std::vector<std::string> get_mesh(std::string folder_path, string phase){
struct dirent *ptr;
//string phase = "train";
//std::string folder_path = "/home/lnf297/Desktop/flk/shrec";
std::vector<std::string> subfolders;
std::vector<std::string> meshes;
DIR* dir = opendir(folder_path.c_str());
if (dir) {
dirent* entry;
while ((entry = readdir(dir)) != nullptr) {
if (entry->d_type == DT_DIR && std::string(entry->d_name) != "." && std::string(entry->d_name) != "..") {
subfolders.push_back(entry->d_name);
}
}
closedir(dir);
} else {
std::cerr << "Error opening folder " << folder_path << std::endl;
}
for(int i = 0; i < subfolders.size(); i++){
std::string path = folder_path + "/" + subfolders[i] + "/" + phase;
const char *phase3=path.data();
dir = opendir(phase3);
vector<string> files;
while((ptr=readdir(dir))!=NULL)
{
//跳过'.'和'..'两个目录
if(ptr->d_name[0] == '.')
continue;
//cout << ptr->d_name << endl;
string path_onj = path + "/" + ptr->d_name;
meshes.push_back(path_onj);
//files.push_back(ptr->d_name);
}
}
return meshes;
}
int main() {
std::vector<std::string> path;
path = get_mesh("/home/lnf297/Desktop/flk/shrec", "train");
cout <<"hello" << path.size() << endl;
}
c++读取训练,测试数据
最新推荐文章于 2023-03-11 16:52:39 发布