diff --git a/src/openalpr/textdetection/characteranalysis.cpp b/src/openalpr/textdetection/characteranalysis.cpp index 46493dd..aeec953 100644 --- a/src/openalpr/textdetection/characteranalysis.cpp +++ b/src/openalpr/textdetection/characteranalysis.cpp @@ -49,7 +49,6 @@ void CharacterAnalysis::analyze() timespec startTime; getTime(&startTime); - TextLine textLine; for (uint i = 0; i < pipeline_data->thresholds.size(); i++) { @@ -154,23 +153,18 @@ void CharacterAnalysis::analyze() if (this->linePolygon.size() > 0) { - textLine.topLine = LineSegment(this->linePolygon[0].x, this->linePolygon[0].y, this->linePolygon[1].x, this->linePolygon[1].y); - textLine.bottomLine = LineSegment(this->linePolygon[3].x, this->linePolygon[3].y, this->linePolygon[2].x, this->linePolygon[2].y); + LineSegment topLine = LineSegment(this->linePolygon[0].x, this->linePolygon[0].y, this->linePolygon[1].x, this->linePolygon[1].y); + LineSegment bottomLine = LineSegment(this->linePolygon[3].x, this->linePolygon[3].y, this->linePolygon[2].x, this->linePolygon[2].y); filterBetweenLines(bestThreshold, bestContours, linePolygon); - textLine.textArea = getCharArea(textLine.topLine, textLine.bottomLine); + vector textArea = getCharArea(topLine, bottomLine); - if (textLine.textArea.size() > 0) - { - textLine.charBoxTop = LineSegment(textLine.textArea[0].x, textLine.textArea[0].y, textLine.textArea[1].x, textLine.textArea[1].y); - textLine.charBoxBottom = LineSegment(textLine.textArea[3].x, textLine.textArea[3].y, textLine.textArea[2].x, textLine.textArea[2].y); - textLine.charBoxLeft = LineSegment(textLine.textArea[3].x, textLine.textArea[3].y, textLine.textArea[0].x, textLine.textArea[0].y); - textLine.charBoxRight = LineSegment(textLine.textArea[2].x, textLine.textArea[2].y, textLine.textArea[1].x, textLine.textArea[1].y); - } + TextLine textLine(textArea, topLine, bottomLine); + + pipeline_data->textLines.push_back(textLine); } - pipeline_data->textLines.push_back(textLine); this->thresholdsInverted = isPlateInverted(); } diff --git a/src/openalpr/textdetection/characteranalysis.h b/src/openalpr/textdetection/characteranalysis.h index 52bbe36..3811b05 100644 --- a/src/openalpr/textdetection/characteranalysis.h +++ b/src/openalpr/textdetection/characteranalysis.h @@ -38,23 +38,13 @@ class CharacterAnalysis cv::Mat bestThreshold; TextContours bestContours; - //std::vector > bestContours; - //std::vector bestHierarchy; - //std::vector bestCharSegments; - //int bestCharSegmentsCount; - std::vector linePolygon; - - bool thresholdsInverted; bool isTwoLine; std::vector allTextContours; - //std::vector > > allContours; - //std::vector > allHierarchy; - //std::vector > charSegments; void analyze(); diff --git a/src/openalpr/textdetection/textline.cpp b/src/openalpr/textdetection/textline.cpp index ccd3b2a..d8be290 100644 --- a/src/openalpr/textdetection/textline.cpp +++ b/src/openalpr/textdetection/textline.cpp @@ -20,7 +20,17 @@ #include "textline.h" -TextLine::TextLine() { +TextLine::TextLine(std::vector textArea, LineSegment topLine, LineSegment bottomLine) { + if (textArea.size() > 0) + { + this->textArea = textArea; + this->topLine = topLine; + this->bottomLine = bottomLine; + this->charBoxTop = LineSegment(textArea[0].x, textArea[0].y, textArea[1].x, textArea[1].y); + this->charBoxBottom = LineSegment(textArea[3].x, textArea[3].y, textArea[2].x, textArea[2].y); + this->charBoxLeft = LineSegment(textArea[3].x, textArea[3].y, textArea[0].x, textArea[0].y); + this->charBoxRight = LineSegment(textArea[2].x, textArea[2].y, textArea[1].x, textArea[1].y); + } } diff --git a/src/openalpr/textdetection/textline.h b/src/openalpr/textdetection/textline.h index 6172c01..ac3eeb1 100644 --- a/src/openalpr/textdetection/textline.h +++ b/src/openalpr/textdetection/textline.h @@ -25,7 +25,7 @@ class TextLine { public: - TextLine(); + TextLine(std::vector textArea, LineSegment topLine, LineSegment bottomLine); virtual ~TextLine(); std::vector textArea;