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. //
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. //
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/>. //
15 // Written by Francois Fleuret //
16 // (C) Idiap Research Institute //
18 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
19 ///////////////////////////////////////////////////////////////////////////
21 #include "pose_cell.h"
25 bool PoseCell::contains(Pose *pose) {
27 _head_xc.contains(pose->_head_xc) &&
28 _head_yc.contains(pose->_head_yc) &&
29 _head_radius.contains(pose->_head_radius) &&
30 _belly_xc.contains(pose->_belly_xc) &&
31 _belly_yc.contains(pose->_belly_yc);
34 bool PoseCell::negative_for_train(Pose *pose) {
35 const scalar_t r_tolerance = 3;
36 scalar_t r = pose->_head_radius;
38 r <= _head_radius.min / r_tolerance ||
39 r >= _head_radius.max * r_tolerance ||
40 pose->_head_xc <= _head_xc.min - r ||
41 pose->_head_xc >= _head_xc.max + r ||
42 pose->_head_yc <= _head_yc.min - r ||
43 pose->_head_yc >= _head_yc.max + r;
46 void PoseCell::get_centroid(Pose *pose) {
47 pose->_bounding_box_xmin = -1;
48 pose->_bounding_box_ymin = -1;
49 pose->_bounding_box_xmax = -1;
50 pose->_bounding_box_ymax = -1;
51 pose->_head_radius = sqrt(_head_radius.min * _head_radius.max);
52 pose->_head_xc = _head_xc.middle();
53 pose->_head_yc = _head_yc.middle();
54 pose->_belly_xc = _belly_xc.middle();
55 pose->_belly_yc = _belly_yc.middle();
58 void PoseCell::print(ostream *out) {
59 (*out) << " _head_xc " << _head_xc << endl;
60 (*out) << " _head_yc " << _head_yc << endl;
61 (*out) << " _head_radius " << _head_radius << endl;
62 (*out) << " _head_tilt " << _head_tilt << endl;
63 (*out) << " _belly_xc " << _belly_xc << endl;
64 (*out) << " _belly_yc " << _belly_yc << endl;