Commit 3f40433ab6c9b8275d1eca8a504bc035fba30ea7
1 parent
e3b533a3
Fixed boundary condition of RectFromPoints
Showing
1 changed file
with
5 additions
and
2 deletions
openbr/plugins/regions.cpp
| ... | ... | @@ -345,9 +345,12 @@ class RectFromPointsTransform : public UntrainableTransform |
| 345 | 345 | |
| 346 | 346 | dst.file.setPoints(points); |
| 347 | 347 | |
| 348 | - if (crop) dst.m() = src.m()(Rect(std::max(0.0, minX - deltaWidth/2.0), std::max(0.0, minY - deltaHeight/2.0), std::min((double)src.m().cols, width), std::min((double)src.m().rows, height))); | |
| 348 | + const int x = std::max(0.0, minX - deltaWidth/2.0); | |
| 349 | + const int y = std::max(0.0, minY - deltaHeight/2.0); | |
| 350 | + | |
| 351 | + if (crop) dst.m() = src.m()(Rect(x, y, std::min((double)src.m().cols-x, width), std::min((double)src.m().rows-y, height))); | |
| 349 | 352 | else { |
| 350 | - dst.file.appendRect(QRectF(std::max(0.0, minX - deltaWidth/2.0), std::max(0.0, minY - deltaHeight/2.0), std::min((double)src.m().cols, width), std::min((double)src.m().rows, height))); | |
| 353 | + dst.file.appendRect(QRectF(x, y, std::min((double)src.m().cols-x, width), std::min((double)src.m().rows-y, height))); | |
| 351 | 354 | dst.m() = src.m(); |
| 352 | 355 | } |
| 353 | 356 | } | ... | ... |