c 语言小技巧之二 自动创建目录
2017-09-04 16:33
232 查看
int main()
{
bool first = true;
double average = 0.0;
fstream fout;
fout.open("log2017904.txt", ios::app | ios::out);
int noface = 0;
char imgpath[260];
char imgpath2[260];
string imagefolder_path = "E:\\face_data\\CASIA-WebFace";
// vector<string> files;
// getFiles("E:\\face_data\\CASIA-WebFace", files);
int label = 0;
fstream fin;
fin.open("E:\\face_data\\cleaned list-casia.txt", ios::in || ios::app);
string stemp;
while (!fin.eof())
{
fin >> stemp >>label;
cout << "stemp " << stemp << endl;
sprintf(imgpath, "%s/%s", imagefolder_path.c_str(), stemp.c_str());
Mat img = imread(imgpath);
imshow("img", img);
cvWaitKey(3);
int last = stemp.find_last_of(".");
int begin1 = stemp.find_last_of("\\");
int begin2 = stemp.find_last_of("/");
int begin = max(begin1, begin2);
string sub_path = stemp.substr(0, begin);
string name_image = stemp.substr(begin + 1, last - begin - 1);
cout << "name " << name_image << endl;
int facecount = FD_Detect(FD_handle, img.data, img.cols, img.rows, rect);
if (facecount > 0)
{
char dir[260];
sprintf(dir, "5K_new_20170901//%s", sub_path.c_str());
if (_access(dir, 0) == -1)
{
_mkdir(dir);
/*for (int i = 0; i < 2; i++)
{
sprintf(dir, "5K_new_20170901//%d", i);
_mkdir(dir);
}*/
}
//sprintf(imgpath2, "5K_new_20170901\\%s\\%s.jpg", name.c_str(), name_image.c_str())
sprintf(imgpath2, "5K_new_20170901\\%s",stemp.c_str());
cout << "imgpath2" << imgpath2 << endl;
FF_FeaExtract(FF_handle, img.data, img.cols, img.rows, feature, rect[0], imgpath2);
}
else
{
noface++;
fout << "no facecount" << endl;
}
}
system("pause");
// fout << imgpath << endl;
FD_Destroy(FD_handle);
delete[] rect;
return 1;
}
{
bool first = true;
double average = 0.0;
fstream fout;
fout.open("log2017904.txt", ios::app | ios::out);
int noface = 0;
char imgpath[260];
char imgpath2[260];
string imagefolder_path = "E:\\face_data\\CASIA-WebFace";
// vector<string> files;
// getFiles("E:\\face_data\\CASIA-WebFace", files);
int label = 0;
fstream fin;
fin.open("E:\\face_data\\cleaned list-casia.txt", ios::in || ios::app);
string stemp;
while (!fin.eof())
{
fin >> stemp >>label;
cout << "stemp " << stemp << endl;
sprintf(imgpath, "%s/%s", imagefolder_path.c_str(), stemp.c_str());
Mat img = imread(imgpath);
imshow("img", img);
cvWaitKey(3);
int last = stemp.find_last_of(".");
int begin1 = stemp.find_last_of("\\");
int begin2 = stemp.find_last_of("/");
int begin = max(begin1, begin2);
string sub_path = stemp.substr(0, begin);
string name_image = stemp.substr(begin + 1, last - begin - 1);
cout << "name " << name_image << endl;
int facecount = FD_Detect(FD_handle, img.data, img.cols, img.rows, rect);
if (facecount > 0)
{
char dir[260];
sprintf(dir, "5K_new_20170901//%s", sub_path.c_str());
if (_access(dir, 0) == -1)
{
_mkdir(dir);
/*for (int i = 0; i < 2; i++)
{
sprintf(dir, "5K_new_20170901//%d", i);
_mkdir(dir);
}*/
}
//sprintf(imgpath2, "5K_new_20170901\\%s\\%s.jpg", name.c_str(), name_image.c_str())
sprintf(imgpath2, "5K_new_20170901\\%s",stemp.c_str());
cout << "imgpath2" << imgpath2 << endl;
FF_FeaExtract(FF_handle, img.data, img.cols, img.rows, feature, rect[0], imgpath2);
}
else
{
noface++;
fout << "no facecount" << endl;
}
}
system("pause");
// fout << imgpath << endl;
FD_Destroy(FD_handle);
delete[] rect;
return 1;
}
相关文章推荐
- OneNote利器——让你的OneNote自动创建目录索引
- Java自动创建多层文件目录
- Linux系统下创建任务,对指定目录文件进行自动压缩存档
- java File 自动创建所有目录
- 自动创建目录
- 自动创建文件(包含没有文件父目录,自动创建)
- 一个可以自动创建多级目录的函数
- Maven项目目录结构与自动创建maven目录
- Visual Studio使用技巧笔记(引用程序集自动复制dll到引用项目目录)
- maven3—自动创建目录骨架,maven中的坐标和仓库
- 【qtp脚本】实现自动创建目录并通过测试写字板生成指定个数的文件
- 自动创建目录骨架
- 安卓手机或者平板文件系统中出现自动创建 SDCARD/JOY 目录的解决办法
- ThinkPHP3.2.3 - 绑定默认应用目录,并自动创建
- Sql2005自动备份并邮件通知状态之二创建维护计划
- mac系统下用zend framework 自动创建目录结构
- PHP目录与文件操作技巧总结(创建,删除,遍历,读写,修改等)
- linux创建账户并自动生成主目录和主目录下的文件
- 使用visual studio自动创建IIS虚拟目录
- 递归自动创建级联目录