From 5a2e0d6a4d1d4b429a368fd5cf8400ede0d8838d Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 15 May 2018 21:40:13 -0400 Subject: [PATCH] Added centered_rects() --- dlib/geometry/rectangle.h | 15 +++++++++++++++ dlib/geometry/rectangle_abstract.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/dlib/geometry/rectangle.h b/dlib/geometry/rectangle.h index 8be3136cc..ef2541969 100644 --- a/dlib/geometry/rectangle.h +++ b/dlib/geometry/rectangle.h @@ -571,6 +571,21 @@ namespace dlib return centered_rect(p.x(),p.y(),width,height); } +// ---------------------------------------------------------------------------------------- + + inline std::vector centered_rects ( + const std::vector& pts, + unsigned long width, + unsigned long height + ) + { + std::vector tmp; + tmp.reserve(pts.size()); + for (auto& p : pts) + tmp.emplace_back(centered_rect(p, width, height)); + return tmp; + } + // ---------------------------------------------------------------------------------------- inline const rectangle centered_rect ( diff --git a/dlib/geometry/rectangle_abstract.h b/dlib/geometry/rectangle_abstract.h index 823dc6bc8..ca282bcf9 100644 --- a/dlib/geometry/rectangle_abstract.h +++ b/dlib/geometry/rectangle_abstract.h @@ -452,6 +452,20 @@ namespace dlib - R.tl_corner() == point(p.x()-width/2, p.y()-height/2) !*/ +// ---------------------------------------------------------------------------------------- + + inline std::vector centered_rects ( + const std::vector& pts, + unsigned long width, + unsigned long height + ); + /*! + ensures + - returns an array ARR where: + - #ARR.size() == pts.size() + - #ARR[i] == centered_rect(pts[i], width, height) + !*/ + // ---------------------------------------------------------------------------------------- const rectangle centered_rect (