mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 01:12:47 +08:00
Replaced "uint" (platform specific) with "unsigned int" (universal)
This commit is contained in:
@@ -60,7 +60,7 @@ namespace alpr
|
||||
|
||||
pipeline_data->textLines.clear();
|
||||
|
||||
for (uint i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
{
|
||||
TextContours tc(pipeline_data->thresholds[i]);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace alpr
|
||||
|
||||
getTime(&startTime);
|
||||
|
||||
for (uint i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
{
|
||||
this->filter(pipeline_data->thresholds[i], allTextContours[i]);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace alpr
|
||||
if (plateMask.hasPlateMask)
|
||||
{
|
||||
// Filter out bad contours now that we have an outer box mask...
|
||||
for (uint i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
{
|
||||
filterByOuterMask(allTextContours[i]);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace alpr
|
||||
|
||||
int bestFitScore = -1;
|
||||
int bestFitIndex = -1;
|
||||
for (uint i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++)
|
||||
{
|
||||
|
||||
int segmentCount = allTextContours[i].getGoodIndicesCount();
|
||||
@@ -142,7 +142,7 @@ namespace alpr
|
||||
vector<vector<Point> > linePolygons = lf.findLines(pipeline_data->crop_gray, bestContours);
|
||||
|
||||
vector<TextLine> tempTextLines;
|
||||
for (uint i = 0; i < linePolygons.size(); i++)
|
||||
for (unsigned int i = 0; i < linePolygons.size(); i++)
|
||||
{
|
||||
vector<Point> linePolygon = linePolygons[i];
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace alpr
|
||||
std::sort(tempTextLines.begin(), tempTextLines.end(), sort_text_line);
|
||||
|
||||
// Now that we've filtered a few more contours, re-do the text area.
|
||||
for (uint i = 0; i < tempTextLines.size(); i++)
|
||||
for (unsigned int i = 0; i < tempTextLines.size(); i++)
|
||||
{
|
||||
vector<Point> updatedTextArea = getCharArea(tempTextLines[i].topLine, tempTextLines[i].bottomLine);
|
||||
vector<Point> linePolygon = tempTextLines[i].linePolygon;
|
||||
@@ -214,7 +214,7 @@ namespace alpr
|
||||
if (this->pipeline_data->config->debugCharAnalysis && pipeline_data->textLines.size() > 0)
|
||||
{
|
||||
vector<Mat> tempDash;
|
||||
for (uint z = 0; z < pipeline_data->thresholds.size(); z++)
|
||||
for (unsigned int z = 0; z < pipeline_data->thresholds.size(); z++)
|
||||
{
|
||||
Mat tmp(pipeline_data->thresholds[z].size(), pipeline_data->thresholds[z].type());
|
||||
pipeline_data->thresholds[z].copyTo(tmp);
|
||||
@@ -227,7 +227,7 @@ namespace alpr
|
||||
this->bestThreshold.copyTo(bestVal);
|
||||
cvtColor(bestVal, bestVal, CV_GRAY2BGR);
|
||||
|
||||
for (uint z = 0; z < this->bestContours.size(); z++)
|
||||
for (unsigned int z = 0; z < this->bestContours.size(); z++)
|
||||
{
|
||||
Scalar dcolor(255,0,0);
|
||||
if (this->bestContours.goodIndices[z])
|
||||
@@ -246,7 +246,7 @@ namespace alpr
|
||||
{
|
||||
Mat charMask = Mat::zeros(bestThreshold.size(), CV_8U);
|
||||
|
||||
for (uint i = 0; i < bestContours.size(); i++)
|
||||
for (unsigned int i = 0; i < bestContours.size(); i++)
|
||||
{
|
||||
if (bestContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -281,7 +281,7 @@ namespace alpr
|
||||
{
|
||||
|
||||
//vector<bool> goodIndices(contours.size());
|
||||
for (uint z = 0; z < textContours.size(); z++) textContours.goodIndices[z] = true;
|
||||
for (unsigned int z = 0; z < textContours.size(); z++) textContours.goodIndices[z] = true;
|
||||
|
||||
this->filterByBoxSize(textContours, STARTING_MIN_HEIGHT + (i * HEIGHT_STEP), STARTING_MAX_HEIGHT + (i * HEIGHT_STEP));
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace alpr
|
||||
float aspecttolerance=0.25;
|
||||
|
||||
|
||||
for (uint i = 0; i < textContours.size(); i++)
|
||||
for (unsigned int i = 0; i < textContours.size(); i++)
|
||||
{
|
||||
if (textContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -344,7 +344,7 @@ namespace alpr
|
||||
void CharacterAnalysis::filterContourHoles(TextContours& textContours)
|
||||
{
|
||||
|
||||
for (uint i = 0; i < textContours.size(); i++)
|
||||
for (unsigned int i = 0; i < textContours.size(); i++)
|
||||
{
|
||||
if (textContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -377,7 +377,7 @@ namespace alpr
|
||||
vector<int> parentIDs;
|
||||
vector<int> votes;
|
||||
|
||||
for (uint i = 0; i < textContours.size(); i++)
|
||||
for (unsigned int i = 0; i < textContours.size(); i++)
|
||||
{
|
||||
if (textContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -387,7 +387,7 @@ namespace alpr
|
||||
int voteIndex = -1;
|
||||
int parentID = textContours.hierarchy[i][3];
|
||||
// check if parentID is already in the lsit
|
||||
for (uint j = 0; j < parentIDs.size(); j++)
|
||||
for (unsigned int j = 0; j < parentIDs.size(); j++)
|
||||
{
|
||||
if (parentIDs[j] == parentID)
|
||||
{
|
||||
@@ -410,7 +410,7 @@ namespace alpr
|
||||
int totalVotes = 0;
|
||||
int winningParentId = 0;
|
||||
int highestVotes = 0;
|
||||
for (uint i = 0; i < parentIDs.size(); i++)
|
||||
for (unsigned int i = 0; i < parentIDs.size(); i++)
|
||||
{
|
||||
if (votes[i] > highestVotes)
|
||||
{
|
||||
@@ -421,7 +421,7 @@ namespace alpr
|
||||
}
|
||||
|
||||
// Now filter out all the contours with a different parent ID (assuming the totalVotes > 2)
|
||||
for (uint i = 0; i < textContours.size(); i++)
|
||||
for (unsigned int i = 0; i < textContours.size(); i++)
|
||||
{
|
||||
if (textContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -452,11 +452,11 @@ namespace alpr
|
||||
// Create a white mask for the area inside the polygon
|
||||
Mat outerMask = Mat::zeros(img.size(), CV_8U);
|
||||
|
||||
for (uint i = 0; i < textLines.size(); i++)
|
||||
for (unsigned int i = 0; i < textLines.size(); i++)
|
||||
fillConvexPoly(outerMask, textLines[i].linePolygon.data(), textLines[i].linePolygon.size(), Scalar(255,255,255));
|
||||
|
||||
// For each contour, determine if enough of it is between the lines to qualify
|
||||
for (uint i = 0; i < textContours.size(); i++)
|
||||
for (unsigned int i = 0; i < textContours.size(); i++)
|
||||
{
|
||||
if (textContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -490,7 +490,7 @@ namespace alpr
|
||||
|
||||
// Get the absolute distance from the top and bottom lines
|
||||
|
||||
for (uint i = 0; i < textLines.size(); i++)
|
||||
for (unsigned int i = 0; i < textLines.size(); i++)
|
||||
{
|
||||
Point closestTopPoint = textLines[i].topLine.closestPointOnSegmentTo(topMiddle);
|
||||
Point closestBottomPoint = textLines[i].bottomLine.closestPointOnSegmentTo(botMiddle);
|
||||
@@ -535,10 +535,10 @@ namespace alpr
|
||||
int totalChars = 0;
|
||||
|
||||
vector<bool> originalindices;
|
||||
for (uint i = 0; i < textContours.size(); i++)
|
||||
for (unsigned int i = 0; i < textContours.size(); i++)
|
||||
originalindices.push_back(textContours.goodIndices[i]);
|
||||
|
||||
for (uint i=0; i < textContours.size(); i++)
|
||||
for (unsigned int i=0; i < textContours.size(); i++)
|
||||
{
|
||||
if (textContours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -625,12 +625,12 @@ namespace alpr
|
||||
int leftX = MAX;
|
||||
int rightX = MIN;
|
||||
|
||||
for (uint i = 0; i < bestContours.size(); i++)
|
||||
for (unsigned int i = 0; i < bestContours.size(); i++)
|
||||
{
|
||||
if (bestContours.goodIndices[i] == false)
|
||||
continue;
|
||||
|
||||
for (uint z = 0; z < bestContours.contours[i].size(); z++)
|
||||
for (unsigned int z = 0; z < bestContours.contours[i].size(); z++)
|
||||
{
|
||||
if (bestContours.contours[i][z].x < leftX)
|
||||
leftX = bestContours.contours[i][z].x;
|
||||
|
@@ -46,7 +46,7 @@ namespace alpr
|
||||
|
||||
vector<CharPointInfo> charPoints;
|
||||
|
||||
for (uint i = 0; i < contours.contours.size(); i++)
|
||||
for (unsigned int i = 0; i < contours.contours.size(); i++)
|
||||
{
|
||||
if (contours.goodIndices[i] == false)
|
||||
continue;
|
||||
@@ -65,7 +65,7 @@ namespace alpr
|
||||
// Create a mask from the bestLine area, and remove all contours with tops that fall inside of it.
|
||||
|
||||
vector<CharPointInfo> remainingPoints;
|
||||
for (uint i = 0; i < charPoints.size(); i++)
|
||||
for (unsigned int i = 0; i < charPoints.size(); i++)
|
||||
{
|
||||
Mat mask = Mat::zeros(Size(contours.width, contours.height), CV_8U);
|
||||
fillConvexPoly(mask, bestLine.data(), bestLine.size(), Scalar(255,255,255));
|
||||
@@ -103,7 +103,7 @@ namespace alpr
|
||||
|
||||
|
||||
vector<int> charheights;
|
||||
for (uint i = 0; i < charPoints.size(); i++)
|
||||
for (unsigned int i = 0; i < charPoints.size(); i++)
|
||||
charheights.push_back(charPoints[i].boundingBox.height);
|
||||
float medianCharHeight = median(charheights.data(), charheights.size());
|
||||
|
||||
@@ -112,9 +112,9 @@ namespace alpr
|
||||
vector<LineSegment> topLines;
|
||||
vector<LineSegment> bottomLines;
|
||||
// Iterate through each possible char and find all possible lines for the top and bottom of each char segment
|
||||
for (uint i = 0; i < charPoints.size() - 1; i++)
|
||||
for (unsigned int i = 0; i < charPoints.size() - 1; i++)
|
||||
{
|
||||
for (uint k = i+1; k < charPoints.size(); k++)
|
||||
for (unsigned int k = i+1; k < charPoints.size(); k++)
|
||||
{
|
||||
|
||||
int leftCPIndex, rightCPIndex;
|
||||
@@ -168,13 +168,13 @@ namespace alpr
|
||||
int bestScoreDistance = -1; // Line segment distance is used as a tie breaker
|
||||
|
||||
// Now, among all possible lines, find the one that is the best fit
|
||||
for (uint i = 0; i < topLines.size(); i++)
|
||||
for (unsigned int i = 0; i < topLines.size(); i++)
|
||||
{
|
||||
float SCORING_MIN_THRESHOLD = 0.97;
|
||||
float SCORING_MAX_THRESHOLD = 1.03;
|
||||
|
||||
int curScore = 0;
|
||||
for (uint charidx = 0; charidx < charPoints.size(); charidx++)
|
||||
for (unsigned int charidx = 0; charidx < charPoints.size(); charidx++)
|
||||
{
|
||||
float topYPos = topLines[i].getPointAt(charPoints[charidx].top.x);
|
||||
float botYPos = bottomLines[i].getPointAt(charPoints[charidx].bottom.x);
|
||||
|
@@ -51,14 +51,14 @@ namespace alpr
|
||||
if (pipeline_data->config->debugCharAnalysis)
|
||||
cout << "CharacterAnalysis::findOuterBoxMask" << endl;
|
||||
|
||||
for (uint imgIndex = 0; imgIndex < contours.size(); imgIndex++)
|
||||
for (unsigned int imgIndex = 0; imgIndex < contours.size(); imgIndex++)
|
||||
{
|
||||
//vector<bool> charContours = filter(thresholds[imgIndex], allContours[imgIndex], allHierarchy[imgIndex]);
|
||||
|
||||
int charsRecognized = 0;
|
||||
int parentId = -1;
|
||||
bool hasParent = false;
|
||||
for (uint i = 0; i < contours[imgIndex].goodIndices.size(); i++)
|
||||
for (unsigned int i = 0; i < contours[imgIndex].goodIndices.size(); i++)
|
||||
{
|
||||
if (contours[imgIndex].goodIndices[i]) charsRecognized++;
|
||||
if (contours[imgIndex].goodIndices[i] && contours[imgIndex].hierarchy[i][3] != -1)
|
||||
@@ -97,9 +97,9 @@ namespace alpr
|
||||
int longestChildIndex = -1;
|
||||
double longestChildLength = 0;
|
||||
// Find the child with the longest permiter/arc length ( just for kicks)
|
||||
for (uint i = 0; i < contours[winningIndex].size(); i++)
|
||||
for (unsigned int i = 0; i < contours[winningIndex].size(); i++)
|
||||
{
|
||||
for (uint j = 0; j < contours[winningIndex].size(); j++)
|
||||
for (unsigned int j = 0; j < contours[winningIndex].size(); j++)
|
||||
{
|
||||
if (contours[winningIndex].hierarchy[j][3] == winningParentId)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ namespace alpr
|
||||
findContours(mask, contoursSecondRound, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
|
||||
int biggestContourIndex = -1;
|
||||
double largestArea = 0;
|
||||
for (uint c = 0; c < contoursSecondRound.size(); c++)
|
||||
for (unsigned int c = 0; c < contoursSecondRound.size(); c++)
|
||||
{
|
||||
double area = contourArea(contoursSecondRound[c]);
|
||||
if (area > largestArea)
|
||||
|
@@ -50,7 +50,7 @@ namespace alpr
|
||||
CV_RETR_TREE, // retrieve all contours
|
||||
CV_CHAIN_APPROX_SIMPLE ); // all pixels of each contours
|
||||
|
||||
for (uint i = 0; i < contours.size(); i++)
|
||||
for (unsigned int i = 0; i < contours.size(); i++)
|
||||
goodIndices.push_back(true);
|
||||
|
||||
this->width = threshold.cols;
|
||||
@@ -58,7 +58,7 @@ namespace alpr
|
||||
}
|
||||
|
||||
|
||||
uint TextContours::size() {
|
||||
unsigned int TextContours::size() {
|
||||
return contours.size();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace alpr
|
||||
int TextContours::getGoodIndicesCount()
|
||||
{
|
||||
int count = 0;
|
||||
for (uint i = 0; i < goodIndices.size(); i++)
|
||||
for (unsigned int i = 0; i < goodIndices.size(); i++)
|
||||
{
|
||||
if (goodIndices[i])
|
||||
count++;
|
||||
@@ -80,7 +80,7 @@ namespace alpr
|
||||
std::vector<bool> TextContours::getIndicesCopy()
|
||||
{
|
||||
vector<bool> copyArray;
|
||||
for (uint i = 0; i < goodIndices.size(); i++)
|
||||
for (unsigned int i = 0; i < goodIndices.size(); i++)
|
||||
{
|
||||
bool val = goodIndices[i];
|
||||
copyArray.push_back(goodIndices[i]);
|
||||
@@ -93,7 +93,7 @@ namespace alpr
|
||||
{
|
||||
if (newIndices.size() == goodIndices.size())
|
||||
{
|
||||
for (uint i = 0; i < newIndices.size(); i++)
|
||||
for (unsigned int i = 0; i < newIndices.size(); i++)
|
||||
goodIndices[i] = newIndices[i];
|
||||
}
|
||||
else
|
||||
@@ -116,7 +116,7 @@ namespace alpr
|
||||
cvtColor(img_contours, img_contours, CV_GRAY2RGB);
|
||||
|
||||
vector<vector<Point> > allowedContours;
|
||||
for (uint i = 0; i < this->contours.size(); i++)
|
||||
for (unsigned int i = 0; i < this->contours.size(); i++)
|
||||
{
|
||||
if (this->goodIndices[i])
|
||||
allowedContours.push_back(this->contours[i]);
|
||||
|
@@ -41,7 +41,7 @@ namespace alpr
|
||||
std::vector<std::vector<cv::Point> > contours;
|
||||
std::vector<cv::Vec4i> hierarchy;
|
||||
|
||||
uint size();
|
||||
unsigned int size();
|
||||
int getGoodIndicesCount();
|
||||
|
||||
std::vector<bool> getIndicesCopy();
|
||||
|
@@ -30,9 +30,9 @@ namespace alpr
|
||||
TextLine::TextLine(std::vector<cv::Point2f> textArea, std::vector<cv::Point2f> linePolygon) {
|
||||
std::vector<Point> textAreaInts, linePolygonInts;
|
||||
|
||||
for (uint i = 0; i < textArea.size(); i++)
|
||||
for (unsigned int i = 0; i < textArea.size(); i++)
|
||||
textAreaInts.push_back(Point(round(textArea[i].x), round(textArea[i].y)));
|
||||
for (uint i = 0; i < linePolygon.size(); i++)
|
||||
for (unsigned int i = 0; i < linePolygon.size(); i++)
|
||||
linePolygonInts.push_back(Point(round(linePolygon[i].x), round(linePolygon[i].y)));
|
||||
|
||||
initialize(textAreaInts, linePolygonInts);
|
||||
@@ -56,10 +56,10 @@ namespace alpr
|
||||
if (this->linePolygon.size() > 0)
|
||||
this->linePolygon.clear();
|
||||
|
||||
for (uint i = 0; i < textArea.size(); i++)
|
||||
for (unsigned int i = 0; i < textArea.size(); i++)
|
||||
this->textArea.push_back(textArea[i]);
|
||||
|
||||
for (uint i = 0; i < linePolygon.size(); i++)
|
||||
for (unsigned int i = 0; i < linePolygon.size(); i++)
|
||||
this->linePolygon.push_back(linePolygon[i]);
|
||||
|
||||
this->topLine = LineSegment(linePolygon[0].x, linePolygon[0].y, linePolygon[1].x, linePolygon[1].y);
|
||||
|
Reference in New Issue
Block a user