Commit cdc57feccde79e935d2ef78fee2fbd1d9261a169
1 parent
f16ec251
Add ApplyMaskTransform to apply a mask in the template metadata
Showing
1 changed file
with
20 additions
and
0 deletions
openbr/plugins/mask.cpp
| @@ -180,6 +180,26 @@ class LargestConvexAreaTransform : public UntrainableTransform | @@ -180,6 +180,26 @@ class LargestConvexAreaTransform : public UntrainableTransform | ||
| 180 | 180 | ||
| 181 | BR_REGISTER(Transform, LargestConvexAreaTransform) | 181 | BR_REGISTER(Transform, LargestConvexAreaTransform) |
| 182 | 182 | ||
| 183 | +/*! | ||
| 184 | + * \ingroup transforms | ||
| 185 | + * \brief Applies a mask from the metadata. | ||
| 186 | + * \author Austin Blanton \cite imaus10 | ||
| 187 | + */ | ||
| 188 | +class ApplyMaskTransform : public UntrainableTransform | ||
| 189 | +{ | ||
| 190 | + Q_OBJECT | ||
| 191 | + | ||
| 192 | + void project(const Template &src, Template &dst) const | ||
| 193 | + { | ||
| 194 | + if (src.file.contains("Mask")) | ||
| 195 | + src.m().copyTo(dst, src.file.get<Mat>("Mask")); | ||
| 196 | + else | ||
| 197 | + dst = src; | ||
| 198 | + } | ||
| 199 | +}; | ||
| 200 | + | ||
| 201 | +BR_REGISTER(Transform, ApplyMaskTransform) | ||
| 202 | + | ||
| 183 | } // namespace br | 203 | } // namespace br |
| 184 | 204 | ||
| 185 | #include "mask.moc" | 205 | #include "mask.moc" |