您的位置:首页 > 其它

最近调试人脸问题的总结--命令行+抽取第二级子目录的名称

2017-12-17 16:15 246 查看
最近调试人脸识别程序的总结

1. 人脸检测

    人脸检测的阈值是0.7 在外部不允许更改

2. 命令行的程序

    有时候出现点击批处理闪退的情况 比较建议的方式是重写一个bat 文件

    目前没有找到根本原因

    bat 文件里面的路径的方式:

    facedetect.exe E:\data\guoche_gallay\guoche_gallay E:\data\guoche_gallay 

   需要注意的点:路径不是双斜杠 

3.命令行文件的复制问题:

    char* sFile1 = argv[1];

   char* sFile2 = argv[2];

   如果需要转换成int 使用atoi  函数   

char *str = "12345.67";
n = atoi(str);
printf("n=%d\n",n);
http://blog.csdn.net/li6727975/article/details/42875641
4. 抽取倒数第二级如何做到:     

for (int j = 0; j < files_gallary.size(); ++j)
{
img_gallary = imread(files_gallary[j].c_str());
if (img_gallary.empty())
continue;
string szMarkupFilePath = files_gallary[j].c_str();
int last = szMarkupFilePath.find_last_of(".");
int begin1 = szMarkupFilePath.find_last_of("\\");
int begin2 = szMarkupFilePath.find_last_of("/");
int begin3 = szMarkupFilePath.find_last_not_of("\\");
int begin = max(begin1, begin2);
string name = szMarkupFilePath.substr(begin + 1, last - begin - 1 + 4);
string subname_full = szMarkupFilePath.substr(0, begin);
cout << "subname_full " << subname_full << endl;
int last1 = begin;
int begin2_1 = subname_full.find_last_of("\\");
int begin2_2 = subname_full.find_last_of("/");
int begin2_3 = subname_full.find_last_not_of("\\");
int begin22 = max(begin2_1, begin2_2);
string name2 = subname_full.substr(begin22 + 1, last1 - begin22 - 1 + 4);
cout << "name2 " << name2 << endl;
}
需要说明的是subname_full.substr这个函数的第一个为需要抽取的厨师地址,后面是长度

与matlab 中是不同的

    5. 写特征到文件      

FILE *f = fopen(feature_path, "wb");
if (f){
fwrite(pFeature1, EF_Size(), 1, f);
fclose(f);
}
FILE *f1 = fopen(feature_path_beifen, "wb");
if (f1)
{
fwrite(pFeature1, EF_Size(), 1, f);
fclose(f1);
}
  6. 从文件读取特征

     FILE *f = fopen(feature_path, "rb");
if (f)
{
fread(pFeature2, EF_Size(), 1, f);
//fread(pFeature2, 1, EF_Size(), f);     // 这两个用法那个对 需要确认
fclose(f);
}

7. 写数据到文件

    static ofstream file2("first_part_score1.txt");

    file2 << tline.c_str() << " " << label_txt_img.c_str() << " " << score << endl;

8. 读文件

   ifstream infile("first_thread.txt", ios::binary | ios::in);
while (!infile.eof())
{ // 从磁盘文件输入
infile >> tline >> label_txt >> label_txt_img;

   }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐