automatic commit
[folded-ctf.git] / pose_cell.cc
1
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.                         //
6 //                                                                       //
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.                              //
11 //                                                                       //
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/>.  //
14 //                                                                       //
15 // Written by Francois Fleuret, (C) IDIAP                                //
16 // Contact <francois.fleuret@idiap.ch> for comments & bug reports        //
17 ///////////////////////////////////////////////////////////////////////////
18
19 #include "pose_cell.h"
20 #include "global.h"
21 #include "tools.h"
22
23 bool PoseCell::contains(Pose *pose) {
24   return
25     _head_xc.contains(pose->_head_xc) &&
26     _head_yc.contains(pose->_head_yc) &&
27     _head_radius.contains(pose->_head_radius) &&
28     _belly_xc.contains(pose->_belly_xc) &&
29     _belly_yc.contains(pose->_belly_yc);
30 }
31
32 bool PoseCell::negative_for_train(Pose *pose) {
33   const scalar_t r_tolerance = 3;
34   scalar_t r = pose->_head_radius;
35   return
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;
42 }
43
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->_belly_xc = _belly_xc.middle();
53   pose->_belly_yc = _belly_yc.middle();
54 }
55
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) << "  _belly_xc " << _belly_xc << endl;
62   (*out) << "  _belly_yc " << _belly_yc << endl;
63 }