本文参考
2002文件夹、2003文件夹、Fold_all.txt、Elsp.txt、evaluation.tgz、FDDB-folds.tgz、
其中2002文件夹和2003文件夹是解压originalPics.tar.gz得到的。
而关于Fold_all.txt与Elsp.txt,则是FDDB-folds.tgz中的各个10个txt的整合版,把它们整合到一起
读Fold.txt文件,依照顺序做人脸检测,将检测结果输出出来,格式如下:
<image name i>
<number of faces in this image =im>
<face i1>
<face i2>
...
<face im>
<face im>的表达形式有以下两种:
4 a. Rectangular regions
Each face region is represented as:
<left_x top_y width height detection_score>
4 b. Elliptical regions
Each face region is represented as:
<major_axis_radius minor_axis_radius angle center_x center_y detection_score>.
http://vis-www.cs.umass.edu/fddb/README.txt
解压evaluation.tgz,将其源文件和头文件包含在工程中,添加OpenCV的属性表。
然后做以下修改:
在evaluate.cpp中的main函数,把第235行改为如下,即在max前面添加括号,否则会冲突。
Results *r = new Results(imName, (std::numeric_limits<double>::max)(), NULL, annot, det);
在项目的属性栏中做如下改动:
把下面代码中路径改成自己的:
#ifdef _WIN32
string baseDir = "F:/MachineLearningVisualApplicationGroup/face_detect/face_lib/";
string listFile = "F:/MachineLearningVisualApplicationGroup/face_detect/name.txt";
string detFile = "F:/MachineLearningVisualApplicationGroup/face_detect/data.txt";
string annotFile = "F:/MachineLearningVisualApplicationGroup/face_detect/data0.txt";
还要注意 detFormat = DET_RECTANGLE; 如果你的检测输出是椭圆,这里就要改成椭圆。
编译通过,生成解决方案。
找到生成的 .exe文件,在命令行里运行,根据提示输入对应文件的路径。我的如下所示:
FDDBTest2.exe -a F:/MachineLearningVisualApplicationGroup/face_detect/data0.tx -d F:/MachineLearningVisualApplicationGroup/face_detect/data.txt -l F:/MachineLearningVisualApplicationGroup/face_detect/face_lib/
运行结束之后,生成两个ROC文件:
DiscRoc.txt和ContRoc.txt,这就是最终要画图ROC的数据。
6、生成ROC图数据
安装perl,关于perl的配置,请戳:http://jingyan.baidu.com/article/9f7e7ec0b798ae6f281554e9.html?st=2&os=0&bd_page_type=1&net_type=1
安装好之后,修改原来的一个用于评测的pl文件:
#!/usr/bin/perl -w
use strict;
#### VARIABLES TO EDIT ####
# where gnuplot is
my $GNUPLOT = "D:/gnuplot/bin/gnuplot";
# where the binary is
my $evaluateBin = "evaluate";
# where the images are
my $imDir = "F:/soft/c++/Test_FDDB/Test_FDDB"; #FDDB数据库的图片在哪
# where the folds are
my $fddbDir = "F:/soft/c++/Test_FDDB/Test_FDDB/FDDB-Folds"; #fddb图片的两个txt
# where the detections are
my $detDir = "C:/Users/strstr/Desktop/FDDB_DRAW/Filep/"; #图片存放的位置
###########################
my $detFormat = 0; # 0: rectangle, 1: ellipse 2: pixels
sub makeGNUplotFile
{
my $rocFile = shift;
my $gnuplotFile = shift;
my $title = shift;
my $pngFile = shift;
open(GF, ">$gnuplotFile") or die "Can not open $gnuplotFile for writing\n";
#print GF "$GNUPLOT\n";
print GF "set term png\n";
print GF "set size 1,1\n";
print GF "set output \"$pngFile\"\n";
#print GF "set xtics 500\n";
print GF "set ytics 0.1\n";
print GF "set grid\n";
#print GF "set size ratio -1\n";
print GF "set ylabel \"True positive rate\"\n";
print GF "set xlabel \"False positives\"\n";
#print GF "set xr [0:2000]\n";
print GF "set yr [0:1.0]\n";
print GF "set key right bottom\n";
print GF "plot \"$rocFile\" using 2:1 title \"$title\" with lines lw 2 \n";
close(GF);
}
my $gpFile = "C:/Users/strstr/Desktop/FDDB_DRAW/Filep/ContROC.p";
my $gpFile1 = "C:/Users/strstr/Desktop/FDDB_DRAW/Filep/DistROC.p";
my $title = "YotoFace";
# plot the two ROC curves using GNUplot
makeGNUplotFile("C:/Users/strstr/Desktop/FDDB_DRAW/tempContROC.txt", $gpFile, $title, $detDir."ContROC.png");
makeGNUplotFile("C:/Users/strstr/Desktop/FDDB_DRAW/tempDiscROC.txt", $gpFile1, $title, $detDir."DiscROC.png");
安装GUNPLOT,我装的gp501-win32-mingw。
打开刚才生成的两个.p文件,file->output,将可以看见生成的ROC曲线啦。