automatic commit
[folded-ctf.git] / global.h
1 /*
2  *  folded-ctf is an implementation of the folded hierarchy of
3  *  classifiers for object detection, developed by Francois Fleuret
4  *  and Donald Geman.
5  *
6  *  Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of folded-ctf.
10  *
11  *  folded-ctf is free software: you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published
13  *  by the Free Software Foundation, either version 3 of the License,
14  *  or (at your option) any later version.
15  *
16  *  folded-ctf is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with folded-ctf.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25
26 /*
27
28   We stuff all the global values in there.
29
30  */
31
32 #ifndef GLOBAL_H
33 #define GLOBAL_H
34
35 #include <iostream>
36
37 using namespace std;
38
39 #include "misc.h"
40 #include "param_parser.h"
41 #include "progress_bar.h"
42
43 enum { LOSS_EXPONENTIAL,
44        LOSS_HINGE,
45        LOSS_LOGISTIC };
46
47 class Global {
48 public:
49   int niceness;
50   int random_seed;
51   int pictures_for_article;
52
53   char pool_name[buffer_size];
54   char test_pool_name[buffer_size];
55   char detector_name[buffer_size];
56   char result_path[buffer_size];
57
58   int loss_type;
59
60   int nb_images;
61   int material_feature_nb;
62
63   int tree_depth_max;
64
65   int nb_weak_learners_per_classifier;
66   int nb_classifiers_per_level;
67   int nb_levels;
68
69   scalar_t proportion_negative_cells_for_training;
70   int nb_negative_samples_per_positive;
71   int nb_features_for_boosting_optimization;
72   int force_head_belly_independence;
73
74   scalar_t proportion_for_train;
75   scalar_t proportion_for_validation;
76   scalar_t proportion_for_test;
77   bool write_validation_rocs;
78   bool write_parse_images;
79   bool write_tag_images;
80   scalar_t wanted_true_positive_rate;
81   int nb_wanted_true_positive_rates;
82
83   int nb_scales_per_power_of_two;
84   scalar_t min_head_radius;
85   scalar_t max_head_radius;
86   int root_cell_nb_xy_per_radius;
87
88   scalar_t pi_feature_window_min_size;
89
90   ProgressBar bar;
91
92   Global();
93   ~Global();
94
95   void init_parser(ParamParser *parser);
96   void read_parser(ParamParser *parser);
97
98   ostream *log_stream;
99
100   inline int scale_to_discrete_log_scale(scalar_t scale_ratio) {
101     return int(floor(log(scale_ratio) / log(2.0) * nb_scales_per_power_of_two));
102   }
103
104   inline scalar_t discrete_log_scale_to_scale(int discrete_scale) {
105     return exp( - scalar_t(discrete_scale) * log(2.0) / scalar_t(nb_scales_per_power_of_two));
106   }
107 };
108
109 extern Global global;
110
111 #endif