automatic commit
[folded-ctf.git] / parsing_pool.h
diff --git a/parsing_pool.h b/parsing_pool.h
new file mode 100644 (file)
index 0000000..f7b67be
--- /dev/null
@@ -0,0 +1,74 @@
+
+///////////////////////////////////////////////////////////////////////////
+// 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 <http://www.gnu.org/licenses/>.  //
+//                                                                       //
+// Written by Francois Fleuret, (C) IDIAP                                //
+// Contact <francois.fleuret@idiap.ch> for comments & bug reports        //
+///////////////////////////////////////////////////////////////////////////
+
+#ifndef PARSING_POOL_H
+#define PARSING_POOL_H
+
+/*
+
+  A ParsingPool is a family of Parsing associated to all the images of
+  a LabelledImagePool.
+
+*/
+
+#include "parsing.h"
+#include "pi_feature_family.h"
+#include "classifier.h"
+#include "labelled_image_pool.h"
+#include "pose_cell_hierarchy.h"
+
+class ParsingPool {
+  int _nb_images;
+  long int _nb_cells, _nb_positive_cells, _nb_negative_cells;
+  Parsing **_parsings;
+
+public:
+
+  inline int nb_cells() {
+    return _nb_cells;
+  }
+
+  inline int nb_positive_cells() {
+    return _nb_positive_cells;
+  }
+
+  inline int nb_negative_cells() {
+    return _nb_negative_cells;
+  }
+
+  ParsingPool(LabelledImagePool *image_pool, PoseCellHierarchy *hierarchy, scalar_t proportion_negative_cells);
+
+  ~ParsingPool();
+
+  // The parameter level is the resulting level, not the starting one,
+  // hence should always be strictly positive
+  void down_one_level(LossMachine *loss_machine, PoseCellHierarchy *hierarchy, int level);
+
+  void update_cell_responses(PiFeatureFamily *pi_feature_family,
+                             Classifier *classifier);
+
+  // Collect all positive and sample negative examples
+  void weighted_sampling(LossMachine *loss_machine,
+                         PiFeatureFamily *pi_feature_family,
+                         SampleSet *sample_set,
+                         scalar_t *responses);
+
+  void write_roc(ofstream *out);
+};
+
+#endif