Commit 91c63155 authored by Davis King's avatar Davis King

Further simplified initial image selection.

parent 991cb97a
...@@ -409,15 +409,13 @@ int main(int argc, char** argv) ...@@ -409,15 +409,13 @@ int main(int argc, char** argv)
parser.add_option("h","Displays this information."); parser.add_option("h","Displays this information.");
parser.add_option("c","Create an XML file named <arg> listing a set of images.",1); parser.add_option("c","Create an XML file named <arg> listing a set of images.",1);
parser.add_option("d","Include all images files in directory <arg> in the new image file list.",1);
parser.add_option("r","Search directories recursively for images."); parser.add_option("r","Search directories recursively for images.");
parser.parse(argc, argv); parser.parse(argc, argv);
const char* singles[] = {"h","c","r"}; const char* singles[] = {"h","c","r"};
parser.check_one_time_options(singles); parser.check_one_time_options(singles);
parser.check_sub_option("c", "d"); parser.check_sub_option("c", "r");
parser.check_sub_option("d", "r");
if (parser.option("h")) if (parser.option("h"))
{ {
...@@ -437,23 +435,25 @@ int main(int argc, char** argv) ...@@ -437,23 +435,25 @@ int main(int argc, char** argv)
make_empty_file(filename); make_empty_file(filename);
const std::string parent_dir = get_parent_directory(file(filename)).full_name(); const std::string parent_dir = get_parent_directory(file(filename)).full_name();
unsigned long depth = 0;
if (parser.option("r"))
depth = 30;
image_dataset_metadata metadata; image_dataset_metadata metadata;
metadata.name = "imglab dataset"; metadata.name = "imglab dataset";
metadata.comment = "Created by imglab tool."; metadata.comment = "Created by imglab tool.";
for (unsigned long i = 0; i < parser.number_of_arguments(); ++i) for (unsigned long i = 0; i < parser.number_of_arguments(); ++i)
{
try
{ {
const string temp = strip_path(file(parser[i]).full_name(), parent_dir); const string temp = strip_path(file(parser[i]).full_name(), parent_dir);
metadata.images.push_back(image(temp)); metadata.images.push_back(image(temp));
} }
catch (dlib::file::file_not_found&)
for (unsigned long i = 0; i < parser.option("d").count(); ++i)
{ {
unsigned long depth = 0; // then parser[i] should be a directory
if (parser.option("r"))
depth = 30;
std::vector<file> files = get_files_in_directory_tree(parser.option("d").argument(0,i), std::vector<file> files = get_files_in_directory_tree(parser[i],
match_endings(".png .PNG .jpeg .JPEG .jpg .JPG .bmp .BMP .dng .DNG"), match_endings(".png .PNG .jpeg .JPEG .jpg .JPG .bmp .BMP .dng .DNG"),
depth); depth);
sort(files.begin(), files.end()); sort(files.begin(), files.end());
...@@ -463,6 +463,7 @@ int main(int argc, char** argv) ...@@ -463,6 +463,7 @@ int main(int argc, char** argv)
metadata.images.push_back(image(strip_path(files[j].full_name(), parent_dir))); metadata.images.push_back(image(strip_path(files[j].full_name(), parent_dir)));
} }
} }
}
save_image_dataset_metadata(metadata, filename); save_image_dataset_metadata(metadata, filename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment