mirror of
https://github.com/kerberos-io/openalpr-base.git
synced 2025-10-07 07:20:50 +08:00
Moved using statements out of headers and into cpp
This commit is contained in:
@@ -29,30 +29,28 @@
|
||||
#include "verticalhistogram.h"
|
||||
#include "config.h"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
//const float MIN_BOX_WIDTH_PX = 4; // 4 pixels
|
||||
|
||||
const Scalar COLOR_DEBUG_EDGE(0,0,255); // Red
|
||||
const Scalar COLOR_DEBUG_SPECKLES(0,0,255); // Red
|
||||
const Scalar COLOR_DEBUG_MIN_HEIGHT(255,0,0); // Blue
|
||||
const Scalar COLOR_DEBUG_MIN_AREA(255,0,0); // Blue
|
||||
const Scalar COLOR_DEBUG_FULLBOX(255,255,0); // Blue-green
|
||||
const Scalar COLOR_DEBUG_COLORFILTER(255,0,255); // Magenta
|
||||
const Scalar COLOR_DEBUG_EMPTYFILTER(0,255,255); // Yellow
|
||||
const cv::Scalar COLOR_DEBUG_EDGE(0,0,255); // Red
|
||||
const cv::Scalar COLOR_DEBUG_SPECKLES(0,0,255); // Red
|
||||
const cv::Scalar COLOR_DEBUG_MIN_HEIGHT(255,0,0); // Blue
|
||||
const cv::Scalar COLOR_DEBUG_MIN_AREA(255,0,0); // Blue
|
||||
const cv::Scalar COLOR_DEBUG_FULLBOX(255,255,0); // Blue-green
|
||||
const cv::Scalar COLOR_DEBUG_COLORFILTER(255,0,255); // Magenta
|
||||
const cv::Scalar COLOR_DEBUG_EMPTYFILTER(0,255,255); // Yellow
|
||||
|
||||
class CharacterSegmenter
|
||||
{
|
||||
|
||||
public:
|
||||
CharacterSegmenter(Mat img, bool invertedColors, Config* config);
|
||||
CharacterSegmenter(cv::Mat img, bool invertedColors, Config* config);
|
||||
virtual ~CharacterSegmenter();
|
||||
|
||||
vector<Rect> characters;
|
||||
std::vector<cv::Rect> characters;
|
||||
int confidence;
|
||||
|
||||
vector<Mat> getThresholds();
|
||||
std::vector<cv::Mat> getThresholds();
|
||||
|
||||
private:
|
||||
Config* config;
|
||||
@@ -62,40 +60,40 @@ class CharacterSegmenter
|
||||
LineSegment top;
|
||||
LineSegment bottom;
|
||||
|
||||
vector<Mat> imgDbgGeneral;
|
||||
vector<Mat> imgDbgCleanStages;
|
||||
std::vector<cv::Mat> imgDbgGeneral;
|
||||
std::vector<cv::Mat> imgDbgCleanStages;
|
||||
|
||||
vector<bool> filter(Mat img, vector<vector<Point> > contours, vector<Vec4i> hierarchy);
|
||||
vector<bool> filterByBoxSize(vector< vector< Point> > contours, vector<bool> goodIndices, float minHeightPx, float maxHeightPx);
|
||||
vector<bool> filterBetweenLines(Mat img, vector<vector<Point> > contours, vector<Vec4i> hierarchy, vector<Point> outerPolygon, vector<bool> goodIndices);
|
||||
vector<bool> filterContourHoles(vector<vector<Point> > contours, vector<Vec4i> hierarchy, vector<bool> goodIndices);
|
||||
std::vector<bool> filter(cv::Mat img, std::vector<std::vector<cv::Point> > contours, std::vector<cv::Vec4i> hierarchy);
|
||||
std::vector<bool> filterByBoxSize(std::vector< std::vector<cv::Point> > contours, std::vector<bool> goodIndices, float minHeightPx, float maxHeightPx);
|
||||
std::vector<bool> filterBetweenLines(cv::Mat img, std::vector<std::vector<cv::Point> > contours, std::vector<cv::Vec4i> hierarchy, std::vector<cv::Point> outerPolygon, std::vector<bool> goodIndices);
|
||||
std::vector<bool> filterContourHoles(std::vector<std::vector<cv::Point> > contours, std::vector<cv::Vec4i> hierarchy, std::vector<bool> goodIndices);
|
||||
|
||||
vector<Point> getBestVotedLines(Mat img, vector<vector<Point> > contours, vector<bool> goodIndices);
|
||||
int getGoodIndicesCount(vector<bool> goodIndices);
|
||||
std::vector<cv::Point> getBestVotedLines(cv::Mat img, std::vector<std::vector<cv::Point> > contours, std::vector<bool> goodIndices);
|
||||
int getGoodIndicesCount(std::vector<bool> goodIndices);
|
||||
|
||||
Mat getCharacterMask(Mat img_threshold, vector<vector<Point> > contours, vector<Vec4i> hierarchy, vector<bool> goodIndices);
|
||||
Mat getCharBoxMask(Mat img_threshold, vector<Rect> charBoxes);
|
||||
cv::Mat getCharacterMask(cv::Mat img_threshold, std::vector<std::vector<cv::Point> > contours, std::vector<cv::Vec4i> hierarchy, std::vector<bool> goodIndices);
|
||||
cv::Mat getCharBoxMask(cv::Mat img_threshold, std::vector<cv::Rect> charBoxes);
|
||||
|
||||
void removeSmallContours(vector<Mat> thresholds, vector<vector<vector<Point > > > allContours, float avgCharWidth, float avgCharHeight);
|
||||
void removeSmallContours(std::vector<cv::Mat> thresholds, std::vector<std::vector<std::vector<cv::Point > > > allContours, float avgCharWidth, float avgCharHeight);
|
||||
|
||||
Mat getVerticalHistogram(Mat img, Mat mask);
|
||||
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);
|
||||
cv::Mat getVerticalHistogram(cv::Mat img, cv::Mat mask);
|
||||
std::vector<cv::Rect> getHistogramBoxes(VerticalHistogram histogram, float avgCharWidth, float avgCharHeight, float* score);
|
||||
std::vector<cv::Rect> getBestCharBoxes(cv::Mat img, std::vector<cv::Rect> charBoxes, float avgCharWidth);
|
||||
std::vector<cv::Rect> combineCloseBoxes( std::vector<cv::Rect> charBoxes, float avgCharWidth);
|
||||
|
||||
vector<Rect> get1DHits(Mat img, int yOffset);
|
||||
std::vector<cv::Rect> get1DHits(cv::Mat img, int yOffset);
|
||||
|
||||
void cleanCharRegions(vector<Mat> thresholds, vector<Rect> charRegions);
|
||||
void cleanBasedOnColor(vector<Mat> thresholds, Mat colorMask, vector<Rect> charRegions);
|
||||
void cleanMostlyFullBoxes(vector<Mat> thresholds, const vector<Rect> charRegions);
|
||||
vector<Rect> filterMostlyEmptyBoxes(vector<Mat> thresholds, const vector<Rect> charRegions);
|
||||
void filterEdgeBoxes(vector<Mat> thresholds, const vector<Rect> charRegions, float avgCharWidth, float avgCharHeight);
|
||||
void cleanCharRegions(std::vector<cv::Mat> thresholds, std::vector<cv::Rect> charRegions);
|
||||
void cleanBasedOnColor(std::vector<cv::Mat> thresholds, cv::Mat colorMask, std::vector<cv::Rect> charRegions);
|
||||
void cleanMostlyFullBoxes(std::vector<cv::Mat> thresholds, const std::vector<cv::Rect> charRegions);
|
||||
std::vector<cv::Rect> filterMostlyEmptyBoxes(std::vector<cv::Mat> thresholds, const std::vector<cv::Rect> charRegions);
|
||||
void filterEdgeBoxes(std::vector<cv::Mat> thresholds, const std::vector<cv::Rect> charRegions, float avgCharWidth, float avgCharHeight);
|
||||
|
||||
int getLongestBlobLengthBetweenLines(Mat img, int col);
|
||||
int getLongestBlobLengthBetweenLines(cv::Mat img, int col);
|
||||
|
||||
int isSkinnyLineInsideBox(Mat threshold, Rect box, vector<vector<Point> > contours, vector<Vec4i> hierarchy, float avgCharWidth, float avgCharHeight);
|
||||
int isSkinnyLineInsideBox(cv::Mat threshold, cv::Rect box, std::vector<std::vector<cv::Point> > contours, std::vector<cv::Vec4i> hierarchy, float avgCharWidth, float avgCharHeight);
|
||||
|
||||
vector<Point> getEncapsulatingLines(Mat img, vector<vector<Point> > contours, vector<bool> goodIndices);
|
||||
std::vector<cv::Point> getEncapsulatingLines(cv::Mat img, std::vector<std::vector<cv::Point> > contours, std::vector<bool> goodIndices);
|
||||
};
|
||||
|
||||
#endif // OPENALPR_CHARACTERSEGMENTER_H
|
||||
|
Reference in New Issue
Block a user