Fixed issue where detected region has a negative width/height

This commit is contained in:
Matt Hill
2015-05-15 05:37:10 -04:00
parent 00a00df05e
commit f66a1dfd56
5 changed files with 13 additions and 6 deletions

View File

@@ -35,6 +35,7 @@ set(lpr_source_files
textdetection/linefinder.cpp
pipeline_data.cpp
cjson.c
motiondetector.cpp
)

View File

@@ -111,13 +111,16 @@ namespace alpr
for( unsigned int i = 0; i < plates.size(); i++ )
{
plates[i].x = (plates[i].x / scale_factor) + offset_x;
plates[i].y = (plates[i].y / scale_factor) + offset_y;
plates[i].x = (plates[i].x / scale_factor);
plates[i].y = (plates[i].y / scale_factor);
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);
plates[i] = expandRect(plates[i], 0, 0, w, h);
plates[i].x = plates[i].x + offset_x;
plates[i].y = plates[i].y + offset_y;
}
vector<PlateRegion> orderedRegions = aggregateRegions(plates);

View File

@@ -121,13 +121,16 @@ namespace alpr
for( unsigned int i = 0; i < plates.size(); i++ )
{
plates[i].x = (plates[i].x / scale_factor) + offset_x;
plates[i].y = (plates[i].y / scale_factor) + offset_y;
plates[i].x = (plates[i].x / scale_factor);
plates[i].y = (plates[i].y / scale_factor);
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);
plates[i] = expandRect(plates[i], 0, 0, w, h);
plates[i].x = plates[i].x + offset_x;
plates[i].y = plates[i].y + offset_y;
}
vector<PlateRegion> orderedRegions = aggregateRegions(plates);