2 * folded-ctf is an implementation of the folded hierarchy of
3 * classifiers for object detection, developed by Francois Fleuret
6 * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
7 * Written by Francois Fleuret <francois.fleuret@idiap.ch>
9 * This file is part of folded-ctf.
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.
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.
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/>.
28 This class factorizes the information from a PoseCell needed by a
29 PiFeature to be evaluated on an image. Since there can be in there
30 costly operations such as trigonometric mappings, it provides a
31 substantial cost optimization.
35 #ifndef PI_REFERENTIAL_H
36 #define PI_REFERENTIAL_H
38 #include "rectangle.h"
39 #include "pose_cell.h"
40 #include "rgb_image.h"
43 // The best scale so that the head size is
44 // ~global.reference_head_size. This is an integer scale as defined
48 scalar_t _horizontal_polarity;
50 // The head frame in _common_scale. The vectors are of length the _RADIUS_ of the head
51 scalar_t _head_xc, _head_yc, _head_radius;
52 scalar_t _head_window_scaling;
53 scalar_t _head_ux, _head_uy, _head_vx, _head_vy;
54 scalar_t _head_ux_nopolarity, _head_uy_nopolarity, _head_vx_nopolarity, _head_vy_nopolarity;
56 //**********************************************************************
57 // Useless fields, but they are necessary so that the optimized code
58 // with g++ gives the same results as some reference
59 // experiments. Sorry for that.
60 scalar_t _body_xc, _body_yc;
62 //**********************************************************************
64 // The belly frame is defined by the belly location and head scale
65 scalar_t _belly_xc, _belly_yc;
66 scalar_t _belly_ux, _belly_uy, _belly_vx, _belly_vy;
67 scalar_t _belly_ux_nopolarity, _belly_uy_nopolarity, _belly_vx_nopolarity, _belly_vy_nopolarity;
68 scalar_t _belly_window_scaling;
70 // The head-belly frame is defined by the head location and the belly
71 scalar_t _head_belly_xc, _head_belly_yc;
72 scalar_t _head_belly_ux, _head_belly_uy, _head_belly_vx, _head_belly_vy;
73 int _head_belly_edge_shift;
75 void draw_frame(RGBImage *image,
76 int registration_mode,
83 PiReferential(PoseCell *cell);
86 // A square frame centered on the head, of size four times the
87 // head radius and, flipped horizontally if the belly is on the
88 // left of the head center
91 // Same as above, without the flipping
94 // A frame centered on the belly, of size eight times the head
95 // radius, flipped horizontally if the belly is on the left of the
99 // Same as above, without the flipping
100 RM_BELLY_NO_POLARITY,
102 // A frame centered on the middle point between the head center
103 // and the belly, of size twice the distance head center - belly
104 // in the head-belly direction, and of four times the head radius
108 // Same as above with rotation of the edges
114 // The rectangle coordinates are in the reference frames. For the
115 // head for instance [-0.5, 0.5] x [-0.5, 0.5] corresponds to the
118 void register_rectangle(int registration_mode,
122 int register_edge(int registration_type, int edge_type);
124 void draw(RGBImage *image, int level);
126 void draw_window(RGBImage *image,
127 int registration_mode, Rectangle *window,
130 static void print_registration_mode(ostream *out, int registration_mode);