Commit 85d421c3 authored by Davis King's avatar Davis King

Added --rmignore

parent 98bd4542
......@@ -627,6 +627,7 @@ int main(int argc, char** argv)
"the results as cluster_###.xml and cluster_###.jpg files.",1);
parser.add_option("ignore", "Mark boxes labeled as <arg> as ignored. The resulting XML file is output as a separate file and the original is not modified.",1);
parser.add_option("rmlabel","Remove all boxes labeled <arg> and save the results to a new XML file.",1);
parser.add_option("rmignore","Remove all boxes marked ignore and save the results to a new XML file.");
parser.add_option("rm-if-overlaps","Remove all boxes labeled <arg> if they overlap any box not labeled <arg> and save the results to a new XML file.",1);
parser.add_option("jpg", "When saving images to disk, write them as jpg files instead of png.");
......@@ -644,7 +645,7 @@ int main(int argc, char** argv)
const char* singles[] = {"h","c","r","l","files","convert","parts","rmdiff", "rmtrunc", "rmdupes", "seed", "shuffle", "split", "add",
"flip", "rotate", "tile", "size", "cluster", "resample", "min-object-size", "rmempty",
"crop-size", "cropped-object-size", "rmlabel", "rm-if-overlaps", "sort-num-objects", "one-object-per-image", "jpg"};
"crop-size", "cropped-object-size", "rmlabel", "rm-if-overlaps", "sort-num-objects", "one-object-per-image", "jpg", "rmignore"};
parser.check_one_time_options(singles);
const char* c_sub_ops[] = {"r", "convert"};
parser.check_sub_options("c", c_sub_ops);
......@@ -658,6 +659,7 @@ int main(int argc, char** argv)
parser.check_incompatible_options("c", "rmdiff");
parser.check_incompatible_options("c", "rmempty");
parser.check_incompatible_options("c", "rmlabel");
parser.check_incompatible_options("c", "rmignore");
parser.check_incompatible_options("c", "rm-if-overlaps");
parser.check_incompatible_options("c", "rmdupes");
parser.check_incompatible_options("c", "rmtrunc");
......@@ -710,6 +712,8 @@ int main(int argc, char** argv)
parser.check_incompatible_options("rmempty", "rename");
parser.check_incompatible_options("rmlabel", "ignore");
parser.check_incompatible_options("rmlabel", "rename");
parser.check_incompatible_options("rmignore", "ignore");
parser.check_incompatible_options("rmignore", "rename");
parser.check_incompatible_options("rm-if-overlaps", "ignore");
parser.check_incompatible_options("rm-if-overlaps", "rename");
parser.check_incompatible_options("rmdupes", "rename");
......@@ -871,6 +875,32 @@ int main(int argc, char** argv)
return EXIT_SUCCESS;
}
if (parser.option("rmignore"))
{
if (parser.number_of_arguments() != 1)
{
cerr << "The --rmignore option requires you to give one XML file on the command line." << endl;
return EXIT_FAILURE;
}
dlib::image_dataset_metadata::dataset data;
load_image_dataset_metadata(data, parser[0]);
for (auto&& img : data.images)
{
std::vector<dlib::image_dataset_metadata::box> boxes;
for (auto&& b : img.boxes)
{
if (!b.ignore)
boxes.push_back(b);
}
img.boxes = boxes;
}
save_image_dataset_metadata(data, parser[0] + ".rmignore.xml");
return EXIT_SUCCESS;
}
if (parser.option("rm-if-overlaps"))
{
if (parser.number_of_arguments() != 1)
......
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