MCPcopy Create free account
hub / github.com/davisking/dlib / metadata_editor

Method metadata_editor

tools/imglab/src/metadata_editor.cpp:30–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28);
29
30metadata_editor::
31metadata_editor(
32 const std::string& filename_,
33 const std::string& font_path
34) :
35 mbar(*this),
36 lb_images(*this),
37 image_pos(0),
38 display(*this),
39 overlay_label_name(*this),
40 overlay_label(*this),
41 keyboard_jump_pos(0),
42 last_keyboard_jump_pos_update(0)
43{
44 file metadata_file(filename_);
45 filename = metadata_file.full_name();
46
47 // Set the custom label fonts
48 if (!font_path.empty())
49 {
50 const auto custom_font = std::make_shared<dlib::bdf_font>();
51 std::ifstream fin(font_path);
52 if (fin.good())
53 {
54 custom_font->read_bdf_file(fin, 0xFFFF);
55 custom_font->adjust_metrics();
56 font = std::move(custom_font);
57 }
58 else
59 {
60 std::cerr << "WARNING: could not open file '" + font_path + "', using default font\n.";
61 }
62 }
63 display.set_main_font(font);
64 overlay_label.set_main_font(font);
65
66 // Make our current directory be the one that contains the metadata file. We
67 // do this because that file might contain relative paths to the image files
68 // we are supposed to be loading.
69 set_current_dir(get_parent_directory(metadata_file).full_name());
70
71 load_image_dataset_metadata(metadata, filename);
72
73 dlib::array<std::string>::expand_1a files;
74 files.resize(metadata.images.size());
75 for (unsigned long i = 0; i < metadata.images.size(); ++i)
76 {
77 files[i] = metadata.images[i].filename;
78 }
79 lb_images.load(files);
80 lb_images.enable_multiple_select();
81
82 lb_images.set_click_handler(*this, &metadata_editor::on_lb_images_clicked);
83
84 overlay_label_name.set_text("Next Label: ");
85 overlay_label.set_width(200);
86
87 display.set_image_clicked_handler(*this, &metadata_editor::on_image_clicked);

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
get_parent_directoryFunction · 0.85
adjust_metricsMethod · 0.80
set_main_fontMethod · 0.80
add_menu_itemMethod · 0.80
set_current_dirFunction · 0.50
menu_item_textClass · 0.50
menu_item_separatorClass · 0.50

Tested by

no test coverage detected