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