X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=inline;f=pi_referential.cc;h=979f5d9b3a67dd84783721df6239466f7cf791da;hb=HEAD;hp=6f5609917da0d0a0820fbee6d430551656b56cc6;hpb=789f96ef05fda4588aa536adb614c0e841be0812;p=folded-ctf.git
diff --git a/pi_referential.cc b/pi_referential.cc
index 6f56099..979f5d9 100644
--- a/pi_referential.cc
+++ b/pi_referential.cc
@@ -1,20 +1,26 @@
-
-///////////////////////////////////////////////////////////////////////////
-// 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 //
-///////////////////////////////////////////////////////////////////////////
+/*
+ * folded-ctf is an implementation of the folded hierarchy of
+ * classifiers for object detection, developed by Francois Fleuret
+ * and Donald Geman.
+ *
+ * Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
+ * Written by Francois Fleuret
+ *
+ * This file is part of folded-ctf.
+ *
+ * folded-ctf is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * folded-ctf 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 folded-ctf. If not, see .
+ *
+ */
#include "pi_referential.h"
#include "global.h"
@@ -70,20 +76,10 @@ void PiReferential::draw_frame(RGBImage *image,
image->draw_line(2, r, g, b, x3, y3, x4, y4);
image->draw_line(2, r, g, b, x4, y4, x1, y1);
} else {
- // int xc = (x1 + x2 + x3 + x4)/4, yc = (y1 + y2 + y3 + y4)/4;
- // image->draw_line(1, r, g, b, xc - delta, yc, xc + delta, yc);
- // image->draw_line(1, r, g, b, xc, yc - delta, xc, yc + delta);
image->draw_line(2, r, g, b, x1, y1, x2, y2);
image->draw_line(2, r, g, b, x2, y2, x3, y3);
image->draw_line(2, r, g, b, x3, y3, x4, y4);
image->draw_line(2, r, g, b, x4, y4, x1, y1);
- // image->draw_line(2, r, g, b,
- // (2*xc + 5 * x1 + 5 * x2)/12, (2 * yc + 5 * y1 + 5 * y2)/12,
- // (x1 + x2)/2, (y1 + y2)/2);
- // image->draw_line(6, r, g, b,
- // (2*xc + 3 * x2 + 3 * x3)/8, (2 * yc + 3 * y2 + 3 * y3)/8,
- // (x2 + x3)/2, (y2 + y3)/2
- // );
}
}
@@ -159,110 +155,6 @@ void PiReferential::draw_window(RGBImage *image,
}
-void PiReferential::draw_edge_and_scale(RGBImage *image,
- int registration_mode, Rectangle *window,
- int _tag, int _edge_scale) {
- const int ref_radius = 10;
- int r, g, b;
- int edges = 0;
-
- switch(registration_mode) {
-
- case PiReferential::RM_HEAD:
- r = 0; g = 255; b = 0;
- break;
-
- case PiReferential::RM_HEAD_NO_POLARITY:
- r = 128; g = 255; b = 128;
- break;
-
- case PiReferential::RM_BELLY:
- r = 64; g = 0; b = 255;
- break;
-
- case PiReferential::RM_BELLY_NO_POLARITY:
- r = 192; g = 128; b = 255;
- break;
-
- case PiReferential::RM_HEAD_BELLY_EDGES:
- edges = 1;
- case PiReferential::RM_HEAD_BELLY:
- r = 255; g = 0; b = 0;
- break;
-
- default:
- cerr << "INCONSISTENCY" << endl;
- abort();
- }
-
- scalar_t xc = (window->xmin + window->xmax)/2;
- scalar_t yc = (window->ymin + window->ymax)/2;
- int radius = ref_radius * (1 << _edge_scale);
-
- image->draw_ellipse(1, r, g, b, xc, yc, radius, radius, 0);
-
- if(_tag >= RichImage::first_edge_tag && _tag < RichImage::first_edge_tag + RichImage::nb_edge_tags) {
-
- scalar_t dx, dy;
-
- switch(_tag - RichImage::first_edge_tag) {
- case 0:
- dx = 0; dy = -1;
- break;
-
- case 1:
- dx = 1; dy = -1;
- break;
-
- case 2:
- dx = 1; dy = 0;
- break;
-
- case 3:
- dx = 1; dy = 1;
- break;
-
- case 4:
- dx = 0; dy = 1;
- break;
-
- case 5:
- dx = -1; dy = 1;
- break;
-
- case 6:
- dx = -1; dy = 0;
- break;
-
- case 7:
- dx = -1; dy = -1;
- break;
-
- default:
- abort();
- }
-
- scalar_t l = sqrt(dx * dx + dy * dy);
-
- if(edges) {
- int delta = 3;
- image->draw_ellipse(1, r, g, b, xc, yc, radius + delta, radius + delta, 0);
- }
-
- for(scalar_t u = 0; u <= radius; u += 0.1) {
- scalar_t s = sqrt(radius * radius - (u * u * l * l))/l;
- image->draw_line(2, r, g, b,
- int(xc + u * dx - s * dy), int(yc + u * dy + s * dx),
- int(xc + u * dx + s * dy), int(yc + u * dy - s * dx));
- }
-
- }
-
- else if(_tag == RichImage::variance_tag) {
- image->draw_ellipse(1, r, g, b, xc, yc, 8, 8, 0);
- }
-}
-
PiReferential::PiReferential(PoseCell *cell) {
scalar_t head_radius = sqrt(scalar_t(cell->_head_radius.min * cell->_head_radius.max));
@@ -282,14 +174,16 @@ PiReferential::PiReferential(PoseCell *cell) {
// Body location
+ // **********************************************************************
+ // Useless code, but necessary to keep the exact same results with
+ // g++ 4.1 and -O3 options on reference experiments.
_body_xc = cell->_belly_xc.middle() * discrete_scale_ratio;
_body_yc = cell->_belly_yc.middle() * discrete_scale_ratio;
-
_body_tilt = 0;
-
if((_head_xc - _body_xc) * cos(_body_tilt) + (_head_yc - _body_yc) * sin(_body_tilt) > 0) {
_body_tilt += M_PI;
}
+ // **********************************************************************
// Belly location
@@ -308,6 +202,7 @@ PiReferential::PiReferential(PoseCell *cell) {
// Frames
if(_body_xc >= _head_xc) {
+ // if(_belly_xc >= _head_xc) {
_horizontal_polarity = 1;
} else {
_horizontal_polarity = -1;
@@ -358,8 +253,8 @@ PiReferential::PiReferential(PoseCell *cell) {
scalar_t l = sqrt(_head_belly_vx * _head_belly_vx + _head_belly_vy * _head_belly_vy);
- _head_belly_vx = _head_belly_vx/l * _head_radius * 2;
- _head_belly_vy = _head_belly_vy/l * _head_radius * 2;
+ _head_belly_vx = (_head_belly_vx / l) * _head_radius * 2;
+ _head_belly_vy = (_head_belly_vy / l) * _head_radius * 2;
_head_belly_edge_shift = int(floor(- RichImage::nb_edge_tags * atan2(_head_belly_ux, _head_belly_uy) / (2 * M_PI) + 0.5));
_head_belly_edge_shift = (RichImage::nb_edge_tags + _head_belly_edge_shift) % RichImage::nb_edge_tags;
}