Commit f54e33c13a4ad363c44930bda45d502150416825
1 parent
0f880500
Added border property
Showing
1 changed file
with
6 additions
and
4 deletions
openbr/plugins/metadata/grid.cpp
| @@ -29,16 +29,18 @@ class GridTransform : public UntrainableTransform | @@ -29,16 +29,18 @@ class GridTransform : public UntrainableTransform | ||
| 29 | Q_OBJECT | 29 | Q_OBJECT |
| 30 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) | 30 | Q_PROPERTY(int rows READ get_rows WRITE set_rows RESET reset_rows STORED false) |
| 31 | Q_PROPERTY(int columns READ get_columns WRITE set_columns RESET reset_columns STORED false) | 31 | Q_PROPERTY(int columns READ get_columns WRITE set_columns RESET reset_columns STORED false) |
| 32 | + Q_PROPERTY(float border READ get_border WRITE set_border RESET reset_border STORED false) | ||
| 32 | BR_PROPERTY(int, rows, 1) | 33 | BR_PROPERTY(int, rows, 1) |
| 33 | BR_PROPERTY(int, columns, 1) | 34 | BR_PROPERTY(int, columns, 1) |
| 35 | + BR_PROPERTY(float, border, 0) | ||
| 34 | 36 | ||
| 35 | void project(const Template &src, Template &dst) const | 37 | void project(const Template &src, Template &dst) const |
| 36 | { | 38 | { |
| 37 | QList<QPointF> landmarks; | 39 | QList<QPointF> landmarks; |
| 38 | - const float row_step = 1.f * src.m().rows / rows; | ||
| 39 | - const float column_step = 1.f * src.m().cols / columns; | ||
| 40 | - for (float y=row_step/2; y<src.m().rows; y+=row_step) | ||
| 41 | - for (float x=column_step/2; x<src.m().cols; x+=column_step) | 40 | + const float row_step = (src.m().rows-src.m().rows*border*2) / rows; |
| 41 | + const float column_step = (src.m().cols-src.m().cols*border*2) / columns; | ||
| 42 | + for (float y=row_step/2+src.m().rows*border; y<src.m().rows-src.m().rows*border; y+=row_step) | ||
| 43 | + for (float x=column_step/2+src.m().cols*border; x<src.m().cols-src.m().cols*border; x+=column_step) | ||
| 42 | landmarks.append(QPointF(x,y)); | 44 | landmarks.append(QPointF(x,y)); |
| 43 | dst = src; | 45 | dst = src; |
| 44 | dst.file.setPoints(landmarks); | 46 | dst.file.setPoints(landmarks); |