automatic commit
[folded-ctf.git] / graph.sh
1 #!/bin/bash
2
3 ########################################################################
4 #                                                                      #
5 #  folded-ctf is an implementation of the folded hierarchy of          #
6 #  classifiers for object detection, developed by Francois Fleuret     #
7 #  and Donald Geman.                                                   #
8 #                                                                      #
9 #  Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/   #
10 #  Written by Francois Fleuret <francois.fleuret@idiap.ch>             #
11 #                                                                      #
12 #  This file is part of folded-ctf.                                    #
13 #                                                                      #
14 #  folded-ctf is free software: you can redistribute it and/or modify  #
15 #  it under the terms of the GNU General Public License as published   #
16 #  by the Free Software Foundation, either version 3 of the License,   #
17 #  or (at your option) any later version.                              #
18 #                                                                      #
19 #  folded-ctf is distributed in the hope that it will be useful, but   #
20 #  WITHOUT ANY WARRANTY; without even the implied warranty of          #
21 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   #
22 #  General Public License for more details.                            #
23 #                                                                      #
24 #  You should have received a copy of the GNU General Public License   #
25 #  along with folded-ctf.  If not, see <http://www.gnu.org/licenses/>. #
26 #                                                                      #
27 ########################################################################
28
29 GRAPH_NAME="/tmp/roc.eps"
30
31 #########################################################################
32
33 echo "Parsing the log files."
34
35 for p in hb h+b; do
36     grep ^INFO results/${p}-*/log  | \
37         awk '{
38                if($2 == "DECIMATED_FALSE_NEGATIVE_RATE") {
39                  printf(1-$3)
40                } else if($2 == "DECIMATED_NB_FALSE_POSITIVES_PER_VGA") {
41                  printf(" "$3"\n")
42                }
43              }' | sort -g > /tmp/${p}
44
45     if [[ ! -s /tmp/${p} ]]; then
46         echo "Not enough data points for ${p}." >&2
47         exit 1
48     fi
49 done
50
51 ######################################################################
52
53 echo "Generating the graph per se."
54
55 gnuplot<<EOF
56   set terminal postscript enhanced eps "Helvetica" 20
57   set key 80,0.25
58   set output "${GRAPH_NAME}"
59   set logscale x
60   set xlabel "Number of false alarms per 640x480"
61   set ylabel "True positive rate"
62   set grid
63
64   plot [1e-3:100][0.0:1.0] \
65      '/tmp/hb' using 2:1 title "HB" pt 7 ps 1.0 lc 1 lw 1,\
66      '/tmp/h+b' using 2:1 title "H+B" pt 7 ps 1.0 lc 3 lw 1
67 EOF
68
69 ######################################################################
70
71 echo "Graph saved in ${GRAPH_NAME}"