Commit c0ab9a13 authored by Davis King's avatar Davis King

Added get_mapping_to_chip()

parent 0438ae5d
......@@ -1457,6 +1457,25 @@ namespace dlib
}
};
// ----------------------------------------------------------------------------------------
inline point_transform_affine get_mapping_to_chip (
const chip_details& details
)
{
std::vector<dlib::vector<double,2> > from, to;
point p1(0,0);
point p2(details.cols-1,0);
point p3(details.cols-1, details.rows-1);
to.push_back(p1);
from.push_back(rotate_point<double>(center(details.rect),details.rect.tl_corner(),details.angle));
to.push_back(p2);
from.push_back(rotate_point<double>(center(details.rect),details.rect.tr_corner(),details.angle));
to.push_back(p3);
from.push_back(rotate_point<double>(center(details.rect),details.rect.br_corner(),details.angle));
return find_similarity_transform(from, to);
}
// ----------------------------------------------------------------------------------------
template <
......@@ -1534,7 +1553,7 @@ namespace dlib
from.push_back(get_rect(chips[i]).tl_corner()); to.push_back(rotate_point<double>(center(rect),rect.tl_corner(),chip_locations[i].angle));
from.push_back(get_rect(chips[i]).tr_corner()); to.push_back(rotate_point<double>(center(rect),rect.tr_corner(),chip_locations[i].angle));
from.push_back(get_rect(chips[i]).bl_corner()); to.push_back(rotate_point<double>(center(rect),rect.bl_corner(),chip_locations[i].angle));
point_transform_affine trns = find_affine_transform(from,to);
point_transform_affine trns = find_similarity_transform(from,to);
// now extract the actual chip
if (level == -1)
......
......@@ -1004,6 +1004,17 @@ namespace dlib
unsigned long cols;
};
// ----------------------------------------------------------------------------------------
point_transform_affine get_mapping_to_chip (
const chip_details& details
);
/*!
ensures
- returns a transformation that maps from the pixels in the original image
to the pixels in the cropped image defined by the given details object.
!*/
// ----------------------------------------------------------------------------------------
template <
......
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