X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=detector.h;fp=detector.h;h=72248af1aa524cc8c39cd04e06bbce16a74dfdbe;hb=d922ad61d35e9a6996730bec24b16f8bf7bc426c;hp=0000000000000000000000000000000000000000;hpb=3bb118f5a9462d02ff7d99ef28ecc0d7e23529f9;p=folded-ctf.git diff --git a/detector.h b/detector.h new file mode 100644 index 0000000..72248af --- /dev/null +++ b/detector.h @@ -0,0 +1,76 @@ + +/////////////////////////////////////////////////////////////////////////// +// This program is free software: you can redistribute it and/or modify // +// it under the terms of the version 3 of the GNU General Public License // +// as published by the Free Software Foundation. // +// // +// This program is distributed in the hope that it will be useful, but // +// WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +// General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +// // +// Written by Francois Fleuret, (C) IDIAP // +// Contact for comments & bug reports // +/////////////////////////////////////////////////////////////////////////// + +/* + + This is the main class, a folded hierarchy of classifiers. + +*/ + +#ifndef DETECTOR_H +#define DETECTOR_H + +#include "storable.h" +#include "boosted_classifier.h" +#include "labelled_image_pool.h" +#include "parsing_pool.h" +#include "pose_cell_scored_set.h" + +class Detector : public Storable { +public: + PoseCellHierarchy *_hierarchy; + int _nb_levels, _nb_classifiers_per_level, _nb_classifiers; + scalar_t *_thresholds; + Classifier **_classifiers; + PiFeatureFamily **_pi_feature_families; + + void free(); + + virtual void train_classifier(int level, + LossMachine *loss_machine, + ParsingPool *parsing, + PiFeatureFamily *pi_feature_family, + Classifier *classifier); + + virtual void parse_rec(RichImage *image, int level, + PoseCell *cell, scalar_t response, + PoseCellScoredSet *result); + +public: + + Detector(); + virtual ~Detector(); + + inline int nb_levels() { return _nb_levels; } + + // The validation set is only used to save ROCs curves during + // training for monitoring the learning + + virtual void train(LabelledImagePool *train_pool, + LabelledImagePool *validation_pool, + LabelledImagePool *hierarchy_pool); + + virtual void compute_thresholds(LabelledImagePool *validation_pool, scalar_t wanted_tp); + + virtual void parse(RichImage *image, PoseCellScoredSet *result_cell_set); + + virtual void read(istream *is); + virtual void write(ostream *os); +}; + +#endif