From 92ac70dc6d18590fcc33adc4f4c72ac8b97692ae Mon Sep 17 00:00:00 2001 From: Davis King Date: Mon, 20 Jun 2011 20:25:06 -0400 Subject: [PATCH] Now the tool can modify the ground truth boxes. --- tools/imglab/src/metadata_editor.cpp | 35 ++++++++++++++++++++++++++++ tools/imglab/src/metadata_editor.h | 2 ++ 2 files changed, 37 insertions(+) diff --git a/tools/imglab/src/metadata_editor.cpp b/tools/imglab/src/metadata_editor.cpp index 848aaa88f..af551d6ac 100644 --- a/tools/imglab/src/metadata_editor.cpp +++ b/tools/imglab/src/metadata_editor.cpp @@ -49,6 +49,9 @@ metadata_editor( overlay_label_name.set_text("Next Label: "); overlay_label.set_width(200); + display.set_overlay_rects_changed_handler(*this, &metadata_editor::on_overlay_rects_changed); + overlay_label.set_text_modified_handler(*this, &metadata_editor::on_overlay_label_changed); + mbar.set_number_of_menus(1); mbar.set_menu_name(0,"File",'F'); @@ -350,4 +353,36 @@ load_image_and_set_size( // ---------------------------------------------------------------------------------------- +void metadata_editor:: +on_overlay_rects_changed( +) +{ + using namespace dlib::image_dataset_metadata; + if (image_pos < metadata.images.size()) + { + const std::vector& rects = display.get_overlay_rects(); + + std::vector& boxes = metadata.images[image_pos].boxes; + + boxes.clear(); + for (unsigned long i = 0; i < rects.size(); ++i) + { + box temp; + temp.label = rects[i].label; + temp.rect = rects[i].rect; + boxes.push_back(temp); + } + } +} + +// ---------------------------------------------------------------------------------------- + +void metadata_editor:: +on_overlay_label_changed( +) +{ + display.set_default_overlay_rect_label(trim(overlay_label.text())); +} + +// ---------------------------------------------------------------------------------------- diff --git a/tools/imglab/src/metadata_editor.h b/tools/imglab/src/metadata_editor.h index 95f114448..659960e3a 100644 --- a/tools/imglab/src/metadata_editor.h +++ b/tools/imglab/src/metadata_editor.h @@ -35,6 +35,8 @@ private: void save_metadata_to_file (const std::string& file); void load_image(unsigned long idx); void load_image_and_set_size(unsigned long idx); + void on_overlay_rects_changed(); + void on_overlay_label_changed(); std::string filename; dlib::image_dataset_metadata::dataset metadata;