Commit 10356e39 authored by Davis King's avatar Davis King

Added functions to easily add full_object_detections to the overlay

of an image_window.
parent 64e26c7a
......@@ -3587,6 +3587,79 @@ namespace dlib
add_overlay(temp);
}
void add_overlay(
const full_object_detection& object,
const std::vector<std::string>& part_names
)
{
add_overlay(overlay_rect(object.get_rect(), rgb_pixel(255,0,0)));
std::vector<overlay_circle> temp;
temp.reserve(object.num_parts());
for (unsigned long i = 0; i < object.num_parts(); ++i)
{
if (object.part(i) != OBJECT_PART_NOT_PRESENT)
{
if (i < part_names.size())
temp.push_back(overlay_circle(object.part(i), 7, rgb_pixel(0,255,0), part_names[i]));
else
temp.push_back(overlay_circle(object.part(i), 7, rgb_pixel(0,255,0)));
}
}
add_overlay(temp);
}
void add_overlay(
const full_object_detection& object
)
{
std::vector<std::string> part_names;
add_overlay(object, part_names);
}
void add_overlay(
const std::vector<full_object_detection>& objects,
const std::vector<std::string>& part_names
)
{
std::vector<overlay_rect> rtemp;
rtemp.reserve(objects.size());
for (unsigned long i = 0; i < objects.size(); ++i)
{
rtemp.push_back(overlay_rect(objects[i].get_rect(), rgb_pixel(255,0,0)));
}
add_overlay(rtemp);
std::vector<overlay_circle> temp;
for (unsigned long i = 0; i < objects.size(); ++i)
{
for (unsigned long j = 0; j < objects[i].num_parts(); ++j)
{
if (objects[i].part(j) != OBJECT_PART_NOT_PRESENT)
{
if (j < part_names.size())
temp.push_back(overlay_circle(objects[i].part(j), 7, rgb_pixel(0,255,0),part_names[j]));
else
temp.push_back(overlay_circle(objects[i].part(j), 7, rgb_pixel(0,255,0)));
}
}
}
add_overlay(temp);
}
void add_overlay(
const std::vector<full_object_detection>& objects
)
{
std::vector<std::string> part_names;
add_overlay(objects, part_names);
}
void add_overlay (
const overlay_line& overlay
);
......
......@@ -13,6 +13,7 @@
#include <map>
#include "../interfaces/enumerable.h"
#include "style_abstract.h"
#include "../image_processing/full_object_detection_abstract.h"
namespace dlib
{
......@@ -2856,6 +2857,51 @@ namespace dlib
that they will be displayed with the color specific by p.
!*/
void add_overlay(
const full_object_detection& object,
const std::vector<std::string>& part_names
);
/*!
ensures
- adds the given full_object_detection to the overlays
and shows it on the screen. This includes any of its
parts that are not set equal to OBJECT_PART_NOT_PRESENT.
- for all valid i < part_names.size():
- the part object.part(i) will be labeled with the string
part_names[i].
!*/
void add_overlay(
const full_object_detection& object
);
/*!
ensures
- adds the given full_object_detection to the overlays
and shows it on the screen. This includes any of its
parts that are not set equal to OBJECT_PART_NOT_PRESENT.
!*/
void add_overlay(
const std::vector<full_object_detection>& objects,
const std::vector<std::string>& part_names
);
/*!
ensures
- calling this function is equivalent to calling the following
sequence of functions, for all valid i:
- add_overlay(objects[i], part_names);
!*/
void add_overlay(
const std::vector<full_object_detection>& objects
);
/*!
ensures
- calling this function is equivalent to calling the following
sequence of functions, for all valid i:
- add_overlay(objects[i]);
!*/
void add_overlay (
const overlay_line& overlay
);
......
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