Commit 6553e4abbcc158cff0588be2db5fdcf7633e2090
Merge branch 'attributes' of https://github.com/biometrics/openbr into attributes
Showing
1 changed file
with
28 additions
and
2 deletions
openbr/plugins/regions.cpp
| ... | ... | @@ -292,7 +292,7 @@ BR_REGISTER(Transform, CropRectTransform) |
| 292 | 292 | |
| 293 | 293 | /*! |
| 294 | 294 | * \ingroup transforms |
| 295 | - * \brief Create matrix from landmarks. | |
| 295 | + * \brief Create rect from landmarks. | |
| 296 | 296 | * \author Scott Klum \cite sklum |
| 297 | 297 | * \todo Padding should be a percent of total image size |
| 298 | 298 | */ |
| ... | ... | @@ -313,7 +313,6 @@ class RectFromPointsTransform : public UntrainableTransform |
| 313 | 313 | |
| 314 | 314 | if (src.file.points().isEmpty()) { |
| 315 | 315 | if (Globals->verbose) qWarning("No landmarks"); |
| 316 | - dst = src; | |
| 317 | 316 | return; |
| 318 | 317 | } |
| 319 | 318 | |
| ... | ... | @@ -355,6 +354,33 @@ BR_REGISTER(Transform, RectFromPointsTransform) |
| 355 | 354 | |
| 356 | 355 | /*! |
| 357 | 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 | 384 | * \brief Create face bounding box from two eye locations. `widthPadding` specifies |
| 359 | 385 | * what percentage of the interpupliary distance (ipd) will be padded in both |
| 360 | 386 | * horizontal directions. The `verticalLocation` specifies where vertically the | ... | ... |