diff --git a/openbr/plugins/crop.cpp b/openbr/plugins/crop.cpp index 5c3c548..30a75ea 100644 --- a/openbr/plugins/crop.cpp +++ b/openbr/plugins/crop.cpp @@ -69,6 +69,31 @@ BR_REGISTER(Transform, ROITransform) /*! * \ingroup transforms + * \brief Crops the rectangular regions of interest from given points and sizes. + * \author Austin Blanton \cite imaus10 + */ +class ROIFromPtsTransform : public UntrainableTransform +{ + Q_OBJECT + Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false) + Q_PROPERTY(int height READ get_height WRITE set_height RESET reset_height STORED false) + BR_PROPERTY(int, width, 1) + BR_PROPERTY(int, height, 1) + + void project(const Template &src, Template &dst) const + { + foreach (const QPointF &pt, src.file.points()) { + int x = pt.x() - (width/2); + int y = pt.y() - (height/2); + dst += src.m()(Rect(x, y, width, height)); + } + } +}; + +BR_REGISTER(Transform, ROIFromPtsTransform) + +/*! + * \ingroup transforms * \brief Resize the template * \author Josh Klontz \cite jklontz * \note Method: Area should be used for shrinking an image, Cubic for slow but accurate enlargment, Bilin for fast enlargement.