Ensure detection rectangle is always within image frame bounds

This commit is contained in:
Matt Hill
2015-05-08 07:43:21 -04:00
parent f029713ab8
commit a8499e3d0d
2 changed files with 6 additions and 0 deletions

View File

@@ -115,6 +115,9 @@ namespace alpr
plates[i].y = (plates[i].y / scale_factor) + offset_y; plates[i].y = (plates[i].y / scale_factor) + offset_y;
plates[i].width = plates[i].width / scale_factor; plates[i].width = plates[i].width / scale_factor;
plates[i].height = plates[i].height / scale_factor; plates[i].height = plates[i].height / scale_factor;
// Ensure that the rectangle isn't < 0 or > maxWidth/Height
plates[i] = expandRect(plates[i], 0, 0, frame.cols, frame.rows);
} }
vector<PlateRegion> orderedRegions = aggregateRegions(plates); vector<PlateRegion> orderedRegions = aggregateRegions(plates);

View File

@@ -125,6 +125,9 @@ namespace alpr
plates[i].y = (plates[i].y / scale_factor) + offset_y; plates[i].y = (plates[i].y / scale_factor) + offset_y;
plates[i].width = plates[i].width / scale_factor; plates[i].width = plates[i].width / scale_factor;
plates[i].height = plates[i].height / scale_factor; plates[i].height = plates[i].height / scale_factor;
// Ensure that the rectangle isn't < 0 or > maxWidth/Height
plates[i] = expandRect(plates[i], 0, 0, frame.cols, frame.rows);
} }
vector<PlateRegion> orderedRegions = aggregateRegions(plates); vector<PlateRegion> orderedRegions = aggregateRegions(plates);