X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=materials.cc;h=eea7395e2177d3c853ddfdb3c13571ad7a18a562;hb=e1d8ccc0f252d9be9590fe5a6106a4336762b6aa;hp=64729dbadae673ab6ba889e68a69ec42756e0f80;hpb=4953a336630d0ee905c949bf1fe846b85cabb744;p=folded-ctf.git
diff --git a/materials.cc b/materials.cc
index 64729db..eea7395 100644
--- a/materials.cc
+++ b/materials.cc
@@ -12,7 +12,9 @@
// 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 //
+// Written by Francois Fleuret //
+// (C) Idiap Research Institute //
+// //
// Contact for comments & bug reports //
///////////////////////////////////////////////////////////////////////////
@@ -75,26 +77,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 +92,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 +130,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 +147,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 +210,6 @@ void write_image_with_detections(const char *filename,
}
}
- (*global.log_stream) << "Writing " << filename << endl;
-
+ cout << "Writing " << filename << endl;
result_sp.write_png(filename);
}