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

Function create_new_dataset

tools/imglab/src/main.cpp:33–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31// ----------------------------------------------------------------------------------------
32
33void create_new_dataset (
34 const command_line_parser& parser
35)
36{
37 using namespace dlib::image_dataset_metadata;
38
39 const std::string filename = parser.option("c").argument();
40 // make sure the file exists so we can use the get_parent_directory() command to
41 // figure out it's parent directory.
42 make_empty_file(filename);
43 const std::string parent_dir = get_parent_directory(file(filename));
44
45 unsigned long depth = 0;
46 if (parser.option("r"))
47 depth = 30;
48
49 dataset meta;
50 meta.name = "imglab dataset";
51 meta.comment = "Created by imglab tool.";
52 for (unsigned long i = 0; i < parser.number_of_arguments(); ++i)
53 {
54 try
55 {
56 const string temp = strip_path(file(parser[i]), parent_dir);
57 meta.images.push_back(image(temp));
58 }
59 catch (dlib::file::file_not_found&)
60 {
61 // then parser[i] should be a directory
62
63 std::vector<file> files = get_files_in_directory_tree(parser[i],
64 match_endings(".png .PNG .jpeg .JPEG .jpg .JPG .bmp .BMP .dng .DNG .gif .GIF .jxl .JXL .webp .WEBP"),
65 depth);
66 sort(files.begin(), files.end());
67
68 for (unsigned long j = 0; j < files.size(); ++j)
69 {
70 meta.images.push_back(image(strip_path(files[j], parent_dir)));
71 }
72 }
73 }
74
75 save_image_dataset_metadata(meta, filename);
76}
77
78// ----------------------------------------------------------------------------------------
79

Callers 1

mainFunction · 0.85

Calls 13

make_empty_fileFunction · 0.85
get_parent_directoryFunction · 0.85
strip_pathFunction · 0.85
imageClass · 0.85
number_of_argumentsMethod · 0.80
fileClass · 0.50
match_endingsClass · 0.50
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected