mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 07:37:00 +08:00
Moved polygon logic to textline
This commit is contained in:
@@ -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<Point> 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();
|
||||
}
|
||||
|
@@ -38,23 +38,13 @@ class CharacterAnalysis
|
||||
cv::Mat bestThreshold;
|
||||
|
||||
TextContours bestContours;
|
||||
//std::vector<std::vector<cv::Point> > bestContours;
|
||||
//std::vector<cv::Vec4i> bestHierarchy;
|
||||
//std::vector<bool> bestCharSegments;
|
||||
//int bestCharSegmentsCount;
|
||||
|
||||
|
||||
std::vector<cv::Point> linePolygon;
|
||||
|
||||
|
||||
|
||||
bool thresholdsInverted;
|
||||
bool isTwoLine;
|
||||
|
||||
std::vector<TextContours> allTextContours;
|
||||
//std::vector<std::vector<std::vector<cv::Point> > > allContours;
|
||||
//std::vector<std::vector<cv::Vec4i> > allHierarchy;
|
||||
//std::vector<std::vector<bool> > charSegments;
|
||||
|
||||
void analyze();
|
||||
|
||||
|
@@ -20,7 +20,17 @@
|
||||
|
||||
#include "textline.h"
|
||||
|
||||
TextLine::TextLine() {
|
||||
TextLine::TextLine(std::vector<cv::Point> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
class TextLine {
|
||||
public:
|
||||
TextLine();
|
||||
TextLine(std::vector<cv::Point> textArea, LineSegment topLine, LineSegment bottomLine);
|
||||
virtual ~TextLine();
|
||||
|
||||
std::vector<cv::Point> textArea;
|
||||
|
Reference in New Issue
Block a user