Commit 1df8c441 authored by Davis King's avatar Davis King

Upgraded load_image_dataset() so that it returns the list of ignored

rectangles.
parent 647285e8
......@@ -24,7 +24,7 @@ namespace dlib
typename image_type,
typename MM
>
void load_image_dataset (
std::vector<std::vector<rectangle> > load_image_dataset (
array<image_type,MM>& images,
std::vector<std::vector<rectangle> >& object_locations,
const std::string& filename,
......@@ -36,6 +36,8 @@ namespace dlib
object_locations.clear();
const std::string old_working_dir = get_current_dir();
std::vector<std::vector<rectangle> > ignored_rects;
// Set the current directory to be the one that contains the
// metadata file. We do this because the file might contain
// file paths which are relative to this folder.
......@@ -49,27 +51,33 @@ namespace dlib
load_image_dataset_metadata(data, filename);
image_type img;
std::vector<rectangle> rects;
std::vector<rectangle> rects, ignored;
for (unsigned long i = 0; i < data.images.size(); ++i)
{
rects.clear();
ignored.clear();
for (unsigned long j = 0; j < data.images[i].boxes.size(); ++j)
{
if (label.size() == 0 || data.images[i].boxes[j].label == label)
{
rects.push_back(data.images[i].boxes[j].rect);
if (data.images[i].boxes[j].ignore)
ignored.push_back(data.images[i].boxes[j].rect);
else
rects.push_back(data.images[i].boxes[j].rect);
}
}
if (!skip_empty_images || rects.size() != 0)
{
object_locations.push_back(rects);
ignored_rects.push_back(ignored);
load_image(img, data.images[i].filename);
images.push_back(img);
}
}
set_current_dir(old_working_dir);
return ignored_rects;
}
// ----------------------------------------------------------------------------------------
......@@ -78,13 +86,13 @@ namespace dlib
typename image_type,
typename MM
>
void load_image_dataset (
std::vector<std::vector<rectangle> > load_image_dataset (
array<image_type,MM>& images,
std::vector<std::vector<rectangle> >& object_locations,
const std::string& filename
)
{
load_image_dataset(images, object_locations, filename, "");
return load_image_dataset(images, object_locations, filename, "");
}
// ----------------------------------------------------------------------------------------
......
......@@ -19,7 +19,7 @@ namespace dlib
typename image_type,
typename MM
>
void load_image_dataset (
std::vector<std::vector<rectangle> > load_image_dataset (
array<image_type,MM>& images,
std::vector<std::vector<rectangle> >& object_locations,
const std::string& filename,
......@@ -39,17 +39,25 @@ namespace dlib
- #images.size() == #object_locations.size()
- This routine is capable of loading any image format which can be read by the
load_image() routine.
- let IGNORED_RECTS denote the vector returned from this function.
- IGNORED_RECTS.size() == #object_locations.size()
- IGNORED_RECTS == a list of the rectangles which have the "ignore" flag set to
true in the XML file.
- for all valid i:
- #images[i] == a copy of the i-th image from the dataset
- #images[i] == a copy of the i-th image from the dataset.
- #object_locations[i] == a vector of all the rectangles associated with
#images[i].
#images[i]. Note that only rectangles that are not marked as "ignore"
are stored into #object_locations.
- IGNORED_RECTS[i] == A vector of all the rectangles associated with
#images[i] that are marked as "ignore".
- if (skip_empty_images == true) then
- #object_locations[i].size() != 0
(i.e. only images with detection boxes in them will be loaded.)
(i.e. only images with non-ignored boxes in them will be loaded.)
- if (labels != "") then
- only boxes with the given label will be loaded into object_locations.
- Only boxes with the given label will be loaded into object_locations
and IGNORED_RECTS.
- else
- all boxes in the dataset will be loaded into object_locations.
- all boxes in the dataset will be loaded regardless of their labels.
!*/
// ----------------------------------------------------------------------------------------
......@@ -58,7 +66,7 @@ namespace dlib
typename image_type,
typename MM
>
void load_image_dataset (
std::vector<std::vector<rectangle> > load_image_dataset (
array<image_type,MM>& images,
std::vector<std::vector<rectangle> >& object_locations,
const std::string& filename
......@@ -68,7 +76,7 @@ namespace dlib
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
ensures
- performs: load_image_dataset(images, object_locations, filename, "");
- performs: return load_image_dataset(images, object_locations, filename, "");
(i.e. it ignores box labels and therefore loads all the boxes in the dataset)
!*/
......
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