Reusing expandRect function to verify bounds of rectangle

This commit is contained in:
Matt Hill
2015-03-28 13:11:40 -04:00
parent de952119c5
commit 7dc085df70

View File

@@ -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);