parent
25adeea4ef
commit
b06fec5c4d
@ -1,35 +1,35 @@
|
||||
#ifndef __FEATURE_H__
|
||||
#define __FEATURE_H__
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
namespace easypr {
|
||||
|
||||
//! 获得车牌的特征数
|
||||
cv::Mat getTheFeatures(cv::Mat in);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 用于从车牌的image生成svm的训练特征features
|
||||
typedef void(*svmCallback)(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是生成直方图均衡特征的回调函数
|
||||
void getHisteqFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取垂直和水平的直方图图值
|
||||
void getHistogramFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取SIFT特征子
|
||||
void getSIFTFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取HOG特征子
|
||||
void getHOGFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取HSV空间量化的直方图特征子
|
||||
void getHSVHistFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif
|
||||
/* endif __FEATURE_H__ */
|
||||
#ifndef __FEATURE_H__
|
||||
#define __FEATURE_H__
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
namespace easypr {
|
||||
|
||||
//! 获得车牌的特征数
|
||||
cv::Mat getTheFeatures(cv::Mat in);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 用于从车牌的image生成svm的训练特征features
|
||||
typedef void(*svmCallback)(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是生成直方图均衡特征的回调函数
|
||||
void getHisteqFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取垂直和水平的直方图图值
|
||||
void getHistogramFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取SIFT特征子
|
||||
void getSIFTFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取HOG特征子
|
||||
void getHOGFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
//! 本函数是获取HSV空间量化的直方图特征子
|
||||
void getHSVHistFeatures(const cv::Mat& image, cv::Mat& features);
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif
|
||||
/* endif __FEATURE_H__ */
|
||||
@ -1,56 +1,56 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Name: plate Header
|
||||
// Version: 1.0
|
||||
// Date: 2015-03-12
|
||||
// Author: liuruoze
|
||||
// Copyright: liuruoze
|
||||
// Desciption:
|
||||
// An abstract class for car plate.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __PLATE_H__
|
||||
#define __PLATE_H__
|
||||
|
||||
#include "core_func.h"
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
class CPlate {
|
||||
public:
|
||||
bool bColored;
|
||||
|
||||
//! 构造函数
|
||||
CPlate();
|
||||
|
||||
//! 设置与读取变量
|
||||
inline void setPlateMat(Mat param) { m_plateMat = param; }
|
||||
inline Mat getPlateMat() const { return m_plateMat; }
|
||||
|
||||
inline void setPlatePos(RotatedRect param) { m_platePos = param; }
|
||||
inline RotatedRect getPlatePos() const { return m_platePos; }
|
||||
|
||||
inline void setPlateStr(String param) { m_plateStr = param; }
|
||||
inline String getPlateStr() const { return m_plateStr; }
|
||||
|
||||
inline void setPlateLocateType(LocateType param) { m_locateType = param; }
|
||||
inline LocateType getPlateLocateType() const { return m_locateType; }
|
||||
|
||||
private:
|
||||
//! 车牌的图块
|
||||
Mat m_plateMat;
|
||||
|
||||
//! 车牌在原图的位置
|
||||
RotatedRect m_platePos;
|
||||
|
||||
//! 车牌字符串
|
||||
String m_plateStr;
|
||||
|
||||
//! 车牌定位的方法
|
||||
LocateType m_locateType;
|
||||
};
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Name: plate Header
|
||||
// Version: 1.0
|
||||
// Date: 2015-03-12
|
||||
// Author: liuruoze
|
||||
// Copyright: liuruoze
|
||||
// Desciption:
|
||||
// An abstract class for car plate.
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __PLATE_H__
|
||||
#define __PLATE_H__
|
||||
|
||||
#include "core_func.h"
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
class CPlate {
|
||||
public:
|
||||
bool bColored;
|
||||
|
||||
//! 构造函数
|
||||
CPlate();
|
||||
|
||||
//! 设置与读取变量
|
||||
inline void setPlateMat(Mat param) { m_plateMat = param; }
|
||||
inline Mat getPlateMat() const { return m_plateMat; }
|
||||
|
||||
inline void setPlatePos(RotatedRect param) { m_platePos = param; }
|
||||
inline RotatedRect getPlatePos() const { return m_platePos; }
|
||||
|
||||
inline void setPlateStr(String param) { m_plateStr = param; }
|
||||
inline String getPlateStr() const { return m_plateStr; }
|
||||
|
||||
inline void setPlateLocateType(LocateType param) { m_locateType = param; }
|
||||
inline LocateType getPlateLocateType() const { return m_locateType; }
|
||||
|
||||
private:
|
||||
//! 车牌的图块
|
||||
Mat m_plateMat;
|
||||
|
||||
//! 车牌在原图的位置
|
||||
RotatedRect m_platePos;
|
||||
|
||||
//! 车牌字符串
|
||||
String m_plateStr;
|
||||
|
||||
//! 车牌定位的方法
|
||||
LocateType m_locateType;
|
||||
};
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif /* endif __PLATE_H__ */
|
||||
@ -1,65 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Name: plate_judge Header
|
||||
// Version: 1.1
|
||||
// Date: 2014-09-28
|
||||
// MDate: 2015-01-28
|
||||
// Author: liuruoze
|
||||
// Copyright: liuruoze
|
||||
// Reference: Mastering OpenCV with Practical Computer Vision Projects
|
||||
// Reference: CSDN Bloger taotao1233
|
||||
// Desciption:
|
||||
// Defines CPlateLocate
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef __PLATE_JUDGE_H__
|
||||
#define __PLATE_JUDGE_H__
|
||||
|
||||
#include "easypr/plate.h"
|
||||
#include "easypr/feature.h"
|
||||
#include "easypr/core_func.h"
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
class CPlateJudge {
|
||||
public:
|
||||
CPlateJudge();
|
||||
|
||||
//! 对多幅车牌进行SVM判断
|
||||
int plateJudge(const vector<CPlate>&, vector<CPlate>&);
|
||||
|
||||
//! 车牌判断
|
||||
int plateJudge(const vector<Mat>&, vector<Mat>&);
|
||||
|
||||
//! 车牌判断(一副图像)
|
||||
int plateJudge(const Mat& inMat, int& result);
|
||||
|
||||
//! 直方图均衡
|
||||
Mat histeq(Mat);
|
||||
|
||||
//! 装载SVM模型
|
||||
void LoadModel();
|
||||
|
||||
//! 装载SVM模型
|
||||
void LoadModel(string s);
|
||||
|
||||
//! 设置与读取模型路径
|
||||
inline void setModelPath(string path) { m_path = path; }
|
||||
inline string getModelPath() const { return m_path; }
|
||||
|
||||
private:
|
||||
//! 使用的SVM模型
|
||||
CvSVM svm;
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 用于从车牌的image生成svm的训练特征features
|
||||
svmCallback m_getFeatures;
|
||||
|
||||
//! 模型存储路径
|
||||
string m_path;
|
||||
};
|
||||
|
||||
} /*! \namespace easypr*/
|
||||
|
||||
#endif /* endif __PLATE_JUDGE_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,79 +1,79 @@
|
||||
// 这个文件定义了EasyPR里所有特征生成的函数
|
||||
// 所属命名空间为easypr
|
||||
// 这个部分中的特征由easypr的开发者修改
|
||||
|
||||
#include "easypr/core/feature.h"
|
||||
#include "easypr/core/core_func.h"
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
//! 获取垂直和水平的直方图图值
|
||||
Mat getTheFeatures(Mat in) {
|
||||
const int VERTICAL = 0;
|
||||
const int HORIZONTAL = 1;
|
||||
|
||||
// Histogram features
|
||||
Mat vhist = ProjectedHistogram(in, VERTICAL);
|
||||
Mat hhist = ProjectedHistogram(in, HORIZONTAL);
|
||||
|
||||
// Last 10 is the number of moments components
|
||||
int numCols = vhist.cols + hhist.cols;
|
||||
|
||||
Mat out = Mat::zeros(1, numCols, CV_32F);
|
||||
|
||||
// Asign values to feature,样本特征为水平、垂直直方图
|
||||
int j = 0;
|
||||
for (int i = 0; i < vhist.cols; i++) {
|
||||
out.at<float>(j) = vhist.at<float>(i);
|
||||
j++;
|
||||
}
|
||||
for (int i = 0; i < hhist.cols; i++) {
|
||||
out.at<float>(j) = hhist.at<float>(i);
|
||||
j++;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是生成直方图均衡特征的回调函数
|
||||
void getHisteqFeatures(const Mat& image, Mat& features) {
|
||||
features = histeq(image);
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取垂直和水平的直方图图值
|
||||
void getHistogramFeatures(const Mat& image, Mat& features) {
|
||||
Mat grayImage;
|
||||
cvtColor(image, grayImage, CV_RGB2GRAY);
|
||||
|
||||
// grayImage = histeq(grayImage);
|
||||
|
||||
Mat img_threshold;
|
||||
threshold(grayImage, img_threshold, 0, 255,
|
||||
CV_THRESH_OTSU + CV_THRESH_BINARY);
|
||||
features = getTheFeatures(img_threshold);
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取SITF特征子
|
||||
void getSIFTFeatures(const Mat& image, Mat& features) {
|
||||
//待完善
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取HOG特征子
|
||||
void getHOGFeatures(const Mat& image, Mat& features) {
|
||||
//待完善
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取HSV空间量化的直方图特征子
|
||||
void getHSVHistFeatures(const Mat& image, Mat& features) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// 这个文件定义了EasyPR里所有特征生成的函数
|
||||
// 所属命名空间为easypr
|
||||
// 这个部分中的特征由easypr的开发者修改
|
||||
|
||||
#include "easypr/core/feature.h"
|
||||
#include "easypr/core/core_func.h"
|
||||
|
||||
/*! \namespace easypr
|
||||
Namespace where all the C++ EasyPR functionality resides
|
||||
*/
|
||||
namespace easypr {
|
||||
|
||||
//! 获取垂直和水平的直方图图值
|
||||
Mat getTheFeatures(Mat in) {
|
||||
const int VERTICAL = 0;
|
||||
const int HORIZONTAL = 1;
|
||||
|
||||
// Histogram features
|
||||
Mat vhist = ProjectedHistogram(in, VERTICAL);
|
||||
Mat hhist = ProjectedHistogram(in, HORIZONTAL);
|
||||
|
||||
// Last 10 is the number of moments components
|
||||
int numCols = vhist.cols + hhist.cols;
|
||||
|
||||
Mat out = Mat::zeros(1, numCols, CV_32F);
|
||||
|
||||
// Asign values to feature,样本特征为水平、垂直直方图
|
||||
int j = 0;
|
||||
for (int i = 0; i < vhist.cols; i++) {
|
||||
out.at<float>(j) = vhist.at<float>(i);
|
||||
j++;
|
||||
}
|
||||
for (int i = 0; i < hhist.cols; i++) {
|
||||
out.at<float>(j) = hhist.at<float>(i);
|
||||
j++;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是生成直方图均衡特征的回调函数
|
||||
void getHisteqFeatures(const Mat& image, Mat& features) {
|
||||
features = histeq(image);
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取垂直和水平的直方图图值
|
||||
void getHistogramFeatures(const Mat& image, Mat& features) {
|
||||
Mat grayImage;
|
||||
cvtColor(image, grayImage, CV_RGB2GRAY);
|
||||
|
||||
// grayImage = histeq(grayImage);
|
||||
|
||||
Mat img_threshold;
|
||||
threshold(grayImage, img_threshold, 0, 255,
|
||||
CV_THRESH_OTSU + CV_THRESH_BINARY);
|
||||
features = getTheFeatures(img_threshold);
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取SITF特征子
|
||||
void getSIFTFeatures(const Mat& image, Mat& features) {
|
||||
//待完善
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取HOG特征子
|
||||
void getHOGFeatures(const Mat& image, Mat& features) {
|
||||
//待完善
|
||||
}
|
||||
|
||||
//! EasyPR的getFeatures回调函数
|
||||
//! 本函数是获取HSV空间量化的直方图特征子
|
||||
void getHSVHistFeatures(const Mat& image, Mat& features) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} /* \namespace easypr */
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue