Commit 54801baca32b28c0fdc2d2abeda453d627f1ef3f
1 parent
782b5bcf
added crop transform
Showing
1 changed file
with
25 additions
and
0 deletions
openbr/plugins/crop.cpp
| @@ -26,6 +26,31 @@ namespace br | @@ -26,6 +26,31 @@ namespace br | ||
| 26 | 26 | ||
| 27 | /*! | 27 | /*! |
| 28 | * \ingroup transforms | 28 | * \ingroup transforms |
| 29 | + * \brief Crops about the specified region of interest. | ||
| 30 | + * \author Josh Klontz \cite jklontz | ||
| 31 | + */ | ||
| 32 | +class CropTransform : public UntrainableTransform | ||
| 33 | +{ | ||
| 34 | + Q_OBJECT | ||
| 35 | + Q_PROPERTY(int x READ get_x WRITE set_x RESET reset_x STORED false) | ||
| 36 | + Q_PROPERTY(int y READ get_y WRITE set_y RESET reset_y STORED false) | ||
| 37 | + Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) | ||
| 38 | + Q_PROPERTY(int height READ get_height WRITE set_height RESET reset_height STORED false) | ||
| 39 | + BR_PROPERTY(int, x, 0) | ||
| 40 | + BR_PROPERTY(int, y, 0) | ||
| 41 | + BR_PROPERTY(int, width, -1) | ||
| 42 | + BR_PROPERTY(int, height, -1) | ||
| 43 | + | ||
| 44 | + void project(const Template &src, Template &dst) const | ||
| 45 | + { | ||
| 46 | + dst = Mat(src, Rect(x, y, width < 1 ? src.m().cols-x-abs(width) : width, height < 1 ? src.m().rows-y-abs(height) : height)); | ||
| 47 | + } | ||
| 48 | +}; | ||
| 49 | + | ||
| 50 | +BR_REGISTER(Transform, CropTransform) | ||
| 51 | + | ||
| 52 | +/*! | ||
| 53 | + * \ingroup transforms | ||
| 29 | * \brief Crops the rectangular regions of interest. | 54 | * \brief Crops the rectangular regions of interest. |
| 30 | * \author Josh Klontz \cite jklontz | 55 | * \author Josh Klontz \cite jklontz |
| 31 | */ | 56 | */ |