Made --cluster skip empty images

This commit is contained in:
Davis King 2016-09-18 11:54:12 -04:00
parent b040e65414
commit a2c152e8f1

View File

@ -111,6 +111,18 @@ double mean_aspect_ratio (
// ----------------------------------------------------------------------------------------
bool has_non_ignored_boxes (const image_dataset_metadata::image& img)
{
for (auto&& b : img.boxes)
{
if (!b.ignore)
return true;
}
return false;
}
// ----------------------------------------------------------------------------------------
int cluster_dataset(
const dlib::command_line_parser& parser
)
@ -140,8 +152,9 @@ int cluster_dataset(
for (unsigned long i = 0; i < data.images.size(); ++i)
{
pbar.print_status(i);
if (data.images[i].boxes.size() == 0)
if (!has_non_ignored_boxes(data.images[i]))
continue;
array2d<rgb_pixel> img, chip;
load_image(img, data.images[i].filename);
@ -181,8 +194,9 @@ int cluster_dataset(
{
idata[i].first = std::numeric_limits<double>::infinity();
idata[i].second.filename = data.images[i].filename;
if (data.images[i].boxes.size() == 0)
if (!has_non_ignored_boxes(data.images[i]))
continue;
for (unsigned long j = 0; j < data.images[i].boxes.size(); ++j)
{
idata[i].second.boxes.push_back(data.images[i].boxes[j]);