From a8499e3d0d81bc7631deb8d7b0a119485b61f324 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 8 May 2015 07:43:21 -0400 Subject: [PATCH] Ensure detection rectangle is always within image frame bounds --- src/openalpr/detection/detectorcpu.cpp | 3 +++ src/openalpr/detection/detectorcuda.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/openalpr/detection/detectorcpu.cpp b/src/openalpr/detection/detectorcpu.cpp index ae6e794..40413c7 100644 --- a/src/openalpr/detection/detectorcpu.cpp +++ b/src/openalpr/detection/detectorcpu.cpp @@ -115,6 +115,9 @@ namespace alpr plates[i].y = (plates[i].y / scale_factor) + offset_y; plates[i].width = plates[i].width / 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 orderedRegions = aggregateRegions(plates); diff --git a/src/openalpr/detection/detectorcuda.cpp b/src/openalpr/detection/detectorcuda.cpp index 83d4628..1fd42db 100644 --- a/src/openalpr/detection/detectorcuda.cpp +++ b/src/openalpr/detection/detectorcuda.cpp @@ -125,6 +125,9 @@ namespace alpr plates[i].y = (plates[i].y / scale_factor) + offset_y; plates[i].width = plates[i].width / 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 orderedRegions = aggregateRegions(plates);