X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=pi_referential.h;fp=pi_referential.h;h=1dcb0079a976985cdb0d20bfa6ada07a13d2f0ff;hb=d922ad61d35e9a6996730bec24b16f8bf7bc426c;hp=0000000000000000000000000000000000000000;hpb=3bb118f5a9462d02ff7d99ef28ecc0d7e23529f9;p=folded-ctf.git diff --git a/pi_referential.h b/pi_referential.h new file mode 100644 index 0000000..1dcb007 --- /dev/null +++ b/pi_referential.h @@ -0,0 +1,133 @@ + +/////////////////////////////////////////////////////////////////////////// +// This program is free software: you can redistribute it and/or modify // +// it under the terms of the version 3 of the GNU General Public License // +// as published by the Free Software Foundation. // +// // +// This program is distributed in the hope that it will be useful, but // +// WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // +// General Public License for more details. // +// // +// 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 // +// Contact for comments & bug reports // +/////////////////////////////////////////////////////////////////////////// + +/* + + This class factorizes the information from a PoseCell needed by a + PiFeature to be evaluated on an image. Since there can be in there + costly operations such as trigonometric mappings, it provides a + substantial cost optimization. + +*/ + +#ifndef PI_REFERENTIAL_H +#define PI_REFERENTIAL_H + +#include "rectangle.h" +#include "pose_cell.h" +#include "rgb_image.h" + +class PiReferential { + // The best scale so that the head size is + // ~global.reference_head_size. This is an integer scale as defined + // for the RichImage + int _common_scale; + + scalar_t _horizontal_polarity; + + // The head frame in _common_scale. The vectors are of length the _RADIUS_ of the head + scalar_t _head_xc, _head_yc, _head_radius; + scalar_t _head_window_scaling; + scalar_t _head_ux, _head_uy, _head_vx, _head_vy; + scalar_t _head_ux_nopolarity, _head_uy_nopolarity, _head_vx_nopolarity, _head_vy_nopolarity; + + // The body frame in that _common_scale. The vectors are of length the radii of the ellipse + scalar_t _body_xc, _body_yc; + scalar_t _body_radius_1, _body_radius_2, _body_tilt; + scalar_t _body_ux, _body_uy, _body_vx, _body_vy; + scalar_t _body_window_scaling; + int _body_edge_shift; + + // The belly frame is defined by the body location and head scale + scalar_t _belly_xc, _belly_yc; + scalar_t _belly_ux, _belly_uy, _belly_vx, _belly_vy; + scalar_t _belly_ux_nopolarity, _belly_uy_nopolarity, _belly_vx_nopolarity, _belly_vy_nopolarity; + scalar_t _belly_window_scaling; + + // The head-belly frame is defined by the head location and the body + // center location + scalar_t _head_belly_xc, _head_belly_yc; + scalar_t _head_belly_ux, _head_belly_uy, _head_belly_vx, _head_belly_vy; + int _head_belly_edge_shift; + + void draw_frame(RGBImage *image, + int registration_mode, + int x1, int y1, + int x2, int y2, + int x3, int y3, + int x4, int y4); + +public: + PiReferential(PoseCell *cell); + + enum { + // A frame centered on the head, of size four times the head radius + // and, flipped verically if the body center is on the left of the + // head center + RM_HEAD, + + // Same as above, without the flipping + RM_HEAD_NO_POLARITY, + // A frame centered on the body center, of size size times the + // head rardius, flipped vertically if the body center is on the + // left of the head center + RM_BELLY, + + // Same as above, without the flipping + RM_BELLY_NO_POLARITY, + + // A frame centered on the middle point between the head center + // and the body center, of size twice the distance head center - + // body center in the head-body direction, and of four times the + // head radius in the other + RM_HEAD_BELLY, + + // Same as above with rotation of the edges + RM_HEAD_BELLY_EDGES, + + // Not finished yet + RM_BODY, + RM_BODY_EDGES + }; + + int common_scale(); + + // The rectangle coordinates are in the reference frames. For the + // head for instance , [-1,1] x [-1,1] corresponds to the head + // bounding box + + void register_rectangle(int registration_mode, + Rectangle *original, + Rectangle *result); + + int register_edge(int registration_type, int edge_type); + + void draw(RGBImage *image, int level); + + void draw_window(RGBImage *image, + int registration_mode, Rectangle *window, + int filled); + + void draw_edge_and_scale(RGBImage *image, + int registration_mode, Rectangle *window, + int _tag, int _edge_scale); + + static void print_registration_mode(ostream *out, int registration_mode); +}; + +#endif