From 7808cce33a4ea35a2a2a81ecdcbb587e25695d60 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 29 Jan 2014 14:34:31 -0600 Subject: [PATCH] Renamed debugImg to histoImg. Sending the Histogram class to one of the character segmentation classees --- src/openalpr/charactersegmenter.cpp | 14 +++++++++----- src/openalpr/charactersegmenter.h | 2 +- src/openalpr/verticalhistogram.cpp | 6 +++--- src/openalpr/verticalhistogram.h | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/openalpr/charactersegmenter.cpp b/src/openalpr/charactersegmenter.cpp index d5455b7..f3536fd 100644 --- a/src/openalpr/charactersegmenter.cpp +++ b/src/openalpr/charactersegmenter.cpp @@ -142,15 +142,15 @@ CharacterSegmenter::CharacterSegmenter(Mat img, bool invertedColors, Config* con if (this->config->debugCharSegmenter) { - Mat histoCopy(vertHistogram.debugImg.size(), vertHistogram.debugImg.type()); + Mat histoCopy(vertHistogram.histoImg.size(), vertHistogram.histoImg.type()); //vertHistogram.copyTo(histoCopy); - cvtColor(vertHistogram.debugImg, histoCopy, CV_GRAY2RGB); + cvtColor(vertHistogram.histoImg, histoCopy, CV_GRAY2RGB); allHistograms.push_back(histoCopy); } // float score = 0; - vector charBoxes = getHistogramBoxes(vertHistogram.debugImg, avgCharWidth, avgCharHeight, &score); + vector charBoxes = getHistogramBoxes(vertHistogram, avgCharWidth, avgCharHeight, &score); if (this->config->debugCharSegmenter) @@ -271,7 +271,7 @@ CharacterSegmenter::~CharacterSegmenter() // Given a histogram and the horizontal line boundaries, respond with an array of boxes where the characters are // Scores the histogram quality as well based on num chars, char volume, and even separation -vector CharacterSegmenter::getHistogramBoxes(Mat histogram, float avgCharWidth, float avgCharHeight, float* score) +vector CharacterSegmenter::getHistogramBoxes(VerticalHistogram histogram, float avgCharWidth, float avgCharHeight, float* score) { float MIN_HISTOGRAM_HEIGHT = avgCharHeight * config->segmentationMinCharHeightPercent; @@ -282,7 +282,7 @@ vector CharacterSegmenter::getHistogramBoxes(Mat histogram, float avgCharW int pxLeniency = 2; vector charBoxes; - vector allBoxes = get1DHits(histogram, pxLeniency); + vector allBoxes = get1DHits(histogram.histoImg, pxLeniency); for (int i = 0; i < allBoxes.size(); i++) { @@ -292,6 +292,10 @@ vector CharacterSegmenter::getHistogramBoxes(Mat histogram, float avgCharW { charBoxes.push_back(allBoxes[i]); } + else if (allBoxes[i].width > MAX_SEGMENT_WIDTH && allBoxes[i].height > MIN_HISTOGRAM_HEIGHT) + { + + } } diff --git a/src/openalpr/charactersegmenter.h b/src/openalpr/charactersegmenter.h index d5074e6..693469d 100644 --- a/src/openalpr/charactersegmenter.h +++ b/src/openalpr/charactersegmenter.h @@ -82,7 +82,7 @@ class CharacterSegmenter void removeSmallContours(vector thresholds, vector > > allContours, float avgCharWidth, float avgCharHeight); Mat getVerticalHistogram(Mat img, Mat mask); - vector getHistogramBoxes(Mat histogram, float avgCharWidth, float avgCharHeight, float* score); + vector getHistogramBoxes(VerticalHistogram histogram, float avgCharWidth, float avgCharHeight, float* score); vector getBestCharBoxes(Mat img, vector charBoxes, float avgCharWidth); vector combineCloseBoxes( vector charBoxes, float avgCharWidth); diff --git a/src/openalpr/verticalhistogram.cpp b/src/openalpr/verticalhistogram.cpp index 65ae68e..9c916ba 100644 --- a/src/openalpr/verticalhistogram.cpp +++ b/src/openalpr/verticalhistogram.cpp @@ -29,7 +29,7 @@ VerticalHistogram::VerticalHistogram(Mat inputImage, Mat mask) VerticalHistogram::~VerticalHistogram() { - debugImg.release(); + histoImg.release(); colHeights.clear(); } @@ -40,7 +40,7 @@ void VerticalHistogram::analyzeImage(Mat inputImage, Mat mask) lowestValley = inputImage.rows; - debugImg = Mat::zeros(inputImage.size(), CV_8U); + histoImg = Mat::zeros(inputImage.size(), CV_8U); int columnCount; @@ -57,7 +57,7 @@ void VerticalHistogram::analyzeImage(Mat inputImage, Mat mask) for (; columnCount > 0; columnCount--) - debugImg.at(inputImage.rows - columnCount, col) = 255; + histoImg.at(inputImage.rows - columnCount, col) = 255; this->colHeights.push_back(columnCount); diff --git a/src/openalpr/verticalhistogram.h b/src/openalpr/verticalhistogram.h index cae304d..73813bb 100644 --- a/src/openalpr/verticalhistogram.h +++ b/src/openalpr/verticalhistogram.h @@ -44,7 +44,7 @@ class VerticalHistogram VerticalHistogram(Mat inputImage, Mat mask); virtual ~VerticalHistogram(); - Mat debugImg; + Mat histoImg; private: