Commit 14ce2fa69715e53160a39626001a0b81a2c1bf8c
Merge pull request #316 from biometrics/blurTransform
Blur regions of interest
Showing
2 changed files
with
15 additions
and
2 deletions
openbr/plugins/filter.cpp
| @@ -61,11 +61,23 @@ class BlurTransform : public UntrainableTransform | @@ -61,11 +61,23 @@ class BlurTransform : public UntrainableTransform | ||
| 61 | { | 61 | { |
| 62 | Q_OBJECT | 62 | Q_OBJECT |
| 63 | Q_PROPERTY(float sigma READ get_sigma WRITE set_sigma RESET reset_sigma STORED false) | 63 | Q_PROPERTY(float sigma READ get_sigma WRITE set_sigma RESET reset_sigma STORED false) |
| 64 | + Q_PROPERTY(bool ROI READ get_ROI WRITE set_ROI RESET reset_ROI STORED false) | ||
| 64 | BR_PROPERTY(float, sigma, 1) | 65 | BR_PROPERTY(float, sigma, 1) |
| 66 | + BR_PROPERTY(bool, ROI, false) | ||
| 65 | 67 | ||
| 66 | void project(const Template &src, Template &dst) const | 68 | void project(const Template &src, Template &dst) const |
| 67 | { | 69 | { |
| 68 | - GaussianBlur(src, dst, Size(0,0), sigma); | 70 | + if (!ROI) GaussianBlur(src, dst, Size(0,0), sigma); |
| 71 | + else { | ||
| 72 | + dst.m() = src.m(); | ||
| 73 | + foreach (const QRectF &rect, src.file.rects()) { | ||
| 74 | + Rect region(rect.x(), rect.y(), rect.width(), rect.height()); | ||
| 75 | + Mat input = dst.m(); | ||
| 76 | + Mat output = input.clone(); | ||
| 77 | + GaussianBlur(input(region), output(region), Size(0,0), sigma); | ||
| 78 | + dst.m() = output; | ||
| 79 | + } | ||
| 80 | + } | ||
| 69 | } | 81 | } |
| 70 | }; | 82 | }; |
| 71 | 83 |
openbr/plugins/gui.cpp
| @@ -764,7 +764,8 @@ public: | @@ -764,7 +764,8 @@ public: | ||
| 764 | } | 764 | } |
| 765 | else | 765 | else |
| 766 | { | 766 | { |
| 767 | - dst[i].file.set(labelSet[idx], rectSet[idx]); | 767 | + if (labels.isEmpty()) dst[i].file.appendRect(rectSet[idx]); |
| 768 | + else dst[i].file.set(labelSet[idx], rectSet[idx]); | ||
| 768 | } | 769 | } |
| 769 | } | 770 | } |
| 770 | } | 771 | } |