vs下用FDDB數據測試自己的人臉檢測算法並生成ROC曲線

第一步:下載數據集以及標註文件:
鏈接:https://pan.baidu.com/s/1sm731xj 密碼:5qp1
(這裏是我整合好的,意思就是用fddb官網的全部數據集進行測試)解壓後格式如下:

第二步:用自己的算法生成output.txt文件,代碼如下(這個代碼是用opencv的人臉檢測算法測試的,可對自己的算法在此基礎上稍作修改):http://download.csdn.net/download/yu734390853/10235460
output.txt文件格式(檢測框爲矩形):
第一行:圖片路徑
第二行:人臉個數
第三行:左上頂點座標x y 寬(w) 高(h) detection_score(這個我也不清楚具體表示什麼,其他資料上說:這裏要注意detection_score這個值,必須是個有參考意義的分數,不能像它的標註文件一樣置爲1,否則ROC曲線出不來。)

第三步: 在FDDB官網上下載評估程序:http://vis-www.cs.umass.edu/fddb/evaluation.tgz
把頭文件和源文件添加進來(main函數在evaluate.cpp下)。添加問件時注意下面兩點:
1.一定要添加到當前目錄下,否則會出現連接器錯誤。
2.不要添加./文件(是Ubuntu下的隱藏文件)。
之後修改main函數裏的四個路徑(分別是第一步下載的三個文件(2002和2003算一個,放同一文件夾下),和第二步生成的output.txt文件),如下:

之後再註釋掉以下代碼:

配置opencv,編譯(如果報錯可以百度一下,應該只是些簡單問題),運行,結果會在當前目錄下生成tempContROC.txt和tempDiscROC.txt文件。

第四步:安裝perl與gnuplot
Perl地址:鏈接:https://pan.baidu.com/s/1ggws60z 密碼:0pl7
gnuplot地址:鏈接:https://pan.baidu.com/s/1jJWeo0Q 密碼:nzz3
關於perl的配置,請戳:http://jingyan.baidu.com/article/9f7e7ec0b798ae6f281554e9.html?st=2&os=0&bd_page_type=1&net_type=1
關於gnuplot,沒什麼好講的…就是一路next到底。

第五步:修改runEvaluate.pl(evaluate文件夾下)文件,內容如下(注意路徑要全部改成你的路徑):

#!/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");

之後Windows+r 打開cmd, 在命令行進入runEvaluate.pl所在路徑,再輸入perl runEvaluate.pl 運行,就會在你指定的路徑下生成ContROC.p和DistROC.p文件。
之後打開gnuplot工具,先file(左上角)->output(就是把ContROC.p和DistROC.p文件的路徑給進去),再file->open,打開ContROC.p和DistROC.p文件,生成的ROC曲線即保存在當前路徑下。

有任何問題,歡迎交流QQ:734390853(ゅ≈小魚≈ゅ)…………………………

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章