Removed the definition of basename, which confuses an existing system one.
[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 version 3 as   #
16 #  published by the Free Software Foundation.                          #
17 #                                                                      #
18 #  folded-ctf is distributed in the hope that it will be useful, but   #
19 #  WITHOUT ANY WARRANTY; without even the implied warranty of          #
20 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   #
21 #  General Public License for more details.                            #
22 #                                                                      #
23 #  You should have received a copy of the GNU General Public License   #
24 #  along with folded-ctf.  If not, see <http://www.gnu.org/licenses/>. #
25 #                                                                      #
26 ########################################################################
27
28 GRAPH_NAME="/tmp/roc.eps"
29
30 #########################################################################
31
32 echo "Parsing the log files."
33
34 for p in hb h+b; do
35     grep ^INFO results/${p}-*/log  | \
36         awk '{
37                if($2 == "DECIMATED_FALSE_NEGATIVE_RATE") {
38                  printf(1-$3)
39                } else if($2 == "DECIMATED_NB_FALSE_POSITIVES_PER_VGA") {
40                  printf(" "$3"\n")
41                }
42              }' | sort -g > /tmp/${p}
43
44     if [[ ! -s /tmp/${p} ]]; then
45         echo "Not enough data points for ${p}." >&2
46         exit 1
47     fi
48 done
49
50 ######################################################################
51
52 echo "Generating the graph per se."
53
54 gnuplot<<EOF
55   set terminal postscript enhanced eps "Helvetica" 20
56   set key 80,0.25
57   set output "${GRAPH_NAME}"
58   set logscale x
59   set xlabel "Number of false alarms per 640x480"
60   set ylabel "True positive rate"
61   set grid
62
63   plot [1e-3:100][0.0:1.0] \
64      '/tmp/hb' using 2:1 title "HB" pt 7 ps 1.0 lc 1 lw 1,\
65      '/tmp/h+b' using 2:1 title "H+B" pt 7 ps 1.0 lc 3 lw 1
66 EOF
67
68 ######################################################################
69
70 echo "Graph saved in ${GRAPH_NAME}"