automatic commit
[folded-ctf.git] / pose_cell_hierarchy.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 as published
13  *  by the Free Software Foundation, either version 3 of the License,
14  *  or (at your option) any later version.
15  *
16  *  folded-ctf is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with folded-ctf.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25
26 /*
27
28   A PoseCellHierarchy provides the necessary methods to visit a
29   recursive partitioning of the pose space. The two main methods can
30   give you an root partitioning, or compute a finer partitioning from
31   an existing one.
32
33  */
34
35 #ifndef POSE_CELL_HIERARCHY_H
36 #define POSE_CELL_HIERARCHY_H
37
38 #include "pose_cell_set.h"
39 #include "labelled_image_pool.h"
40
41 struct RelativeBellyPoseCell {
42   Interval _belly_xc, _belly_yc;
43 };
44
45 class PoseCellHierarchy {
46   static const scalar_t pseudo_infty = 10000;
47
48   static const scalar_t belly_resolution = 0.5;
49
50   static const int nb_radius_1 = 16;
51   static const int nb_radius_2 = 16;
52   static const int nb_tilts = 64;
53
54   int _nb_levels;
55   scalar_t _min_head_radius;
56   scalar_t _max_head_radius;
57   int _root_cell_nb_xy_per_radius;
58
59   int _nb_belly_cells;
60
61   RelativeBellyPoseCell *_belly_cells;
62
63 public:
64   PoseCellHierarchy();
65   PoseCellHierarchy(LabelledImagePool *train_pool);
66   virtual ~PoseCellHierarchy();
67
68   virtual int nb_levels();
69   virtual void get_containing_cell(Image *image, int level,
70                                    Pose *pose, PoseCell *result_cell);
71
72   virtual void add_root_cells(Image *image, PoseCellSet *cell_set);
73   // level is the level to build, hence should be greater than 1
74   virtual void add_subcells(int level, PoseCell *root, PoseCellSet *cell_set);
75
76   virtual int nb_incompatible_poses(LabelledImagePool *pool);
77
78   virtual void write(ostream *os);
79   virtual void read(istream *is);
80 };
81
82 #endif