Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dlib/data_io/load_image_dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ namespace dlib
}
else
{
std::vector<point> partlist(parts_idx.size(), OBJECT_PART_NOT_PRESENT);
std::vector<dpoint> partlist(parts_idx.size(), OBJECT_PART_NOT_PRESENT);

// populate partlist with all the parts present in this box.
const std::map<std::string,point>& parts = data.images[i].boxes[j].parts;
Expand Down
40 changes: 29 additions & 11 deletions dlib/image_processing/full_object_detection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ namespace dlib

// ----------------------------------------------------------------------------------------

const static point OBJECT_PART_NOT_PRESENT(0x7FFFFFFF,
0x7FFFFFFF);
const static dpoint OBJECT_PART_NOT_PRESENT(0x7FFFFFFFFFFFF,
0x7FFFFFFFFFFFF);

// ----------------------------------------------------------------------------------------

Expand All @@ -23,9 +23,15 @@ namespace dlib
public:
full_object_detection(
const rectangle& rect_,
const std::vector<point>& parts_
const std::vector<dpoint>& parts_
) : rect(rect_), parts(parts_) {}

full_object_detection(
const rectangle& rect_,
const std::vector<point>& parts_
) : rect(rect_), parts (parts_.begin(), parts_.end())
{}

full_object_detection(){}

explicit full_object_detection(
Expand All @@ -36,13 +42,13 @@ namespace dlib
rectangle& get_rect() { return rect; }
unsigned long num_parts() const { return parts.size(); }

const point& part(
const dpoint& part(
unsigned long idx
) const
{
// make sure requires clause is not broken
DLIB_ASSERT(idx < num_parts(),
"\t point full_object_detection::part()"
"\t dpoint full_object_detection::part()"
<< "\n\t Invalid inputs were given to this function "
<< "\n\t idx: " << idx
<< "\n\t num_parts(): " << num_parts()
Expand All @@ -51,13 +57,13 @@ namespace dlib
return parts[idx];
}

point& part(
dpoint& part(
unsigned long idx
)
{
// make sure requires clause is not broken
DLIB_ASSERT(idx < num_parts(),
"\t point full_object_detection::part()"
"\t dpoint full_object_detection::part()"
<< "\n\t Invalid inputs were given to this function "
<< "\n\t idx: " << idx
<< "\n\t num_parts(): " << num_parts()
Expand All @@ -71,7 +77,7 @@ namespace dlib
std::ostream& out
)
{
int version = 1;
int version = 2;
serialize(version, out);
serialize(item.rect, out);
serialize(item.parts, out);
Expand All @@ -84,11 +90,23 @@ namespace dlib
{
int version = 0;
deserialize(version, in);
if (version != 1)

if (version != 1 && version != 2)
throw serialization_error("Unexpected version encountered while deserializing dlib::full_object_detection.");

deserialize(item.rect, in);
deserialize(item.parts, in);

// Legacy support: read vector<point, 2> and cast to vector<dpoint, 2>
if (version == 1) {
std::vector<point> legacy_parts;
deserialize(legacy_parts, in);
item.parts = std::vector<dpoint>(legacy_parts.begin(), legacy_parts.end());
}

else { // version 2 - deserialize into vector<dpoint, 2>
deserialize(item.parts, in);
}

}

bool operator==(
Expand All @@ -109,7 +127,7 @@ namespace dlib

private:
rectangle rect;
std::vector<point> parts;
std::vector<dpoint> parts;
};

// ----------------------------------------------------------------------------------------
Expand Down
22 changes: 16 additions & 6 deletions dlib/image_processing/full_object_detection_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace dlib
{

// ----------------------------------------------------------------------------------------

const static point OBJECT_PART_NOT_PRESENT(0x7FFFFFFF,
0x7FFFFFFF);
const static dpoint OBJECT_PART_NOT_PRESENT(0x7FFFFFFFFFFFF,
0x7FFFFFFFFFFFF);

// ----------------------------------------------------------------------------------------

Expand All @@ -29,7 +29,7 @@ namespace dlib

full_object_detection(
const rectangle& rect,
const std::vector<point>& parts
const std::vector<dpoint>& parts
);
/*!
ensures
Expand All @@ -39,6 +39,16 @@ namespace dlib
- part(i) == parts[i]
!*/

full_object_detection(
const rectangle& rect_,
const std::vector<point>& parts_
);
/*!
ensures
- #get_rect() == rect
- #num_parts() == parts.size()
!*/

full_object_detection(
);
/*!
Expand Down Expand Up @@ -79,7 +89,7 @@ namespace dlib
- returns the number of parts in this object.
!*/

const point& part(
const dpoint& part(
unsigned long idx
) const;
/*!
Expand All @@ -92,7 +102,7 @@ namespace dlib
This is useful for modeling object parts that are not always observed.
!*/

point& part(
dpoint& part(
unsigned long idx
);
/*!
Expand Down
2 changes: 1 addition & 1 deletion dlib/image_processing/scan_image_pyramid.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ namespace dlib
// convert into feature space.
object_box = object_box.intersect(get_rect(feats[best_level]));

std::vector<point> movable_parts;
std::vector<dpoint> movable_parts;
movable_parts.reserve(get_num_movable_components_per_detection_template());
for (unsigned long i = 0; i < get_num_movable_components_per_detection_template(); ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion dlib/image_transforms/interpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ namespace dlib
const full_object_detection& obj
)
{
std::vector<point> parts;
std::vector<dpoint> parts;
parts.reserve(obj.num_parts());
for (unsigned long i = 0; i < obj.num_parts(); ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion dlib/test/object_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ namespace
std::vector<full_object_detection> temp;

rectangle rect = centered_rect(point(100,100), 70,71);
std::vector<point> movable_parts;
std::vector<dpoint> movable_parts;
movable_parts.push_back(shrink_rect(rect,shrink).tl_corner());
movable_parts.push_back(shrink_rect(rect,shrink).tr_corner());
movable_parts.push_back(shrink_rect(rect,shrink).bl_corner());
Expand Down
Loading