From f7e3efe41ffb65d89e8f2ce814c23ff90ad24f34 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Thu, 9 Oct 2008 10:14:40 +0200 Subject: [PATCH] automatic commit --- list_to_pool.cc | 4 +-- pi_referential.cc | 4 +-- pose.cc | 52 ++++++++++++------------------- pose.h | 2 +- pose_cell.cc | 12 ++++---- pose_cell.h | 2 +- pose_cell_hierarchy.cc | 70 ++++++++---------------------------------- pose_cell_hierarchy.h | 2 +- 8 files changed, 45 insertions(+), 103 deletions(-) diff --git a/list_to_pool.cc b/list_to_pool.cc index c142534..c1496e5 100644 --- a/list_to_pool.cc +++ b/list_to_pool.cc @@ -237,8 +237,8 @@ void list_to_pool(char *main_path, char *list_name, char *pool_name) { Pose *pose = current_image->get_target_pose(nb_cats); - pose->_body_xc = x1; - pose->_body_yc = y1; + pose->_belly_xc = x1; + pose->_belly_yc = y1; body_defined = true; } diff --git a/pi_referential.cc b/pi_referential.cc index 6e7eb3e..8c0e8ac 100644 --- a/pi_referential.cc +++ b/pi_referential.cc @@ -338,8 +338,8 @@ PiReferential::PiReferential(PoseCell *cell) { // Body location - _body_xc = cell->_body_xc.middle() * discrete_scale_ratio; - _body_yc = cell->_body_yc.middle() * discrete_scale_ratio; + _body_xc = cell->_belly_xc.middle() * discrete_scale_ratio; + _body_yc = cell->_belly_yc.middle() * discrete_scale_ratio; _body_window_scaling = sqrt(_body_radius_1 * _body_radius_2); if((_head_xc - _body_xc) * cos(_body_tilt) + (_head_yc - _body_yc) * sin(_body_tilt) > 0) { diff --git a/pose.cc b/pose.cc index ed6c705..f0aa9d3 100644 --- a/pose.cc +++ b/pose.cc @@ -26,7 +26,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; + _belly_xc = scene_width - 1 - _belly_xc; } void Pose::translate(scalar_t dx, scalar_t dy) { @@ -36,8 +36,8 @@ void Pose::translate(scalar_t dx, scalar_t dy) { _bounding_box_ymax += dy; _head_xc += dx; _head_yc += dy; - _body_xc += dx; - _body_yc += dy; + _belly_xc += dx; + _belly_yc += dy; } void Pose::scale(scalar_t factor) { @@ -48,8 +48,8 @@ void Pose::scale(scalar_t factor) { _head_xc *= factor; _head_yc *= factor; _head_radius *= factor; - _body_xc *= factor; - _body_yc *= factor; + _belly_xc *= factor; + _belly_yc *= factor; } const scalar_t tolerance_scale_ratio_for_hit = 1.5; @@ -74,7 +74,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 +106,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 +122,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 +151,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 +162,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 +173,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); } diff --git a/pose.h b/pose.h index acd7884..8362d1d 100644 --- a/pose.h +++ b/pose.h @@ -27,7 +27,7 @@ public: scalar_t _bounding_box_xmin, _bounding_box_ymin; scalar_t _bounding_box_xmax, _bounding_box_ymax; scalar_t _head_xc, _head_yc, _head_radius; - scalar_t _body_xc, _body_yc; + scalar_t _belly_xc, _belly_yc; Pose(); diff --git a/pose_cell.cc b/pose_cell.cc index 4e5e7e2..def9b2f 100644 --- a/pose_cell.cc +++ b/pose_cell.cc @@ -25,8 +25,8 @@ bool PoseCell::contains(Pose *pose) { _head_xc.contains(pose->_head_xc) && _head_yc.contains(pose->_head_yc) && _head_radius.contains(pose->_head_radius) && - _body_xc.contains(pose->_body_xc) && - _body_yc.contains(pose->_body_yc); + _belly_xc.contains(pose->_belly_xc) && + _belly_yc.contains(pose->_belly_yc); } bool PoseCell::negative_for_train(Pose *pose) { @@ -49,8 +49,8 @@ void PoseCell::get_centroid(Pose *pose) { pose->_head_radius = sqrt(_head_radius.min * _head_radius.max); pose->_head_xc = _head_xc.middle(); pose->_head_yc = _head_yc.middle(); - pose->_body_xc = _body_xc.middle(); - pose->_body_yc = _body_yc.middle(); + pose->_belly_xc = _belly_xc.middle(); + pose->_belly_yc = _belly_yc.middle(); } void PoseCell::print(ostream *out) { @@ -58,6 +58,6 @@ void PoseCell::print(ostream *out) { (*out) << " _head_yc " << _head_yc << endl; (*out) << " _head_radius " << _head_radius << endl; (*out) << " _head_tilt " << _head_tilt << 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; } diff --git a/pose_cell.h b/pose_cell.h index b970756..3744145 100644 --- a/pose_cell.h +++ b/pose_cell.h @@ -26,7 +26,7 @@ class PoseCell { public: Interval _head_xc, _head_yc, _head_radius, _head_tilt; - Interval _body_xc, _body_yc; + Interval _belly_xc, _belly_yc; // The cell contains the pose diff --git a/pose_cell_hierarchy.cc b/pose_cell_hierarchy.cc index 0816f3a..6ce933f 100644 --- a/pose_cell_hierarchy.cc +++ b/pose_cell_hierarchy.cc @@ -53,16 +53,16 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) { cell_set.get_containing_cell(&pose)->get_centroid(&coarse); - targets[u]._body_xc.set((pose._body_xc - coarse._head_xc) / coarse._head_radius); - targets[u]._body_yc.set((pose._body_yc - coarse._head_yc) / coarse._head_radius); + targets[u]._body_xc.set((pose._belly_xc - coarse._head_xc) / coarse._head_radius); + targets[u]._body_yc.set((pose._belly_yc - coarse._head_yc) / coarse._head_radius); u++; pose.horizontal_flip(image->width()); cell_set.get_containing_cell(&pose)->get_centroid(&coarse); - targets[u]._body_xc.set((pose._body_xc - coarse._head_xc) / coarse._head_radius); - targets[u]._body_yc.set((pose._body_yc - coarse._head_yc) / coarse._head_radius); + targets[u]._body_xc.set((pose._belly_xc - coarse._head_xc) / coarse._head_radius); + targets[u]._body_yc.set((pose._belly_yc - coarse._head_yc) / coarse._head_radius); u++; } @@ -180,52 +180,6 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) { mother._body_xc.set(x, x + body_resolution); mother._body_yc.set(y, y + body_resolution); - // scalar_t dist_min = body_resolution; - scalar_t dist_min = 1e6; - - int nb_got; - - Gaussian dist_body_radius_1, dist_body_radius_2, dist_body_tilt; - - do { - - nb_got = 0; - - for(int t = 0; t < nb_total_targets; t++) { - - scalar_t dist = - sqrt(sq(targets[t]._body_xc.middle() - x - body_resolution / 2) + - sq(targets[t]._body_yc.middle() - y - body_resolution / 2)); - - if(dist <= dist_min) { - dist_body_radius_1.add_sample(targets[t]._body_radius_1.middle()); - dist_body_radius_2.add_sample(targets[t]._body_radius_2.middle()); - dist_body_tilt.add_sample(targets[t]._body_tilt.middle()); - nb_got++; - } - - } - - dist_min *= 2.0; - } while(nb_got < min(100, nb_total_targets)); - - scalar_t zeta = 4; - - mother._body_radius_1.set(dist_body_radius_1.expectation() - - zeta * dist_body_radius_1.standard_deviation(), - dist_body_radius_1.expectation() + - zeta * dist_body_radius_1.standard_deviation()); - - mother._body_radius_2.set(dist_body_radius_2.expectation() - - zeta * dist_body_radius_2.standard_deviation(), - dist_body_radius_2.expectation() + - zeta * dist_body_radius_2.standard_deviation()); - - mother._body_tilt.set(dist_body_tilt.expectation() - - zeta * dist_body_tilt.standard_deviation(), - dist_body_tilt.expectation() + - zeta * dist_body_tilt.standard_deviation()); - _body_cells[k++] = mother; } } @@ -279,10 +233,10 @@ void PoseCellHierarchy::add_root_cells(Image *image, PoseCellSet *cell_set) { cell._head_xc.max = x + cell_xy_size; cell._head_yc.min = y; cell._head_yc.max = y + cell_xy_size; - cell._body_xc.min = cell._head_xc.min - pseudo_infty; - cell._body_xc.max = cell._head_xc.max + pseudo_infty; - cell._body_yc.min = cell._head_yc.min - pseudo_infty; - cell._body_yc.max = cell._head_yc.max + pseudo_infty; + cell._belly_xc.min = cell._head_xc.min - pseudo_infty; + cell._belly_xc.max = cell._head_xc.max + pseudo_infty; + cell._belly_yc.min = cell._head_yc.min - pseudo_infty; + cell._belly_yc.max = cell._head_yc.max + pseudo_infty; cell_set->add_cell(&cell); } } @@ -301,10 +255,10 @@ void PoseCellHierarchy::add_subcells(int level, PoseCell *root, scalar_t x = (cell._head_xc.min + cell._head_xc.max) / 2.0; scalar_t y = (cell._head_yc.min + cell._head_yc.max) / 2.0; for(int k = 0; k < _nb_body_cells; k++) { - cell._body_xc.min = (_body_cells[k]._body_xc.min * r) + x; - cell._body_xc.max = (_body_cells[k]._body_xc.max * r) + x; - cell._body_yc.min = (_body_cells[k]._body_yc.min * r) + y; - cell._body_yc.max = (_body_cells[k]._body_yc.max * r) + y; + cell._belly_xc.min = (_body_cells[k]._body_xc.min * r) + x; + cell._belly_xc.max = (_body_cells[k]._body_xc.max * r) + x; + cell._belly_yc.min = (_body_cells[k]._body_yc.min * r) + y; + cell._belly_yc.max = (_body_cells[k]._body_yc.max * r) + y; cell_set->add_cell(&cell); } } diff --git a/pose_cell_hierarchy.h b/pose_cell_hierarchy.h index 51f4e6e..ffd2146 100644 --- a/pose_cell_hierarchy.h +++ b/pose_cell_hierarchy.h @@ -23,7 +23,7 @@ #include "labelled_image_pool.h" struct RelativeBodyPoseCell { - Interval _body_xc, _body_yc, _body_radius_1, _body_radius_2, _body_tilt; + Interval _body_xc, _body_yc; }; class PoseCellHierarchy { -- 2.39.5