From 3f40433ab6c9b8275d1eca8a504bc035fba30ea7 Mon Sep 17 00:00:00 2001 From: sklum Date: Tue, 22 Oct 2013 16:17:47 -0700 Subject: [PATCH] Fixed boundary condition of RectFromPoints --- openbr/plugins/regions.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openbr/plugins/regions.cpp b/openbr/plugins/regions.cpp index 317eb54..9e9e92a 100644 --- a/openbr/plugins/regions.cpp +++ b/openbr/plugins/regions.cpp @@ -345,9 +345,12 @@ class RectFromPointsTransform : public UntrainableTransform dst.file.setPoints(points); - 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))); + const int x = std::max(0.0, minX - deltaWidth/2.0); + const int y = std::max(0.0, minY - deltaHeight/2.0); + + 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))); else { - 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))); + dst.file.appendRect(QRectF(x, y, std::min((double)src.m().cols-x, width), std::min((double)src.m().rows-y, height))); dst.m() = src.m(); } } -- libgit2 0.21.4