Removed the definition of basename, which confuses an existing system one.
[folded-ctf.git] / pose_cell_hierarchy.cc
index cecd3b3..baa6459 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.  //
-//                                                                       //
-// Written by Francois Fleuret, (C) IDIAP                                //
-// Contact <francois.fleuret@idiap.ch> 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 <francois.fleuret@idiap.ch>
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ *
+ */
 
 #include "pose_cell_hierarchy.h"
 #include "gaussian.h"
@@ -27,7 +33,7 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) {
   _nb_levels = global.nb_levels;
   _min_head_radius = global.min_head_radius;
   _max_head_radius = global.max_head_radius;
-  _root_cell_nb_xy_per_scale = global.root_cell_nb_xy_per_scale;
+  _root_cell_nb_xy_per_radius = global.root_cell_nb_xy_per_radius;
 
   LabelledImage *image;
   int nb_total_targets = 0;
@@ -92,14 +98,6 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) {
   scalar_t belly_ryc_min = belly_resolution * floor(belly_ryc.min / belly_resolution);
   int nb_belly_ryc = int(ceil((belly_ryc.max - belly_ryc_min) / belly_resolution));
 
-  (*global.log_stream) << "belly_rxc = " << belly_rxc << endl
-                       << "belly_rxc_min = " << belly_rxc_min << endl
-                       << "belly_rxc_min + nb_belly_rxc * belly_resolution = " << belly_rxc_min + nb_belly_rxc * belly_resolution << endl
-                       << endl
-                       << "belly_ryc = " << belly_ryc << endl
-                       << "belly_ryc_min = " << belly_ryc_min << endl
-                       << "belly_ryc_min + nb_belly_ryc * belly_resolution = " << belly_ryc_min + nb_belly_ryc * belly_resolution << endl;
-
   int used[nb_belly_rxc * nb_belly_rxc];
 
   for(int k = 0; k < nb_belly_rxc * nb_belly_ryc; k++) {
@@ -150,22 +148,6 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) {
 
   _belly_cells = new RelativeBellyPoseCell[_nb_belly_cells];
 
-  for(int j = 0; j < nb_belly_ryc; j++) {
-    for(int i = 0; i < nb_belly_rxc; i++) {
-      if(used[i + nb_belly_rxc * j]) {
-        if(sq(scalar_t(i) * belly_resolution + belly_resolution/2 + belly_rxc_min) +
-           sq(scalar_t(j) * belly_resolution + belly_resolution/2 + belly_ryc_min) <= 1) {
-          (*global.log_stream) << "*";
-        } else {
-          (*global.log_stream) << "X";
-        }
-      } else {
-        (*global.log_stream) << ".";
-      }
-    }
-    (*global.log_stream) << endl;
-  }
-
   int k = 0;
   for(int j = 0; j < nb_belly_ryc; j++) {
     for(int i = 0; i < nb_belly_rxc; i++) {
@@ -184,8 +166,6 @@ PoseCellHierarchy::PoseCellHierarchy(LabelledImagePool *train_pool) {
       }
     }
   }
-
-  (*global.log_stream) << _nb_belly_cells << " belly cells." << endl;
 }
 
 PoseCellHierarchy::~PoseCellHierarchy() {
@@ -221,7 +201,7 @@ void PoseCellHierarchy::add_root_cells(Image *image, PoseCellSet *cell_set) {
   scalar_t beta = log(2) / scalar_t(global.nb_scales_per_power_of_two);
 
   for(int s = 0; s < nb_scales; s++) {
-    scalar_t cell_xy_size = exp(alpha + scalar_t(s) * beta) / global.root_cell_nb_xy_per_scale;
+    scalar_t cell_xy_size = exp(alpha + scalar_t(s) * beta) / global.root_cell_nb_xy_per_radius;
     PoseCell cell;
     cell._head_radius.min = exp(alpha + scalar_t(s) * beta);
     cell._head_radius.max = exp(alpha + scalar_t(s+1) * beta);
@@ -326,7 +306,7 @@ int PoseCellHierarchy::nb_incompatible_poses(LabelledImagePool *pool) {
 void PoseCellHierarchy::write(ostream *os) {
   write_var(os, &_min_head_radius);
   write_var(os, &_max_head_radius);
-  write_var(os, &_root_cell_nb_xy_per_scale);
+  write_var(os, &_root_cell_nb_xy_per_radius);
   write_var(os, &_nb_belly_cells);
   for(int k = 0; k < _nb_belly_cells; k++)
     write_var(os, &_belly_cells[k]);
@@ -336,7 +316,7 @@ void PoseCellHierarchy::read(istream *is) {
   delete[] _belly_cells;
   read_var(is, &_min_head_radius);
   read_var(is, &_max_head_radius);
-  read_var(is, &_root_cell_nb_xy_per_scale);
+  read_var(is, &_root_cell_nb_xy_per_radius);
   read_var(is, &_nb_belly_cells);
   delete[] _belly_cells;
   _belly_cells = new RelativeBellyPoseCell[_nb_belly_cells];