mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-06 06:56:49 +08:00
Renamed debugImg to histoImg. Sending the Histogram class to one of the character segmentation classees
This commit is contained in:
@@ -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<Rect> charBoxes = getHistogramBoxes(vertHistogram.debugImg, avgCharWidth, avgCharHeight, &score);
|
||||
vector<Rect> 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<Rect> CharacterSegmenter::getHistogramBoxes(Mat histogram, float avgCharWidth, float avgCharHeight, float* score)
|
||||
vector<Rect> CharacterSegmenter::getHistogramBoxes(VerticalHistogram histogram, float avgCharWidth, float avgCharHeight, float* score)
|
||||
{
|
||||
float MIN_HISTOGRAM_HEIGHT = avgCharHeight * config->segmentationMinCharHeightPercent;
|
||||
|
||||
@@ -282,7 +282,7 @@ vector<Rect> CharacterSegmenter::getHistogramBoxes(Mat histogram, float avgCharW
|
||||
int pxLeniency = 2;
|
||||
|
||||
vector<Rect> charBoxes;
|
||||
vector<Rect> allBoxes = get1DHits(histogram, pxLeniency);
|
||||
vector<Rect> allBoxes = get1DHits(histogram.histoImg, pxLeniency);
|
||||
|
||||
for (int i = 0; i < allBoxes.size(); i++)
|
||||
{
|
||||
@@ -292,6 +292,10 @@ vector<Rect> 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -82,7 +82,7 @@ class CharacterSegmenter
|
||||
void removeSmallContours(vector<Mat> thresholds, vector<vector<vector<Point > > > allContours, float avgCharWidth, float avgCharHeight);
|
||||
|
||||
Mat getVerticalHistogram(Mat img, Mat mask);
|
||||
vector<Rect> getHistogramBoxes(Mat histogram, float avgCharWidth, float avgCharHeight, float* score);
|
||||
vector<Rect> getHistogramBoxes(VerticalHistogram histogram, float avgCharWidth, float avgCharHeight, float* score);
|
||||
vector<Rect> getBestCharBoxes(Mat img, vector<Rect> charBoxes, float avgCharWidth);
|
||||
vector<Rect> combineCloseBoxes( vector<Rect> charBoxes, float avgCharWidth);
|
||||
|
||||
|
@@ -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<uchar>(inputImage.rows - columnCount, col) = 255;
|
||||
histoImg.at<uchar>(inputImage.rows - columnCount, col) = 255;
|
||||
|
||||
this->colHeights.push_back(columnCount);
|
||||
|
||||
|
@@ -44,7 +44,7 @@ class VerticalHistogram
|
||||
VerticalHistogram(Mat inputImage, Mat mask);
|
||||
virtual ~VerticalHistogram();
|
||||
|
||||
Mat debugImg;
|
||||
Mat histoImg;
|
||||
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user