Removed the definition of basename, which confuses an existing system one.
[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 version 3 as
13  *  published by the Free Software Foundation.
14  *
15  *  folded-ctf is distributed in the hope that it will be useful, but
16  *  WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with folded-ctf.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 /*
26
27   We stuff all the global values in there.
28
29  */
30
31 #ifndef GLOBAL_H
32 #define GLOBAL_H
33
34 #include <iostream>
35
36 using namespace std;
37
38 #include "misc.h"
39 #include "param_parser.h"
40 #include "progress_bar.h"
41
42 enum { LOSS_EXPONENTIAL,
43        LOSS_HINGE,
44        LOSS_LOGISTIC };
45
46 class Global {
47 public:
48   int niceness;
49   int random_seed;
50   int pictures_for_article;
51
52   char pool_name[buffer_size];
53   char test_pool_name[buffer_size];
54   char detector_name[buffer_size];
55   char result_path[buffer_size];
56
57   int loss_type;
58
59   int nb_images;
60   int material_feature_nb;
61
62   int tree_depth_max;
63
64   int nb_weak_learners_per_classifier;
65   int nb_classifiers_per_level;
66   int nb_levels;
67
68   scalar_t proportion_negative_cells_for_training;
69   int nb_negative_samples_per_positive;
70   int nb_features_for_boosting_optimization;
71   int force_head_belly_independence;
72
73   scalar_t proportion_for_train;
74   scalar_t proportion_for_validation;
75   scalar_t proportion_for_test;
76   bool write_validation_rocs;
77   bool write_parse_images;
78   bool write_tag_images;
79   scalar_t wanted_true_positive_rate;
80   int nb_wanted_true_positive_rates;
81
82   int nb_scales_per_power_of_two;
83   scalar_t min_head_radius;
84   scalar_t max_head_radius;
85   int root_cell_nb_xy_per_radius;
86
87   scalar_t pi_feature_window_min_size;
88
89   ProgressBar bar;
90
91   Global();
92   ~Global();
93
94   void init_parser(ParamParser *parser);
95   void read_parser(ParamParser *parser);
96
97   ostream *log_stream;
98
99   inline int scale_to_discrete_log_scale(scalar_t scale_ratio) {
100     return int(floor(log(scale_ratio) / log(2.0) * nb_scales_per_power_of_two));
101   }
102
103   inline scalar_t discrete_log_scale_to_scale(int discrete_scale) {
104     return exp( - scalar_t(discrete_scale) * log(2.0) / scalar_t(nb_scales_per_power_of_two));
105   }
106 };
107
108 extern Global global;
109
110 #endif