#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void get_feature(const std::string &file_path, const std::string &outputname) { std::string cmd; cmd += "../extract/extract_hog "; cmd += file_path; cmd += " "; cmd += outputname; //std::cout << cmd << std::endl; system(cmd.c_str()); } int main() { std::string from_basedir = "../data/train/"; std::string to_basedir = "../hog/"; dirent *ent; DIR *pdir = opendir(from_basedir.c_str()); long cnt = 0; while ((ent = readdir(pdir)) != NULL) { if (strlen(ent->d_name) == 3) { std::string dirname = std::string(ent->d_name) + "/"; DIR *pdir2 = opendir((from_basedir + dirname).c_str()); system((std::string("mkdir ") + to_basedir + dirname).c_str()); dirent *ent2; while ((ent2 = readdir(pdir2)) != NULL) { if (strcmp(ent2->d_name, ".") == 0 || strcmp(ent2->d_name, "..") == 0) continue; std::string imagename = from_basedir + dirname + ent2->d_name; std::string outputname = to_basedir + dirname + ent2->d_name; outputname = outputname.substr(0, outputname.size() - 3) + "hog"; //std::cout << imagename << std::endl << outputname << std::endl; //std::cout << outputname << std::endl; get_feature(imagename, outputname); cnt++; } } } std::cout << cnt << std::endl; return 0; }