windows下测试人脸检测分类器在FDDB数据库的性能


本文参考

1、首先安装好VS+opencv
2、在FDDB官网上下载图片和标注文件
解压后得到几个文件:
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的整合版,把它们整合到一起
3、建立工程
在Visual Studio中,新建一个项目,把2002文件夹、2003文件夹、Fold_all.txt、Elsp.txt文件移动到下面
4、人脸检测

读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>.
这里要注意detection_score这个值,必须是个有参考意义的分数,不能像它的标注文件一样置为1,否则ROC曲线出不来。
在检测过程中,需要生成一个txt文档。官方文档在这里。
http://vis-www.cs.umass.edu/fddb/README.txt

5、运行评估程序

解压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");
在命令行模式下,运行perl xxxxxxxxxxxx.pl得到ContROC.p与DistROC.p。
7、画ROC曲线

安装GUNPLOT,我装的gp501-win32-mingw。

打开刚才生成的两个.p文件,file->output,将可以看见生成的ROC曲线啦。

或者直接把pl文件拖到里面,然后再file->output,即可看到我们的曲线。



画多条ROC曲线或者更多样式设定,参考 http://blog.csdn.net/watkinsong/article/details/9344775









  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值