diff --git a/src/openalpr/segmentation/charactersegmenter.cpp b/src/openalpr/segmentation/charactersegmenter.cpp index 22fca70..d5912db 100644 --- a/src/openalpr/segmentation/charactersegmenter.cpp +++ b/src/openalpr/segmentation/charactersegmenter.cpp @@ -96,29 +96,31 @@ namespace alpr HistogramVertical vertHistogram(pipeline_data->thresholds[i], histogramMask); - if (this->config->debugCharSegmenter) - { - Mat histoCopy(vertHistogram.histoImg.size(), vertHistogram.histoImg.type()); - //vertHistogram.copyTo(histoCopy); - cvtColor(vertHistogram.histoImg, histoCopy, CV_GRAY2RGB); - - string label = "threshold: " + toString(i); - allHistograms.push_back(addLabel(histoCopy, label)); - } +// if (this->config->debugCharSegmenter) +// { +// Mat histoCopy(vertHistogram.histoImg.size(), vertHistogram.histoImg.type()); +// //vertHistogram.copyTo(histoCopy); +// cvtColor(vertHistogram.histoImg, histoCopy, CV_GRAY2RGB); +// +// string label = "threshold: " + toString(i); +// allHistograms.push_back(addLabel(histoCopy, label)); +// +// std::cout << histoCopy.cols << " x " << histoCopy.rows << std::endl; +// } float score = 0; vector charBoxes = getHistogramBoxes(vertHistogram, avgCharWidth, avgCharHeight, &score); - if (this->config->debugCharSegmenter) - { - for (unsigned int cboxIdx = 0; cboxIdx < charBoxes.size(); cboxIdx++) - { - rectangle(allHistograms[i], charBoxes[cboxIdx], Scalar(0, 255, 0)); - } - - Mat histDashboard = drawImageDashboard(allHistograms, allHistograms[0].type(), 1); - displayImage(config, "Char seg histograms", histDashboard); - } +// if (this->config->debugCharSegmenter) +// { +// for (unsigned int cboxIdx = 0; cboxIdx < charBoxes.size(); cboxIdx++) +// { +// rectangle(allHistograms[i], charBoxes[cboxIdx], Scalar(0, 255, 0)); +// } +// +// Mat histDashboard = drawImageDashboard(allHistograms, allHistograms[0].type(), 1); +// displayImage(config, "Char seg histograms", histDashboard); +// } for (unsigned int z = 0; z < charBoxes.size(); z++) lineBoxes.push_back(charBoxes[z]); @@ -184,6 +186,12 @@ namespace alpr displayImage(config, "Segmentation Clean Filters", cleanImgDash); } } + + // Apply the edge mask (left and right ends) after all lines have been processed. + for (unsigned int i = 0; i < pipeline_data->thresholds.size(); i++) + { + bitwise_and(pipeline_data->thresholds[i], edge_filter_mask, pipeline_data->thresholds[i]); + } vector all_regions_combined; for (unsigned int lidx = 0; lidx < pipeline_data->charRegions.size(); lidx++)