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;
}
// 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) {
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) {
_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) {
_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;
// 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;
// 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;
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);
}
}
(*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) {
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) {
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);
}
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();
_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) {
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) {
(*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;
}
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
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++;
}
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;
}
}
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);
}
}
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);
}
}
#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 {