Commit 3c8183a942e30f54f2a707baceb1358006342d74
1 parent
95911ac6
Added boundingbox transform
Showing
1 changed file
with
28 additions
and
2 deletions
openbr/plugins/regions.cpp
| @@ -292,7 +292,7 @@ BR_REGISTER(Transform, CropRectTransform) | @@ -292,7 +292,7 @@ BR_REGISTER(Transform, CropRectTransform) | ||
| 292 | 292 | ||
| 293 | /*! | 293 | /*! |
| 294 | * \ingroup transforms | 294 | * \ingroup transforms |
| 295 | - * \brief Create matrix from landmarks. | 295 | + * \brief Create rect from landmarks. |
| 296 | * \author Scott Klum \cite sklum | 296 | * \author Scott Klum \cite sklum |
| 297 | * \todo Padding should be a percent of total image size | 297 | * \todo Padding should be a percent of total image size |
| 298 | */ | 298 | */ |
| @@ -313,7 +313,6 @@ class RectFromPointsTransform : public UntrainableTransform | @@ -313,7 +313,6 @@ class RectFromPointsTransform : public UntrainableTransform | ||
| 313 | 313 | ||
| 314 | if (src.file.points().isEmpty()) { | 314 | if (src.file.points().isEmpty()) { |
| 315 | if (Globals->verbose) qWarning("No landmarks"); | 315 | if (Globals->verbose) qWarning("No landmarks"); |
| 316 | - dst = src; | ||
| 317 | return; | 316 | return; |
| 318 | } | 317 | } |
| 319 | 318 | ||
| @@ -355,6 +354,33 @@ BR_REGISTER(Transform, RectFromPointsTransform) | @@ -355,6 +354,33 @@ BR_REGISTER(Transform, RectFromPointsTransform) | ||
| 355 | 354 | ||
| 356 | /*! | 355 | /*! |
| 357 | * \ingroup transforms | 356 | * \ingroup transforms |
| 357 | + * \brief Create matrix from landmarks. | ||
| 358 | + * \author Scott Klum \cite sklum | ||
| 359 | + * \todo Padding should be a percent of total image size | ||
| 360 | + */ | ||
| 361 | + | ||
| 362 | +class BoundingBoxTransform : public UntrainableTransform | ||
| 363 | +{ | ||
| 364 | + Q_OBJECT | ||
| 365 | + | ||
| 366 | + void project(const Template &src, Template &dst) const | ||
| 367 | + { | ||
| 368 | + dst = src; | ||
| 369 | + | ||
| 370 | + if (src.file.points().isEmpty()) { | ||
| 371 | + if (Globals->verbose) qFatal("No landmarks"); | ||
| 372 | + return; | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + Rect boundingBox = boundingRect(OpenCVUtils::toPoints(src.file.points()).toVector().toStdVector()); | ||
| 376 | + dst.file.appendRect(OpenCVUtils::fromRect(boundingBox)); | ||
| 377 | + } | ||
| 378 | +}; | ||
| 379 | + | ||
| 380 | +BR_REGISTER(Transform, BoundingBoxTransform) | ||
| 381 | + | ||
| 382 | +/*! | ||
| 383 | + * \ingroup transforms | ||
| 358 | * \brief Create face bounding box from two eye locations. `widthPadding` specifies | 384 | * \brief Create face bounding box from two eye locations. `widthPadding` specifies |
| 359 | * what percentage of the interpupliary distance (ipd) will be padded in both | 385 | * what percentage of the interpupliary distance (ipd) will be padded in both |
| 360 | * horizontal directions. The `verticalLocation` specifies where vertically the | 386 | * horizontal directions. The `verticalLocation` specifies where vertically the |