X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=materials.cc;h=986004aa31fc49ffa1e3351d98d6860dcc21a007;hb=6a95a56ecee3faeb2e256b0993b83d18120b3b07;hp=64729dbadae673ab6ba889e68a69ec42756e0f80;hpb=4953a336630d0ee905c949bf1fe846b85cabb744;p=folded-ctf.git
diff --git a/materials.cc b/materials.cc
index 64729db..986004a 100644
--- a/materials.cc
+++ b/materials.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 "materials.h"
#include "boosted_classifier.h"
@@ -75,26 +81,7 @@ void write_referential_png(char *filename,
referential->draw(&result_sp, level);
}
- (*global.log_stream) << "Writing " << filename << endl;
- result_sp.write_png(filename);
-}
-
-void write_one_pi_feature_png(char *filename,
- LabelledImage *image,
- PoseCellHierarchy *hierarchy,
- int nb_target,
- int level,
- PiFeature *pf) {
-
- PoseCell target_cell;
- hierarchy->get_containing_cell(image, level,
- image->get_target_pose(nb_target), &target_cell);
- PiReferential referential(&target_cell);
- RGBImage result(image->width(), image->height());
- image->to_rgb(&result);
- RGBImageSubpixel result_sp(&result);
- referential.draw(&result_sp, level);
- // pf->draw(&result_sp, 255, 255, 0, &referential);
+ cout << "Writing " << filename << endl;
result_sp.write_png(filename);
}
@@ -109,33 +96,35 @@ void write_pool_images_with_poses_and_referentials(LabelledImagePool *pool,
PoseCellHierarchy *hierarchy = new PoseCellHierarchy(pool);
- for(int i = 0; i < min(global.nb_images, pool->nb_images()); i++) {
- image = pool->grab_image(i);
- RGBImage result(image->width(), image->height());
- image->to_rgb(&result);
- RGBImageSubpixel result_sp(&result);
-
- if(global.pictures_for_article) {
- for(int t = 0; t < image->nb_targets(); t++) {
- image->get_target_pose(t)->draw(8, 255, 255, 255,
- hierarchy->nb_levels() - 1, &result_sp);
-
+ if(global.material_feature_nb < 0) {
+ for(int i = 0; i < min(global.nb_images, pool->nb_images()); i++) {
+ image = pool->grab_image(i);
+ RGBImage result(image->width(), image->height());
+ image->to_rgb(&result);
+ RGBImageSubpixel result_sp(&result);
+
+ if(global.pictures_for_article) {
+ for(int t = 0; t < image->nb_targets(); t++) {
+ image->get_target_pose(t)->draw(8, 255, 255, 255,
+ hierarchy->nb_levels() - 1, &result_sp);
+
+ }
+ for(int t = 0; t < image->nb_targets(); t++) {
+ image->get_target_pose(t)->draw(4, 0, 0, 0,
+ hierarchy->nb_levels() - 1, &result_sp);
+ }
+ } else {
+ for(int t = 0; t < image->nb_targets(); t++) {
+ image->get_target_pose(t)->draw(4, 255, 128, 0,
+ hierarchy->nb_levels() - 1, &result_sp);
+ }
}
- for(int t = 0; t < image->nb_targets(); t++) {
- image->get_target_pose(t)->draw(4, 0, 0, 0,
- hierarchy->nb_levels() - 1, &result_sp);
- }
- } else {
- for(int t = 0; t < image->nb_targets(); t++) {
- image->get_target_pose(t)->draw(4, 255, 128, 0,
- hierarchy->nb_levels() - 1, &result_sp);
- }
- }
- sprintf(buffer, "/tmp/truth-%05d.png", i);
- cout << "Writing " << buffer << endl;
- result_sp.write_png(buffer);
- pool->release_image(i);
+ sprintf(buffer, "/tmp/truth-%05d.png", i);
+ cout << "Writing " << buffer << endl;
+ result_sp.write_png(buffer);
+ pool->release_image(i);
+ }
}
for(int i = 0; i < min(global.nb_images, pool->nb_images()); i++) {
@@ -145,8 +134,6 @@ void write_pool_images_with_poses_and_referentials(LabelledImagePool *pool,
image->to_rgb(&result);
RGBImageSubpixel result_sp(&result);
- int u = 0;
-
// image->compute_rich_structure();
for(int t = 0; t < image->nb_targets(); t++) {
@@ -164,32 +151,26 @@ void write_pool_images_with_poses_and_referentials(LabelledImagePool *pool,
PiReferential referential(&target_cell);
- sprintf(buffer, "/tmp/referential-%05d-%02d.png", i, u);
image->compute_rich_structure();
- write_referential_png(buffer, hierarchy->nb_levels() - 1, image, &referential, 0);
-
- if(detector) {
- int nb_features = 100;
- for(int f = 0; f < nb_features; f++)
- if(f == 0 || f == 50 || f == 53) {
- int n_family, n_feature;
- if(f < nb_features/2) {
- n_family = 0;
- n_feature = f;
- } else {
- n_family = detector->_nb_classifiers_per_level;
- n_feature = f - nb_features/2;
- }
- pf = detector->_pi_feature_families[n_family]->get_feature(n_feature);
- sprintf(buffer, "/tmp/pf-%05d-%02d-%03d.png", i, u, f);
- write_referential_png(buffer,
- hierarchy->nb_levels() - 1,
- image,
- &referential,
- pf);
- }
+
+ if(global.material_feature_nb < 0) {
+ sprintf(buffer, "/tmp/referential-%05d-%02d.png", i, t);
+ write_referential_png(buffer, hierarchy->nb_levels() - 1, image, &referential, 0);
+ } else if(detector) {
+ int n_family = 0;
+ int n_feature = global.material_feature_nb;
+ while(n_feature > detector->_pi_feature_families[n_family]->nb_features()) {
+ n_family++;
+ n_feature -= detector->_pi_feature_families[n_family]->nb_features();
+ }
+ pf = detector->_pi_feature_families[n_family]->get_feature(n_feature);
+ sprintf(buffer, "/tmp/pf-%05d-%02d-%05d.png", i, t, global.material_feature_nb);
+ write_referential_png(buffer,
+ hierarchy->nb_levels() - 1,
+ image,
+ &referential,
+ pf);
}
- u++;
}
pool->release_image(i);
@@ -233,7 +214,6 @@ void write_image_with_detections(const char *filename,
}
}
- (*global.log_stream) << "Writing " << filename << endl;
-
+ cout << "Writing " << filename << endl;
result_sp.write_png(filename);
}