Commit 3c26e2d4f0d2695d67fcb1f3d5b9982c53a30956

Authored by Austin Blanton
1 parent 2ca2ed58

Add option to crop ROI from a metadata field

Showing 1 changed file with 7 additions and 1 deletions
openbr/plugins/crop.cpp
@@ -57,10 +57,16 @@ BR_REGISTER(Transform, CropTransform) @@ -57,10 +57,16 @@ BR_REGISTER(Transform, CropTransform)
57 class ROITransform : public UntrainableTransform 57 class ROITransform : public UntrainableTransform
58 { 58 {
59 Q_OBJECT 59 Q_OBJECT
  60 + Q_PROPERTY(QString propName READ get_propName WRITE set_propName RESET reset_propName STORED false)
  61 + BR_PROPERTY(QString, propName, "")
60 62
61 void project(const Template &src, Template &dst) const 63 void project(const Template &src, Template &dst) const
62 { 64 {
63 - if (src.file.rects().empty()) { 65 + if (!propName.isEmpty()) {
  66 + QRectF rect = src.file.get<QRectF>(propName);
  67 + dst += src.m()(OpenCVUtils::toRect(rect));
  68 + }
  69 + else if (src.file.rects().empty()) {
64 dst = src; 70 dst = src;
65 if (Globals->verbose) qWarning("No rects present in file."); 71 if (Globals->verbose) qWarning("No rects present in file.");
66 } 72 }