From cdc57feccde79e935d2ef78fee2fbd1d9261a169 Mon Sep 17 00:00:00 2001 From: Austin Van Blanton Date: Wed, 14 Aug 2013 15:07:12 -0400 Subject: [PATCH] Add ApplyMaskTransform to apply a mask in the template metadata --- openbr/plugins/mask.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+), 0 deletions(-) diff --git a/openbr/plugins/mask.cpp b/openbr/plugins/mask.cpp index 81fa8fb..3019934 100644 --- a/openbr/plugins/mask.cpp +++ b/openbr/plugins/mask.cpp @@ -180,6 +180,26 @@ class LargestConvexAreaTransform : public UntrainableTransform BR_REGISTER(Transform, LargestConvexAreaTransform) +/*! + * \ingroup transforms + * \brief Applies a mask from the metadata. + * \author Austin Blanton \cite imaus10 + */ +class ApplyMaskTransform : public UntrainableTransform +{ + Q_OBJECT + + void project(const Template &src, Template &dst) const + { + if (src.file.contains("Mask")) + src.m().copyTo(dst, src.file.get("Mask")); + else + dst = src; + } +}; + +BR_REGISTER(Transform, ApplyMaskTransform) + } // namespace br #include "mask.moc" -- libgit2 0.21.4