X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=folded-ctf.git;a=blobdiff_plain;f=pose.cc;h=3e30e56705de86bbdead807444ff70b2452e448d;hp=ed6c7058afc321edac0301f2e8e9e964d8a8876d;hb=346c6fdc3c36ca10142234cce291031064fa2b48;hpb=d922ad61d35e9a6996730bec24b16f8bf7bc426c diff --git a/pose.cc b/pose.cc index ed6c705..3e30e56 100644 --- a/pose.cc +++ b/pose.cc @@ -12,7 +12,9 @@ // You should have received a copy of the GNU General Public License // // along with this program. If not, see . // // // -// Written by Francois Fleuret, (C) IDIAP // +// Written by Francois Fleuret // +// (C) Idiap Research Institute // +// // // Contact for comments & bug reports // /////////////////////////////////////////////////////////////////////////// @@ -26,30 +28,7 @@ Pose::Pose() { void Pose::horizontal_flip(scalar_t scene_width) { _head_xc = scene_width - 1 - _head_xc; - _body_xc = scene_width - 1 - _body_xc; -} - -void Pose::translate(scalar_t dx, scalar_t dy) { - _bounding_box_xmin += dx; - _bounding_box_ymin += dy; - _bounding_box_xmax += dx; - _bounding_box_ymax += dy; - _head_xc += dx; - _head_yc += dy; - _body_xc += dx; - _body_yc += dy; -} - -void Pose::scale(scalar_t factor) { - _bounding_box_xmin *= factor; - _bounding_box_ymin *= factor; - _bounding_box_xmax *= factor; - _bounding_box_ymax *= factor; - _head_xc *= factor; - _head_yc *= factor; - _head_radius *= factor; - _body_xc *= factor; - _body_yc *= factor; + _belly_xc = scene_width - 1 - _belly_xc; } const scalar_t tolerance_scale_ratio_for_hit = 1.5; @@ -74,7 +53,7 @@ bool Pose::hit(int level, Pose *pose) { // Belly location - if(sq(_body_xc - pose->_body_xc) + sq(_body_yc - pose->_body_yc) > 4 * sq_delta) + if(sq(_belly_xc - pose->_belly_xc) + sq(_belly_yc - pose->_belly_yc) > 4 * sq_delta) return false; if(level == 1) return true; @@ -106,7 +85,7 @@ bool Pose::collide(int level, Pose *pose) { // Belly location - if(sq(_body_xc - pose->_body_xc) + sq(_body_yc - pose->_body_yc) <= sq_delta) + if(sq(_belly_xc - pose->_belly_xc) + sq(_belly_yc - pose->_belly_yc) <= sq_delta) return true; if(level == 1) return false; @@ -122,38 +101,26 @@ void Pose::draw(int thickness, int r, int g, int b, int level, RGBImage *image) image->draw_ellipse(thickness, r, g, b, _head_xc, _head_yc, _head_radius, _head_radius, 0); - // int vx = int(cos(_head_tilt) * _head_radius); - // int vy = int(sin(_head_tilt) * _head_radius); - // image->draw_line(thickness, r, g, b, _head_xc, _head_yc, _head_xc + vx, _head_yc + vy); - if(level == 1) { - // image->draw_line(thickness, r, g, b, - // int(_body_xc) - delta, int(_body_yc), - // int(_body_xc) + delta, int(_body_yc)); - - // image->draw_line(thickness, r, g, b, - // int(_body_xc), int(_body_yc) - delta, - // int(_body_xc), int(_body_yc) + delta); - - scalar_t vx = _body_xc - _head_xc, vy = _body_yc - _head_yc; + scalar_t vx = _belly_xc - _head_xc, vy = _belly_yc - _head_yc; scalar_t l = sqrt(vx * vx + vy * vy); vx /= l; vy /= l; - scalar_t body_radius = 12 + thickness / 2; + scalar_t belly_radius = 12 + thickness / 2; - if(l > _head_radius + thickness + body_radius) { + if(l > _head_radius + thickness + belly_radius) { image->draw_line(thickness, r, g, b, _head_xc + vx * (_head_radius + thickness/2), _head_yc + vy * (_head_radius + thickness/2), - _body_xc - vx * (body_radius - thickness/2), - _body_yc - vy * (body_radius - thickness/2)); + _belly_xc - vx * (belly_radius - thickness/2), + _belly_yc - vy * (belly_radius - thickness/2)); } // An ugly way to make a filled disc - for(scalar_t u = 0; u < body_radius; u += thickness / 2) { - image->draw_ellipse(thickness, r, g, b, _body_xc, _body_yc, u, u, 0); + for(scalar_t u = 0; u < belly_radius; u += thickness / 2) { + image->draw_ellipse(thickness, r, g, b, _belly_xc, _belly_yc, u, u, 0); } } @@ -163,8 +130,8 @@ void Pose::print(ostream *out) { (*out) << " _head_xc " << _head_xc << endl; (*out) << " _head_yc " << _head_yc << endl; (*out) << " _head_radius " << _head_radius << endl; - (*out) << " _body_xc " << _body_xc << endl; - (*out) << " _body_yc " << _body_yc << endl; + (*out) << " _belly_xc " << _belly_xc << endl; + (*out) << " _belly_yc " << _belly_yc << endl; } void Pose::write(ostream *out) { @@ -174,8 +141,8 @@ void Pose::write(ostream *out) { write_var(out, &_bounding_box_ymax); write_var(out, &_head_xc); write_var(out, &_head_yc); write_var(out, &_head_radius); - write_var(out, &_body_xc); - write_var(out, &_body_yc); + write_var(out, &_belly_xc); + write_var(out, &_belly_yc); } void Pose::read(istream *in) { @@ -185,6 +152,6 @@ void Pose::read(istream *in) { read_var(in, &_bounding_box_ymax); read_var(in, &_head_xc); read_var(in, &_head_yc); read_var(in, &_head_radius); - read_var(in, &_body_xc); - read_var(in, &_body_yc); + read_var(in, &_belly_xc); + read_var(in, &_belly_yc); }