Performance improvement -- stop processing filters if the character count is already 0.

This commit is contained in:
Matt Hill
2014-04-08 12:20:41 -05:00
parent 24468becab
commit a35ab7c7fe
2 changed files with 3 additions and 3 deletions

View File

@@ -573,12 +573,12 @@ vector<bool> CharacterAnalysis::filter(Mat img, vector<vector<Point> > contours,
goodIndices = this->filterByBoxSize(contours, goodIndices, STARTING_MIN_HEIGHT + (i * HEIGHT_STEP), STARTING_MAX_HEIGHT + (i * HEIGHT_STEP)); goodIndices = this->filterByBoxSize(contours, goodIndices, STARTING_MIN_HEIGHT + (i * HEIGHT_STEP), STARTING_MAX_HEIGHT + (i * HEIGHT_STEP));
goodIndicesCount = getGoodIndicesCount(goodIndices); goodIndicesCount = getGoodIndicesCount(goodIndices);
if ( goodIndicesCount > 0 && goodIndicesCount <= bestFitScore) // Don't bother doing more filtering if we already lost... if ( goodIndicesCount == 0 || goodIndicesCount <= bestFitScore) // Don't bother doing more filtering if we already lost...
continue; continue;
goodIndices = this->filterContourHoles(contours, hierarchy, goodIndices); goodIndices = this->filterContourHoles(contours, hierarchy, goodIndices);
goodIndicesCount = getGoodIndicesCount(goodIndices); goodIndicesCount = getGoodIndicesCount(goodIndices);
if ( goodIndicesCount > 0 && goodIndicesCount <= bestFitScore) // Don't bother doing more filtering if we already lost... if ( goodIndicesCount == 0 || goodIndicesCount <= bestFitScore) // Don't bother doing more filtering if we already lost...
continue; continue;
//goodIndices = this->filterByParentContour( contours, hierarchy, goodIndices); //goodIndices = this->filterByParentContour( contours, hierarchy, goodIndices);
vector<Point> lines = getBestVotedLines(img, contours, goodIndices); vector<Point> lines = getBestVotedLines(img, contours, goodIndices);

View File

@@ -37,7 +37,7 @@ CharacterRegion::CharacterRegion(Mat img, Config* config)
charAnalysis = new CharacterAnalysis(img, config); charAnalysis = new CharacterAnalysis(img, config);
charAnalysis->analyze(); charAnalysis->analyze();
if (this->debug) if (this->debug && charAnalysis->linePolygon.size() > 0)
{ {
vector<Mat> tempDash; vector<Mat> tempDash;
for (int z = 0; z < charAnalysis->thresholds.size(); z++) for (int z = 0; z < charAnalysis->thresholds.size(); z++)