automatic commit
[folded-ctf.git] / parsing.h
1
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.                         //
6 //                                                                       //
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.                              //
11 //                                                                       //
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/>.  //
14 //                                                                       //
15 // Written by Francois Fleuret                                           //
16 // (C) Idiap Research Institute                                          //
17 //                                                                       //
18 // Contact <francois.fleuret@idiap.ch> for comments & bug reports        //
19 ///////////////////////////////////////////////////////////////////////////
20
21 #ifndef PARSING_H
22 #define PARSING_H
23
24 /*
25
26   A Parsing is associated to a LabelledImage and stores responses over
27   cells.
28
29 */
30
31 #include "fusion_sort.h"
32 #include "pose_cell_hierarchy.h"
33 #include "classifier.h"
34 #include "labelled_image.h"
35
36 class Parsing {
37   LabelledImagePool *_image_pool;
38   int _image_index;
39   int _nb_cells, _nb_positives, _nb_negatives;
40
41   PoseCell *_cells;
42   scalar_t *_responses;
43   int *_labels;
44
45 public:
46
47   Parsing(LabelledImagePool *image_pool,
48           PoseCellHierarchy *hierarchy,
49           scalar_t proportion_negative_cells,
50           int image_index);
51
52   ~Parsing();
53
54   //////////////////////////////////////////////////////////////////////
55
56   inline int nb_cells() {
57     return _nb_cells;
58   }
59
60   inline int nb_positive_cells() {
61     return _nb_positives;
62   }
63
64   inline int nb_negative_cells() {
65     return _nb_negatives;
66   }
67
68   inline scalar_t response(int c) {
69     ASSERT(c >= 0 && c < _nb_cells);
70     return _responses[c];
71   }
72
73   inline int label(int c) {
74     ASSERT(c >= 0 && c < _nb_cells);
75     return _labels[c];
76   }
77
78   void down_one_level(PoseCellHierarchy *hierarchy, int level, int *sample_nb_occurences, scalar_t *sample_responses);
79
80   void update_cell_responses(PiFeatureFamily *pi_feature_family,
81                              Classifier *classifier);
82
83   void collect_samples(SampleSet *samples,
84                        PiFeatureFamily *pi_feature_family,
85                        int s,
86                        int *to_collect);
87 };
88
89 #endif