|
|
@ -14,106 +14,133 @@
|
|
|
|
#ifndef __PLATE_LOCATE_H__
|
|
|
|
#ifndef __PLATE_LOCATE_H__
|
|
|
|
#define __PLATE_LOCATE_H__
|
|
|
|
#define __PLATE_LOCATE_H__
|
|
|
|
|
|
|
|
|
|
|
|
#include "prep.h"
|
|
|
|
|
|
|
|
#include "plate.h"
|
|
|
|
#include "plate.h"
|
|
|
|
#include "core_func.h"
|
|
|
|
#include "core_func.h"
|
|
|
|
|
|
|
|
|
|
|
|
class LabInfo;
|
|
|
|
class LabInfo;
|
|
|
|
/*! \namespace easypr
|
|
|
|
|
|
|
|
Namespace where all the C++ EasyPR functionality resides
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace easypr {
|
|
|
|
namespace easypr {
|
|
|
|
|
|
|
|
|
|
|
|
class CPlateLocate
|
|
|
|
class CPlateLocate {
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
|
|
|
|
CPlateLocate();
|
|
|
|
CPlateLocate();
|
|
|
|
|
|
|
|
|
|
|
|
enum LocateType { SOBEL, COLOR };
|
|
|
|
enum LocateType {
|
|
|
|
|
|
|
|
SOBEL, COLOR
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//! Sobel第一次搜索
|
|
|
|
//! Sobel第一次搜索
|
|
|
|
//! 不限制大小和形状,获取的BoundRect进入下一步
|
|
|
|
//! 不限制大小和形状,获取的BoundRect进入下一步
|
|
|
|
int sobelFrtSearch(const Mat& src, vector<Rect_<float>>& outRects);
|
|
|
|
int sobelFrtSearch(const cv::Mat& src,
|
|
|
|
|
|
|
|
std::vector<cv::Rect_<float>>& outRects);
|
|
|
|
|
|
|
|
|
|
|
|
//! Sobel第二次搜索
|
|
|
|
//! Sobel第二次搜索
|
|
|
|
//! 对大小和形状做限制,生成参考坐标
|
|
|
|
//! 对大小和形状做限制,生成参考坐标
|
|
|
|
int sobelSecSearch( Mat& bound, Point2f refpoint, vector<RotatedRect>& outRects);
|
|
|
|
int sobelSecSearch(cv::Mat& bound, cv::Point2f refpoint,
|
|
|
|
int sobelSecSearchPart( Mat& bound, Point2f refpoint, vector<RotatedRect>& outRects);
|
|
|
|
std::vector<cv::RotatedRect>& outRects);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sobelSecSearchPart(cv::Mat& bound, cv::Point2f refpoint,
|
|
|
|
|
|
|
|
std::vector<cv::RotatedRect>& outRects);
|
|
|
|
|
|
|
|
|
|
|
|
//! 抗扭斜处理
|
|
|
|
//! 抗扭斜处理
|
|
|
|
int deskew(const Mat& src, const Mat& src_b, vector<RotatedRect>& inRects, vector<CPlate>& outPlates);
|
|
|
|
int deskew(const cv::Mat& src, const cv::Mat& src_b,
|
|
|
|
|
|
|
|
std::vector<cv::RotatedRect>& inRects,
|
|
|
|
|
|
|
|
std::vector<CPlate>& outPlates);
|
|
|
|
|
|
|
|
|
|
|
|
//! 是否偏斜
|
|
|
|
//! 是否偏斜
|
|
|
|
//! 输入二值化图像,输出判断结果
|
|
|
|
//! 输入二值化图像,输出判断结果
|
|
|
|
bool isdeflection(const Mat& in, const double angle, double& slope);
|
|
|
|
bool isdeflection(const cv::Mat& in, const double angle, double& slope);
|
|
|
|
|
|
|
|
|
|
|
|
//! Sobel运算
|
|
|
|
//! Sobel运算
|
|
|
|
//! 输入彩色图像,输出二值化图像
|
|
|
|
//! 输入彩色图像,输出二值化图像
|
|
|
|
int sobelOper(const Mat& in, Mat& out, int blurSize, int morphW, int morphH);
|
|
|
|
int sobelOper(const cv::Mat& in, cv::Mat& out, int blurSize, int morphW,
|
|
|
|
|
|
|
|
int morphH);
|
|
|
|
|
|
|
|
|
|
|
|
//! 计算一个安全的Rect
|
|
|
|
//! 计算一个安全的Rect
|
|
|
|
bool calcSafeRect(const RotatedRect& roi_rect, const Mat& src, Rect_<float>& safeBoundRect);
|
|
|
|
bool calcSafeRect(const cv::RotatedRect& roi_rect, const cv::Mat& src,
|
|
|
|
|
|
|
|
cv::Rect_<float>& safeBoundRect);
|
|
|
|
|
|
|
|
|
|
|
|
//! 旋转操作
|
|
|
|
//! 旋转操作
|
|
|
|
bool rotation(Mat& in, Mat& out, const Size rect_size, const Point2f center, const double angle);
|
|
|
|
bool rotation(cv::Mat& in, cv::Mat& out, const cv::Size rect_size,
|
|
|
|
|
|
|
|
const cv::Point2f center,
|
|
|
|
|
|
|
|
const double angle);
|
|
|
|
|
|
|
|
|
|
|
|
//! 扭变操作
|
|
|
|
//! 扭变操作
|
|
|
|
void affine(const Mat& in, Mat& out, const double slope);
|
|
|
|
void affine(const cv::Mat& in, cv::Mat& out, const double slope);
|
|
|
|
|
|
|
|
|
|
|
|
//! 颜色定位法
|
|
|
|
//! 颜色定位法
|
|
|
|
int plateColorLocate(Mat src, vector<CPlate>& candPlates, int index = 0);
|
|
|
|
int plateColorLocate(cv::Mat src, std::vector<CPlate>& candPlates,
|
|
|
|
|
|
|
|
int index = 0);
|
|
|
|
|
|
|
|
|
|
|
|
//! Sobel定位法
|
|
|
|
//! Sobel定位法
|
|
|
|
int plateSobelLocate(Mat src, vector<CPlate>& candPlates, int index = 0);
|
|
|
|
int plateSobelLocate(cv::Mat src, std::vector<CPlate>& candPlates,
|
|
|
|
int sobelOperT(const Mat& in, Mat& out, int blurSize, int morphW, int morphH);
|
|
|
|
int index = 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int sobelOperT(const cv::Mat& in, cv::Mat& out, int blurSize, int morphW,
|
|
|
|
|
|
|
|
int morphH);
|
|
|
|
|
|
|
|
|
|
|
|
//! Color搜索
|
|
|
|
//! Color搜索
|
|
|
|
int colorSearch(const Mat& src, const Color r, Mat& out, vector<RotatedRect>& outRects, int index = 0);
|
|
|
|
int colorSearch(const cv::Mat& src, const Color r, cv::Mat& out,
|
|
|
|
|
|
|
|
std::vector<cv::RotatedRect>& outRects, int index = 0);
|
|
|
|
|
|
|
|
|
|
|
|
//! 未使用函数与代码
|
|
|
|
//! 未使用函数与代码
|
|
|
|
//! 开始------------
|
|
|
|
//! 开始------------
|
|
|
|
bool sobelJudge(Mat roi);
|
|
|
|
bool sobelJudge(cv::Mat roi);
|
|
|
|
int deskewOld(Mat src, vector<RotatedRect>& inRects, vector<RotatedRect>& outRects, vector<Mat>& outMats, LocateType locateType);
|
|
|
|
|
|
|
|
bool verifyCharSizes(Mat r);
|
|
|
|
int deskewOld(cv::Mat src, std::vector<cv::RotatedRect>& inRects,
|
|
|
|
|
|
|
|
std::vector<cv::RotatedRect>& outRects,
|
|
|
|
|
|
|
|
std::vector<cv::Mat>& outMats,
|
|
|
|
|
|
|
|
LocateType locateType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool verifyCharSizes(cv::Mat r);
|
|
|
|
//! 结束------------
|
|
|
|
//! 结束------------
|
|
|
|
//! 未使用函数与代码
|
|
|
|
//! 未使用函数与代码
|
|
|
|
|
|
|
|
|
|
|
|
//! 车牌定位
|
|
|
|
//! 车牌定位
|
|
|
|
int plateLocate(Mat, vector<Mat>&, int = 0 );
|
|
|
|
int plateLocate(cv::Mat, std::vector<cv::Mat>&, int = 0);
|
|
|
|
|
|
|
|
|
|
|
|
//! 车牌的尺寸验证
|
|
|
|
//! 车牌的尺寸验证
|
|
|
|
bool verifySizes(RotatedRect mr);
|
|
|
|
bool verifySizes(cv::RotatedRect mr);
|
|
|
|
|
|
|
|
|
|
|
|
//! 结果车牌显示
|
|
|
|
//! 结果车牌显示
|
|
|
|
Mat showResultMat(Mat src, Size rect_size, Point2f center, int index);
|
|
|
|
cv::Mat showResultMat(cv::Mat src, cv::Size rect_size, cv::Point2f center,
|
|
|
|
|
|
|
|
int index);
|
|
|
|
|
|
|
|
|
|
|
|
//! 生活模式与工业模式切换
|
|
|
|
//! 生活模式与工业模式切换
|
|
|
|
void setLifemode(bool param);
|
|
|
|
void setLifemode(bool param);
|
|
|
|
|
|
|
|
|
|
|
|
//! 设置与读取变量
|
|
|
|
//! 设置与读取变量
|
|
|
|
inline void setGaussianBlurSize(int param){ m_GaussianBlurSize = param;}
|
|
|
|
inline void setGaussianBlurSize(int param) { m_GaussianBlurSize = param; }
|
|
|
|
inline int getGaussianBlurSize() const{ return m_GaussianBlurSize;}
|
|
|
|
|
|
|
|
|
|
|
|
inline int getGaussianBlurSize() const { return m_GaussianBlurSize; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setMorphSizeWidth(int param) { m_MorphSizeWidth = param; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline int getMorphSizeWidth() const { return m_MorphSizeWidth; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setMorphSizeHeight(int param) { m_MorphSizeHeight = param; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline int getMorphSizeHeight() const { return m_MorphSizeHeight; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setVerifyError(float param) { m_error = param; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline float getVerifyError() const { return m_error; }
|
|
|
|
|
|
|
|
|
|
|
|
inline void setMorphSizeWidth(int param){ m_MorphSizeWidth = param;}
|
|
|
|
inline void setVerifyAspect(float param) { m_aspect = param; }
|
|
|
|
inline int getMorphSizeWidth() const{ return m_MorphSizeWidth;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setMorphSizeHeight(int param){ m_MorphSizeHeight = param;}
|
|
|
|
inline float getVerifyAspect() const { return m_aspect; }
|
|
|
|
inline int getMorphSizeHeight() const{ return m_MorphSizeHeight;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setVerifyError(float param){ m_error = param;}
|
|
|
|
inline void setVerifyMin(int param) { m_verifyMin = param; }
|
|
|
|
inline float getVerifyError() const { return m_error;}
|
|
|
|
|
|
|
|
inline void setVerifyAspect(float param){ m_aspect = param;}
|
|
|
|
|
|
|
|
inline float getVerifyAspect() const { return m_aspect;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setVerifyMin(int param){ m_verifyMin = param;}
|
|
|
|
inline void setVerifyMax(int param) { m_verifyMax = param; }
|
|
|
|
inline void setVerifyMax(int param){ m_verifyMax = param;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline void setJudgeAngle(int param){ m_angle = param;}
|
|
|
|
inline void setJudgeAngle(int param) { m_angle = param; }
|
|
|
|
|
|
|
|
|
|
|
|
//! 是否开启调试模式
|
|
|
|
//! 是否开启调试模式
|
|
|
|
inline void setDebug(int param){ m_debug = param;}
|
|
|
|
inline void setDebug(int param) { m_debug = param; }
|
|
|
|
|
|
|
|
|
|
|
|
//! 获取调试模式状态
|
|
|
|
//! 获取调试模式状态
|
|
|
|
inline int getDebug(){ return m_debug;}
|
|
|
|
inline int getDebug() { return m_debug; }
|
|
|
|
|
|
|
|
|
|
|
|
//! PlateLocate所用常量
|
|
|
|
//! PlateLocate所用常量
|
|
|
|
static const int DEFAULT_GAUSSIANBLUR_SIZE = 5;
|
|
|
|
static const int DEFAULT_GAUSSIANBLUR_SIZE = 5;
|
|
|
@ -121,8 +148,9 @@ public:
|
|
|
|
static const int SOBEL_DELTA = 0;
|
|
|
|
static const int SOBEL_DELTA = 0;
|
|
|
|
static const int SOBEL_DDEPTH = CV_16S;
|
|
|
|
static const int SOBEL_DDEPTH = CV_16S;
|
|
|
|
static const int SOBEL_X_WEIGHT = 1;
|
|
|
|
static const int SOBEL_X_WEIGHT = 1;
|
|
|
|
static const int SOBEL_Y_WEIGHT = 0 ;
|
|
|
|
static const int SOBEL_Y_WEIGHT = 0;
|
|
|
|
static const int DEFAULT_MORPH_SIZE_WIDTH = 17;//17
|
|
|
|
static const int DEFAULT_MORPH_SIZE_WIDTH = 17;
|
|
|
|
|
|
|
|
//17
|
|
|
|
static const int DEFAULT_MORPH_SIZE_HEIGHT = 3;//3
|
|
|
|
static const int DEFAULT_MORPH_SIZE_HEIGHT = 3;//3
|
|
|
|
|
|
|
|
|
|
|
|
//! showResultMat所用常量
|
|
|
|
//! showResultMat所用常量
|
|
|
@ -131,7 +159,8 @@ public:
|
|
|
|
static const int TYPE = CV_8UC3;
|
|
|
|
static const int TYPE = CV_8UC3;
|
|
|
|
|
|
|
|
|
|
|
|
//! verifySize所用常量
|
|
|
|
//! verifySize所用常量
|
|
|
|
static const int DEFAULT_VERIFY_MIN = 1;//3
|
|
|
|
static const int DEFAULT_VERIFY_MIN = 1;
|
|
|
|
|
|
|
|
//3
|
|
|
|
static const int DEFAULT_VERIFY_MAX = 24;//20
|
|
|
|
static const int DEFAULT_VERIFY_MAX = 24;//20
|
|
|
|
|
|
|
|
|
|
|
|
//! 角度判断所用常量
|
|
|
|
//! 角度判断所用常量
|
|
|
@ -140,7 +169,7 @@ public:
|
|
|
|
//! 是否开启调试模式常量,默认0代表关闭
|
|
|
|
//! 是否开启调试模式常量,默认0代表关闭
|
|
|
|
static const int DEFAULT_DEBUG = 1;
|
|
|
|
static const int DEFAULT_DEBUG = 1;
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
//! 高斯模糊所用变量
|
|
|
|
//! 高斯模糊所用变量
|
|
|
|
int m_GaussianBlurSize;
|
|
|
|
int m_GaussianBlurSize;
|
|
|
|
|
|
|
|
|
|
|
@ -160,7 +189,7 @@ protected:
|
|
|
|
//! 是否开启调试模式,0关闭,非0开启
|
|
|
|
//! 是否开启调试模式,0关闭,非0开启
|
|
|
|
int m_debug;
|
|
|
|
int m_debug;
|
|
|
|
|
|
|
|
|
|
|
|
LabInfo * m_labItem;
|
|
|
|
LabInfo* m_labItem;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /*! \namespace easypr*/
|
|
|
|
} /*! \namespace easypr*/
|
|
|
|