From 9d0e789a5535a6260aef70959672dd22e5e04894 Mon Sep 17 00:00:00 2001 From: Brendan Klare Date: Fri, 27 Feb 2015 18:12:03 -0500 Subject: [PATCH] Initial transform --- openbr/plugins/imgproc/threshold.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/imgproc/threshold.cpp b/openbr/plugins/imgproc/threshold.cpp index 1e4f53f..c7a6dfd 100644 --- a/openbr/plugins/imgproc/threshold.cpp +++ b/openbr/plugins/imgproc/threshold.cpp @@ -48,6 +48,45 @@ private: BR_REGISTER(Transform, ThresholdTransform) +class CropFromMaskTransform : public UntrainableTransform +{ + Q_OBJECT + +private: + + void project(const Template &src, Template &dst) const + { + dst = src; + + Mat mask = dst.file.get("Mask"); + + int w = mask.rows; + int h = mask.cols; + int left = w; + int right = 0; + int top = h; + int bottom = 0; + for (int i = 0 ; i < w; i++) { + for (int j = 0 ; j < h; j++) { + if (mask.at(i,j)) { + if (i < left) + left = i; + if (i > right) + right = i; + if (j < top) + top = j; + if (j > bottom) + bottom = j; + } + } + } +qDebug() << left << right << top << bottom; + + } +}; + +BR_REGISTER(Transform, CropFromMaskTransform) + } // namespace br #include "imgproc/threshold.moc" -- libgit2 0.21.4