c++读取训练,测试数据

#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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值