}
- else if(strcmp(new_argv[c], "write-target-poses") == 0) {
- check(main_pool, "No pool available.");
- LabelledImage *image;
- for(int p = 0; p < main_pool->nb_images(); p++) {
- image = main_pool->grab_image(p);
- for(int t = 0; t < image->nb_targets(); t++) {
- cout << "IMAGE " << p << " TARGET " << t << endl;
- image->get_target_pose(t)->print(&cout);
- }
- main_pool->release_image(p);
- }
- }
-
//////////////////////////////////////////////////////////////////////
else if(strcmp(new_argv[c], "train-detector") == 0) {
detector->compute_thresholds(validation_pool, global.wanted_true_positive_rate);
}
- else if(strcmp(new_argv[c], "check-hierarchy") == 0) {
- cout << "-- CHECK HIERARCHY ---------------------------------------------------" << endl;
- PoseCellHierarchy *h = new PoseCellHierarchy(hierarchy_pool);
- cout << "Train incompatible poses " << h->nb_incompatible_poses(train_pool) << endl;
- cout << "Validation incompatible poses " << h->nb_incompatible_poses(validation_pool) << endl;
- delete h;
- }
-
- //////////////////////////////////////////////////////////////////////
-
- else if(strcmp(new_argv[c], "validate-detector") == 0) {
- cout << "-- VALIDATE DETECTOR -------------------------------------------------" << endl;
-
- check(validation_pool, "No validation pool available.");
- check(detector, "No detector.");
-
- print_decimated_error_rate(global.nb_levels - 1, validation_pool, detector);
- }
-
//////////////////////////////////////////////////////////////////////
else if(strcmp(new_argv[c], "test-detector") == 0) {
}
}
- else if(strcmp(new_argv[c], "parse-images") == 0) {
- cout << "-- PARSING IMAGES -----------------------------------------------------" << endl;
- check(detector, "No detector.");
- while(!cin.eof()) {
- char image_name[buffer_size];
- cin.getline(image_name, buffer_size);
- if(strlen(image_name) > 0) {
- parse_scene(detector, image_name);
- }
- }
- }
-
//////////////////////////////////////////////////////////////////////
else if(strcmp(new_argv[c], "sequence-test-detector") == 0) {
write_pool_images_with_poses_and_referentials(train_pool, detector);
}
- else if(strcmp(new_argv[c], "produce-materials") == 0) {
- cout << "-- PRODUCING MATERIALS -----------------------------------------------" << endl;
-
- check(hierarchy_pool, "No hierarchy pool available.");
- check(test_pool, "No test pool available.");
-
- PoseCellHierarchy *hierarchy;
-
- cout << "Creating hierarchy" << endl;
-
- hierarchy = new PoseCellHierarchy(hierarchy_pool);
-
- LabelledImage *image;
- for(int p = 0; p < test_pool->nb_images(); p++) {
- image = test_pool->grab_image(p);
- if(image->width() == 640 && image->height() == 480) {
- PoseCellSet pcs;
- hierarchy->add_root_cells(image, &pcs);
- cout << "WE HAVE " << pcs.nb_cells() << " CELLS" << endl;
- exit(0);
- test_pool->release_image(p);
- }
- }
-
- delete hierarchy;
-
- }
-
//////////////////////////////////////////////////////////////////////
else {
parser->add_association("max-head-radius", "200", false);
// How many translation cell for one scale when generating the "top
// level" cells for an image.
- parser->add_association("root-cell-nb-xy-per-scale", "5", false);
+ parser->add_association("root-cell-nb-xy-per-radius", "5", false);
// What is the minimum size of the windows
parser->add_association("pi-feature-window-min-size", "0.1", false);
min_head_radius = parser->get_association_scalar("min-head-radius");
max_head_radius = parser->get_association_scalar("max-head-radius");
- root_cell_nb_xy_per_scale = parser->get_association_int("root-cell-nb-xy-per-scale");
+ root_cell_nb_xy_per_radius = parser->get_association_int("root-cell-nb-xy-per-radius");
pi_feature_window_min_size = parser->get_association_scalar("pi-feature-window-min-size");
int nb_scales_per_power_of_two;
scalar_t min_head_radius;
scalar_t max_head_radius;
- int root_cell_nb_xy_per_scale;
+ int root_cell_nb_xy_per_radius;
scalar_t pi_feature_window_min_size;
// Contact <francois.fleuret@idiap.ch> for comments & bug reports //
///////////////////////////////////////////////////////////////////////////
+/*
+
+ A pool of images is used to avoid having too many images in memory
+ at the same time. It can be either a file, or a subset of another
+ pool of images (see the subclasses).
+
+ */
+
#ifndef LABELLED_IMAGE_POOL_H
#define LABELLED_IMAGE_POOL_H
public:
virtual ~LabelledImagePool();
virtual int nb_images() = 0;
+ // grab_image _DOES NOT_ build the rich structure of the grabbed
+ // image. One has to call compute_rich_structure() explicitely for
+ // that!
virtual LabelledImage *grab_image(int n_image) = 0;
virtual void release_image(int n_image) = 0;
};
public:
LabelledImagePoolFile(char *file_name);
virtual ~LabelledImagePoolFile();
-
virtual int nb_images();
-
- // grab_image(n) does _NOT_ build the rich structure. One has to call
- // compute_rich_structure() for that!
virtual LabelledImage *grab_image(int n_image);
virtual void release_image(int n_image);
};
}
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);
-
- int u = 0;
-
- // image->compute_rich_structure();
-
- for(int t = 0; t < image->nb_targets(); t++) {
-
- image->get_target_pose(t)->draw(4, 255, 0, 0,
- hierarchy->nb_levels() - 1, &result_sp);
-
- hierarchy->get_containing_cell(image,
- hierarchy->nb_levels() - 1,
- image->get_target_pose(t), &target_cell);
-
- target_cell.get_centroid(&p);
-
- p.draw(4, 0, 255, 0, hierarchy->nb_levels() - 1, &result_sp);
-
- 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);
+ image = pool->grab_image(i);
+
+ RGBImage result(image->width(), image->height());
+ image->to_rgb(&result);
+ RGBImageSubpixel result_sp(&result);
+
+ int u = 0;
+
+ // image->compute_rich_structure();
+
+ for(int t = 0; t < image->nb_targets(); t++) {
+
+ image->get_target_pose(t)->draw(4, 255, 0, 0,
+ hierarchy->nb_levels() - 1, &result_sp);
+
+ hierarchy->get_containing_cell(image,
+ hierarchy->nb_levels() - 1,
+ image->get_target_pose(t), &target_cell);
+
+ target_cell.get_centroid(&p);
+
+ p.draw(4, 0, 255, 0, hierarchy->nb_levels() - 1, &result_sp);
+
+ 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);
}
- u++;
- }
+ }
+ u++;
+ }
- // sprintf(buffer, "/tmp/image-%05d.png", i);
- // cout << "Writing " << buffer << endl;
- // result_sp.write_png(buffer);
+ // sprintf(buffer, "/tmp/image-%05d.png", i);
+ // cout << "Writing " << buffer << endl;
+ // result_sp.write_png(buffer);
- // if(global.write_tag_images) {
- // sprintf(buffer, "/tmp/image-%05d_tags.png", i);
- // cout << "Writing " << buffer << endl;
- // image->compute_rich_structure();
- // image->write_tag_png(buffer);
- // }
+ // if(global.write_tag_images) {
+ // sprintf(buffer, "/tmp/image-%05d_tags.png", i);
+ // cout << "Writing " << buffer << endl;
+ // image->compute_rich_structure();
+ // image->write_tag_png(buffer);
+ // }
- pool->release_image(i);
- }
+ pool->release_image(i);
+ }
delete hierarchy;
}
loss_machine->subsample(_nb_cells, labels, tmp_responses,
_nb_negative_cells, sample_nb_occurences, sample_responses,
1);
+
c = 0;
for(int i = 0; i < _nb_images; i++) {
for(int d = 0; d < _parsings[i]->nb_cells(); d++) {
delete[] sample_responses;
delete[] sample_nb_occurences;
+
+ delete[] labels;
+ delete[] tmp_responses;
}
void ParsingPool::update_cell_responses(PiFeatureFamily *pi_feature_family,
s = 0;
c = 0;
-// global.bar.init(&cout, _nb_images);
-
for(int i = 0; i < _nb_images; i++) {
int *to_collect = new int[_parsings[i]->nb_cells()];
delete[] to_collect;
c += _parsings[i]->nb_cells();
-
-// global.bar.refresh(&cout, i);
}
-// global.bar.finish(&cout);
-
delete[] tmp_responses;
delete[] labels;
}
®istered_window_a);
referential->draw_window(image, _registration_a, ®istered_window_a, 0);
-
-// if(!global.pictures_for_article) {
-// int tag = referential->register_edge(_registration_a, _tag);
-
-// referential->draw_edge_and_scale(image, _registration_a, ®istered_window_a,
-// tag, _edge_scale);
-// }
}
void PiFeature::print_edge_thresholding(ostream *os) {
scalar_t _head_ux, _head_uy, _head_vx, _head_vy;
scalar_t _head_ux_nopolarity, _head_uy_nopolarity, _head_vx_nopolarity, _head_vy_nopolarity;
+ //**********************************************************************
// Useless fields, but they are necessary so that the optimized code
// with g++ gives the same results as some reference
// experiments. Sorry for that.
scalar_t _body_xc, _body_yc;
scalar_t _body_tilt;
+ //**********************************************************************
// The belly frame is defined by the belly location and head scale
scalar_t _belly_xc, _belly_yc;
enum {
// A square frame centered on the head, of size four times the
- // head radius and, flipped vertically if the belly is on the left
- // of the head center
+ // head radius and, flipped horizontally if the belly 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 belly, of size eight times the head
- // radius, flipped vertically if the belly is on the left of the
+ // radius, flipped horizontally if the belly is on the left of the
// head center
RM_BELLY,
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
+ // head for instance [-0.5, 0.5] x [-0.5, 0.5] corresponds to the
+ // head bounding box
void register_rectangle(int registration_mode,
Rectangle *original,
_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_scale = global.root_cell_nb_xy_per_radius;
LabelledImage *image;
int nb_total_targets = 0;
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);
OPTS="${OPTS} --force-head-belly-independence=yes"
fi
- if [[ $1 == "light" ]]; then
+ if [[ $1 == "valgrind" ]]; then
OPTS="${OPTS} --nb-classifiers-per-level=1 --nb-weak-learners-per-classifier=10"
- OPTS="${OPTS} --proportion-for-train=0.1 --proportion-for-validation=0.1 --proportion-for-test=0.1"
+ OPTS="${OPTS} --proportion-for-train=0.1 --proportion-for-validation=0.025 --proportion-for-test=0.01"
+ OPTS="${OPTS} --wanted-true-positive-rate=0.1"
+ DEBUGGER="valgrind --db-attach=yes --leak-check=full --show-reachable=yes"
fi
- ./folding \
+ ${DEBUGGER} ./folding \
--niceness=15 \
--pool-name=${POOL_NAME} \
--nb-levels=2 \