Commit dcb8b6ff authored by Davis King's avatar Davis King

Changed code to avoid compiler warnings. Also added support for the

difficult, truncated, and occluded metadata fields of the pascal datasets.
parent 0ac4a540
......@@ -76,9 +76,9 @@ namespace
}
else if (words.size() > 4 && (words[2] == "for" || words[2] == "on") && words[3] == "object")
{
int idx = sa = words[4];
long idx = sa = words[4];
--idx;
if (idx >= img.boxes.size())
if (idx >= (long)img.boxes.size())
throw dlib::error("Invalid object id number of " + words[4]);
if (words[0] == "Center" && words[1] == "point" && words.size() > 9)
......
......@@ -49,9 +49,9 @@ namespace
}
virtual void start_element (
const unsigned long line_number,
const unsigned long ,
const std::string& name,
const dlib::attribute_list& atts
const dlib::attribute_list&
)
{
if (ts.size() == 0 && name != "annotation")
......@@ -66,7 +66,7 @@ namespace
}
virtual void end_element (
const unsigned long line_number,
const unsigned long ,
const std::string& name
)
{
......@@ -106,6 +106,39 @@ namespace
{
temp_box.label = trim(data);
}
else if (ts.back() == "difficult" && ts[ts.size()-2] == "object")
{
if (trim(data) == "0" || trim(data) == "false")
{
temp_box.difficult = false;
}
else
{
temp_box.difficult = true;
}
}
else if (ts.back() == "truncated" && ts[ts.size()-2] == "object")
{
if (trim(data) == "0" || trim(data) == "false")
{
temp_box.truncated = false;
}
else
{
temp_box.truncated = true;
}
}
else if (ts.back() == "occluded" && ts[ts.size()-2] == "object")
{
if (trim(data) == "0" || trim(data) == "false")
{
temp_box.occluded = false;
}
else
{
temp_box.occluded = true;
}
}
}
}
......
......@@ -70,6 +70,12 @@ namespace dlib
<< "left='" << b.rect.left() << "' "
<< "width='" << b.rect.width() << "' "
<< "height='" << b.rect.height() << "'";
if (b.difficult)
fout << " difficult='" << b.difficult << "'";
if (b.truncated)
fout << " truncated='" << b.truncated << "'";
if (b.occluded)
fout << " occluded='" << b.occluded << "'";
if (b.has_label() || b.has_head())
{
......@@ -135,7 +141,7 @@ namespace dlib
}
virtual void start_element (
const unsigned long line_number,
const unsigned long ,
const std::string& name,
const dlib::attribute_list& atts
)
......@@ -170,6 +176,10 @@ namespace dlib
if (atts.is_in_list("height")) temp_box.rect.bottom() = sa = atts["height"];
else throw dlib::error("<box> missing required attribute 'height'");
if (atts.is_in_list("difficult")) temp_box.difficult = sa = atts["difficult"];
if (atts.is_in_list("truncated")) temp_box.truncated = sa = atts["truncated"];
if (atts.is_in_list("occluded")) temp_box.occluded = sa = atts["occluded"];
temp_box.rect.bottom() += temp_box.rect.top()-1;
temp_box.rect.right() += temp_box.rect.left()-1;
}
......@@ -193,7 +203,7 @@ namespace dlib
}
virtual void end_element (
const unsigned long line_number,
const unsigned long ,
const std::string& name
)
{
......
......@@ -15,13 +15,22 @@ namespace dlib
{
struct box
{
box() : head(-0xFFFF,-0xFFFF) {}
box(
) :
head(-0xFFFF,-0xFFFF),
difficult(false),
truncated(false),
occluded(false)
{}
rectangle rect;
// optional fields
std::string label;
point head; // a value of (-0xFFFF,-0xFFFF) indicates the field not supplied
bool difficult;
bool truncated;
bool occluded;
bool has_head() const { return head != point(-0xFFFF,-0xFFFF); }
bool has_label() const { return label.size() != 0; }
......
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