Split out projectRect function in prewarp

This commit is contained in:
Matt Hill
2016-03-14 22:28:22 -04:00
parent c1018cb1ad
commit 3096fa0da2
2 changed files with 14 additions and 8 deletions

View File

@@ -183,21 +183,26 @@ namespace alpr
for (unsigned int i = 0; i < rects.size(); i++)
{
Rect r = projectRect(rects[i], maxWidth, maxHeight, inverse);
projected_rects.push_back(r);
}
return projected_rects;
}
Rect PreWarp::projectRect(Rect rect, int maxWidth, int maxHeight, bool inverse) {
vector<Point2f> points;
points.push_back(Point(rects[i].x, rects[i].y));
points.push_back(Point(rects[i].x + rects[i].width, rects[i].y));
points.push_back(Point(rects[i].x + rects[i].width, rects[i].y + rects[i].height));
points.push_back(Point(rects[i].x, rects[i].y + rects[i].height));
points.push_back(Point(rect.x, rect.y));
points.push_back(Point(rect.x + rect.width, rect.y));
points.push_back(Point(rect.x + rect.width, rect.y + rect.height));
points.push_back(Point(rect.x, rect.y + rect.height));
vector<Point2f> projectedPoints = projectPoints(points, inverse);
Rect projectedRect = boundingRect(projectedPoints);
projectedRect = expandRect(projectedRect, 0, 0, maxWidth, maxHeight);
projected_rects.push_back(projectedRect);
}
return projected_rects;
return projectedRect;
}
vector<Point2f> PreWarp::projectPoints(vector<Point2f> points, bool inverse) {

View File

@@ -40,6 +40,7 @@ namespace alpr
cv::Mat warpImage(cv::Mat image);
std::vector<cv::Point2f> projectPoints(std::vector<cv::Point2f> points, bool inverse);
std::vector<cv::Rect> projectRects(std::vector<cv::Rect> rects, int maxWidth, int maxHeight, bool inverse);
cv::Rect projectRect(cv::Rect rect, int maxWidth, int maxHeight, bool inverse);
void projectPlateRegions(std::vector<PlateRegion>& plateRegions, int maxWidth, int maxHeight, bool inverse);
void setTransform(float w, float h, float rotationx, float rotationy, float rotationz, float panX, float panY, float stretchX, float dist);