vs2015下,使用人脸检测算法对FDDB数据集进行测评

来源:互联网 发布:网络运营管理岗 面试 编辑:程序博客网 时间:2024/05/22 16:40


一、所需文件

FDDB官网首页http://vis-www.cs.umass.edu/fddb/下载,Original,unannontated set of images 数据集,Face annotations 标注信息. 

http://vis-www.cs.umass.edu/fddb/results.html 进入download下载页面,下载evaluation评估源码.

二、建立vs工程

建立自己的人脸检测工程,或者在已有的人脸检测工程中加入第一步下载的文件

其中,2002,2003两个文件夹是第一步Original,unannontated set of images 数据集解压出来的两个文件夹,包含所有人脸数据,FDDB-fold-01.txt是把Face annotations中的10个(FDDB-fold-01——FDDB-fold-10)合并成一个txt,FDDB-fold-01-ellipsList.txt是相同的操作.

三、检测

检测的过程就是使用自定义的检测算法,利用数据集的标注信息访问数据集,对数据集进行处理,然后把检测结果保存成txt文件的过程.保存的txt文件格式要按照官网中README中给出的格式,

The corresponding annotations are included in the file "FDDB-fold-xx-ellipseList.txt" in the following format:...<image name i><number of faces in this image =im><face i1><face i2>...<face im>...Here, each face is denoted by:<major_axis_radius minor_axis_radius angle center_x center_y 1>.
就是针对每一张图像保存成
2002/08/11/big/img_5911167 65 202 202 25.5054 2002/08/26/big/img_2653286 78 100 100 15.6361 54 44 100 100 34.7152 153 109 55 55 14.5676 这种格式,第一行表示图像名,第二行表示检测的人脸个数,第三行表示人脸的信息.从左到右依次表示face_x,face_y,face_width,face_height,face_score.
代码为:
string inputName;string dir;ifstream in_txt("FDDB-fold-01.txt");while (!in_txt.eof()){getline(in_txt, inputName);dir = inputName + ".jpg";image = cv::imread(dir, cv::IMREAD_UNCHANGED);if (image.channels() != 1)cv::cvtColor(image, image_gray, cv::COLOR_BGR2GRAY);elseimage_gray = image;faces = detector.Detect(img_data);ofstream out_txt("output.txt", ios::app);out_txt << inputName << endl << faces.size() << endl;out_txt.close();cout << "Image size (wxh): " << img_data.width << "x"<< img_data.height <<"input:"<<inputName<<endl;cv::Rect face_rect;int32_t num_face = static_cast<int32_t>(faces.size());for (int32_t i = 0; i < num_face; i++) {ofstream out_txt1("output.txt", ios::app);out_txt1 << faces[i].bbox.x << " " << faces[i].bbox.y << " " << faces[i].bbox.width << " " << faces[i].bbox.height << " " <<faces[i].score<<" "<<endl;out_txt1.close();}
在自定义的检测算法修改上述代码,可以得到处理后的txt文件,保存后用于评测.
四、评测
这一步需要用到FDDB提供的evaluation评测程序,除此之外还需要两个软件perl和gnuplot.下一步会介绍这两个软件的作用,这一步主要讲解evalution的配置.
新建一个空的工程,把evaluation中的头文件和源文件分别加入工程中,并删除掉以"_"打头的头文件和源文件,配置opencv环境,修改evaluation.cpp中相应文件路径
  string baseDir = "E:/FDDB/data/";
  string listFile = "E:/FDDB/FDDB-folds/FDDB-fold-01.txt";
  string detFile = "E:/MyFaceDetection/Detection/Detection/output.txt";
  string annotFile = "FDDB-fold-01-ellipseList.txt";
运行后生成两个文件tempContROC.txt和tempDiscROC.txt
五、安装perl和gnuplot
根据自己的电脑选择perl版本和gnuplot版本,安装perl后在cmd命令下测试安装是否完成perl -v
修改evaluation下的pl文件,
# where the images aremy $imDir = "E:/FDDB/originalPics/"; # where the folds aremy $fddbDir = "E:/FDDB/FDDB-folds/FDDB-folds/"; # where the detections aremy $detDir = "E:/FDDBEvaluation/evaluation/evaluation"; 
my $gpFile = "E:/FDDBEvaluation/evaluation/evaluation/ContROC.p";my $gpFile1 = "E:/FDDBEvaluation/evaluation/evaluation/DistROC.p";my $title = "YotoFace";# plot the two ROC curves using GNUplotmakeGNUplotFile("E:/FDDBEvaluation/evaluation/evaluation/tempContROC.txt", $gpFile, $title, $detDir."ContROC.png");makeGNUplotFile("E:/FDDBEvaluation/evaluation/evaluation/tempDiscROC.txt", $gpFile1, $title, $detDir."DiscROC.png");
在cmd命令下,输入perl 所在路径/runEvaluate.pl,得到ContROC.p和DistROC.p
六、用gnuplot打开ContROC.p和DistROC.p,得到evaluationContROC.png和evaluationDiscROC.png


阅读全文
0 0
原创粉丝点击