From 3c8183a942e30f54f2a707baceb1358006342d74 Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Thu, 3 Apr 2014 17:50:38 -0400 Subject: [PATCH] Added boundingbox transform --- openbr/plugins/regions.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index c6fe0e5..cf53eae 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -292,7 +292,7 @@ BR_REGISTER(Transform, CropRectTransform) /*! * \ingroup transforms - * \brief Create matrix from landmarks. + * \brief Create rect from landmarks. * \author Scott Klum \cite sklum * \todo Padding should be a percent of total image size */ @@ -313,7 +313,6 @@ class RectFromPointsTransform : public UntrainableTransform if (src.file.points().isEmpty()) { if (Globals->verbose) qWarning("No landmarks"); - dst = src; return; } @@ -355,6 +354,33 @@ BR_REGISTER(Transform, RectFromPointsTransform) /*! * \ingroup transforms + * \brief Create matrix from landmarks. + * \author Scott Klum \cite sklum + * \todo Padding should be a percent of total image size + */ + +class BoundingBoxTransform : public UntrainableTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + dst = src; + + if (src.file.points().isEmpty()) { + if (Globals->verbose) qFatal("No landmarks"); + return; + } + + Rect boundingBox = boundingRect(OpenCVUtils::toPoints(src.file.points()).toVector().toStdVector()); + dst.file.appendRect(OpenCVUtils::fromRect(boundingBox)); + } +}; + +BR_REGISTER(Transform, BoundingBoxTransform) + +/*! + * \ingroup transforms * \brief Create face bounding box from two eye locations. `widthPadding` specifies * what percentage of the interpupliary distance (ipd) will be padded in both * horizontal directions. The `verticalLocation` specifies where vertically the -- libgit2 0.21.4