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, (C) IDIAP //
16 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
17 ///////////////////////////////////////////////////////////////////////////
19 #include "pose_cell.h"
23 bool PoseCell::contains(Pose *pose) {
25 _head_xc.contains(pose->_head_xc) &&
26 _head_yc.contains(pose->_head_yc) &&
27 _head_radius.contains(pose->_head_radius) &&
28 _body_xc.contains(pose->_body_xc) &&
29 _body_yc.contains(pose->_body_yc);
32 bool PoseCell::negative_for_train(Pose *pose) {
33 const scalar_t r_tolerance = 3;
34 scalar_t r = pose->_head_radius;
36 r <= _head_radius.min / r_tolerance ||
37 r >= _head_radius.max * r_tolerance ||
38 pose->_head_xc <= _head_xc.min - r ||
39 pose->_head_xc >= _head_xc.max + r ||
40 pose->_head_yc <= _head_yc.min - r ||
41 pose->_head_yc >= _head_yc.max + r;
44 void PoseCell::get_centroid(Pose *pose) {
45 pose->_bounding_box_xmin = -1;
46 pose->_bounding_box_ymin = -1;
47 pose->_bounding_box_xmax = -1;
48 pose->_bounding_box_ymax = -1;
49 pose->_head_radius = sqrt(_head_radius.min * _head_radius.max);
50 pose->_head_xc = _head_xc.middle();
51 pose->_head_yc = _head_yc.middle();
52 pose->_body_xc = _body_xc.middle();
53 pose->_body_yc = _body_yc.middle();
56 void PoseCell::print(ostream *out) {
57 (*out) << " _head_xc " << _head_xc << endl;
58 (*out) << " _head_yc " << _head_yc << endl;
59 (*out) << " _head_radius " << _head_radius << endl;
60 (*out) << " _head_tilt " << _head_tilt << endl;
61 (*out) << " _body_xc " << _body_xc << endl;
62 (*out) << " _body_yc " << _body_yc << endl;