2 ///////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify //
4 // it under the terms of the version 3 of the GNU General Public License //
5 // as published by the Free Software Foundation. //
7 // This program is distributed in the hope that it will be useful, but //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
10 // General Public License for more details. //
12 // You should have received a copy of the GNU General Public License //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
15 // Written by Francois Fleuret //
16 // (C) Idiap Research Institute //
18 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
19 ///////////////////////////////////////////////////////////////////////////
23 This is the main class, a detector as a folded hierarchy of
32 #include "boosted_classifier.h"
33 #include "labelled_image_pool.h"
34 #include "parsing_pool.h"
35 #include "pose_cell_scored_set.h"
37 class Detector : public Storable {
39 PoseCellHierarchy *_hierarchy;
40 int _nb_levels, _nb_classifiers_per_level, _nb_classifiers;
41 scalar_t *_thresholds;
42 Classifier **_classifiers;
43 PiFeatureFamily **_pi_feature_families;
47 virtual void train_classifier(int level,
48 LossMachine *loss_machine,
50 PiFeatureFamily *pi_feature_family,
51 Classifier *classifier);
53 virtual void parse_rec(RichImage *image, int level,
54 PoseCell *cell, scalar_t response,
55 PoseCellScoredSet *result);
62 inline int nb_levels() { return _nb_levels; }
64 // The validation set is only used to save ROCs curves during
65 // training for monitoring the learning
67 virtual void train(LabelledImagePool *train_pool,
68 LabelledImagePool *validation_pool,
69 LabelledImagePool *hierarchy_pool);
71 // Compute the thresholds at the various levels to reach the desired
72 // overall true positive rate
74 virtual void compute_thresholds(LabelledImagePool *validation_pool, scalar_t wanted_tp);
76 virtual void parse(RichImage *image, PoseCellScoredSet *result_cell_set);
78 virtual void read(istream *is);
79 virtual void write(ostream *os);