From 7dc085df703a27655d20786c80b4989f06230342 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 28 Mar 2015 13:11:40 -0400 Subject: [PATCH] Reusing expandRect function to verify bounds of rectangle --- src/openalpr/detection/detectormorph.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/openalpr/detection/detectormorph.cpp b/src/openalpr/detection/detectormorph.cpp index 0d6e81e..5582d23 100644 --- a/src/openalpr/detection/detectormorph.cpp +++ b/src/openalpr/detection/detectormorph.cpp @@ -191,16 +191,9 @@ for (int i = 0; i < rects.size(); i++) { PlateRegion PlateReg; - PlateReg.rect = PlateRect.boundingRect(); - - if (PlateReg.rect.x < 0) - PlateReg.rect.x = 0; - if (PlateReg.rect.y < 0) - PlateReg.rect.y = 0; - if (PlateReg.rect.x + PlateReg.rect.width > frame.cols) - PlateReg.rect.width = frame.cols - PlateReg.rect.x; - if (PlateReg.rect.y + PlateReg.rect.height > frame.rows) - PlateReg.rect.height = frame.rows - PlateReg.rect.y; + // Ensure that the rectangle isn't < 0 or > maxWidth/Height + Rect bounding_rect = PlateRect.boundingRect(); + PlateReg.rect = expandRect(bounding_rect, 0, 0, frame.cols, frame.rows); detectedRegions.push_back(PlateReg);