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