diff --git a/src/openalpr/prewarp.cpp b/src/openalpr/prewarp.cpp index 0ec9108..5465d08 100644 --- a/src/openalpr/prewarp.cpp +++ b/src/openalpr/prewarp.cpp @@ -183,21 +183,26 @@ namespace alpr for (unsigned int i = 0; i < rects.size(); i++) { + Rect r = projectRect(rects[i], maxWidth, maxHeight, inverse); + projected_rects.push_back(r); + } + + return projected_rects; + } + + Rect PreWarp::projectRect(Rect rect, int maxWidth, int maxHeight, bool inverse) { vector points; - points.push_back(Point(rects[i].x, rects[i].y)); - points.push_back(Point(rects[i].x + rects[i].width, rects[i].y)); - points.push_back(Point(rects[i].x + rects[i].width, rects[i].y + rects[i].height)); - points.push_back(Point(rects[i].x, rects[i].y + rects[i].height)); + points.push_back(Point(rect.x, rect.y)); + points.push_back(Point(rect.x + rect.width, rect.y)); + points.push_back(Point(rect.x + rect.width, rect.y + rect.height)); + points.push_back(Point(rect.x, rect.y + rect.height)); vector projectedPoints = projectPoints(points, inverse); Rect projectedRect = boundingRect(projectedPoints); projectedRect = expandRect(projectedRect, 0, 0, maxWidth, maxHeight); - projected_rects.push_back(projectedRect); - } - - return projected_rects; + return projectedRect; } vector PreWarp::projectPoints(vector points, bool inverse) { diff --git a/src/openalpr/prewarp.h b/src/openalpr/prewarp.h index 439a5f7..4539c5c 100644 --- a/src/openalpr/prewarp.h +++ b/src/openalpr/prewarp.h @@ -40,6 +40,7 @@ namespace alpr cv::Mat warpImage(cv::Mat image); std::vector projectPoints(std::vector points, bool inverse); std::vector projectRects(std::vector rects, int maxWidth, int maxHeight, bool inverse); + cv::Rect projectRect(cv::Rect rect, int maxWidth, int maxHeight, bool inverse); void projectPlateRegions(std::vector& plateRegions, int maxWidth, int maxHeight, bool inverse); void setTransform(float w, float h, float rotationx, float rotationy, float rotationz, float panX, float panY, float stretchX, float dist);