Commit 8d42878071184d4ff1d379fb63398ffe30b6d2fd

Authored by Austin Van Blanton
1 parent e9c9e036

Add ROIFromPtsTransform

Showing 1 changed file with 25 additions and 0 deletions
openbr/plugins/crop.cpp
@@ -69,6 +69,31 @@ BR_REGISTER(Transform, ROITransform) @@ -69,6 +69,31 @@ BR_REGISTER(Transform, ROITransform)
69 69
70 /*! 70 /*!
71 * \ingroup transforms 71 * \ingroup transforms
  72 + * \brief Crops the rectangular regions of interest from given points and sizes.
  73 + * \author Austin Blanton \cite imaus10
  74 + */
  75 +class ROIFromPtsTransform : public UntrainableTransform
  76 +{
  77 + Q_OBJECT
  78 + Q_PROPERTY(int width READ get_width WRITE set_width RESET reset_width STORED false)
  79 + Q_PROPERTY(int height READ get_height WRITE set_height RESET reset_height STORED false)
  80 + BR_PROPERTY(int, width, 1)
  81 + BR_PROPERTY(int, height, 1)
  82 +
  83 + void project(const Template &src, Template &dst) const
  84 + {
  85 + foreach (const QPointF &pt, src.file.points()) {
  86 + int x = pt.x() - (width/2);
  87 + int y = pt.y() - (height/2);
  88 + dst += src.m()(Rect(x, y, width, height));
  89 + }
  90 + }
  91 +};
  92 +
  93 +BR_REGISTER(Transform, ROIFromPtsTransform)
  94 +
  95 +/*!
  96 + * \ingroup transforms
72 * \brief Resize the template 97 * \brief Resize the template
73 * \author Josh Klontz \cite jklontz 98 * \author Josh Klontz \cite jklontz
74 * \note Method: Area should be used for shrinking an image, Cubic for slow but accurate enlargment, Bilin for fast enlargement. 99 * \note Method: Area should be used for shrinking an image, Cubic for slow but accurate enlargment, Bilin for fast enlargement.