Using a perspective transformation on CharAnalysis instead of redoing the whole process during segmentation. Much faster and seems slightly more accurate -- will need to benchmark.

This commit is contained in:
Matt Hill
2014-10-19 19:07:00 -04:00
parent d2bfebe443
commit a691d8a6fe
4 changed files with 102 additions and 22 deletions

View File

@@ -24,9 +24,35 @@
using namespace cv;
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++)
textAreaInts.push_back(Point(round(textArea[i].x), round(textArea[i].y)));
for (uint i = 0; i < linePolygon.size(); i++)
linePolygonInts.push_back(Point(round(linePolygon[i].x), round(linePolygon[i].y)));
initialize(textAreaInts, linePolygonInts);
}
TextLine::TextLine(std::vector<cv::Point> textArea, std::vector<cv::Point> linePolygon) {
initialize(textArea, linePolygon);
}
TextLine::~TextLine() {
}
void TextLine::initialize(std::vector<cv::Point> textArea, std::vector<cv::Point> linePolygon) {
if (textArea.size() > 0)
{
if (this->textArea.size() > 0)
this->textArea.clear();
if (this->linePolygon.size() > 0)
this->linePolygon.clear();
for (uint i = 0; i < textArea.size(); i++)
this->textArea.push_back(textArea[i]);
@@ -53,9 +79,6 @@ TextLine::TextLine(std::vector<cv::Point> textArea, std::vector<cv::Point> lineP
}
TextLine::~TextLine() {
}
cv::Mat TextLine::drawDebugImage(cv::Mat baseImage) {
cv::Mat debugImage(baseImage.size(), baseImage.type());