Fixed compile errors.

v1.6alpha
Micooz 11 years ago
parent 25adeea4ef
commit b06fec5c4d

@ -1,63 +0,0 @@
//////////////////////////////////////////////////////////////////////////
// Name: chars_identify Header
// Version: 1.0
// Date: 2014-09-25
// Author: liuruoze
// Copyright: liuruoze
// Reference: Mastering OpenCV with Practical Computer Vision Projects
// Reference: CSDN Bloger taotao1233
// Desciption:
// Defines CCharsIdentify
//////////////////////////////////////////////////////////////////////////
#ifndef __CHARS_IDENTIFY_H__
#define __CHARS_IDENTIFY_H__
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
/*! \namespace easypr
Namespace where all the C++ EasyPR functionality resides
*/
namespace easypr {
class CCharsIdentify {
public:
CCharsIdentify();
//! 字符分割
string charsIdentify(Mat, bool, bool);
string charsIdentify(Mat input);
//! 字符分类
int classify(Mat, bool, bool);
int classify(Mat f);
//! 装载ANN模型
void LoadModel();
//! 装载ANN模型
void LoadModel(string s);
//! 设置与读取模型路径
inline void setModelPath(string path) { m_path = path; }
inline string getModelPath() const { return m_path; }
private:
//使用的ANN模型
CvANN_MLP ann;
//! 模型存储路径
string m_path;
//! 特征尺寸
int m_predictSize;
//! 省份对应map
std::map<string, string> m_map;
};
} /* \namespace easypr */
#endif /* endif __CHARS_IDENTIFY_H__ */

@ -55,7 +55,7 @@ static const std::map<const char*, const char*> kCharsMap = {
static const int kCharsTotalNumber = 65;
static bool debug = false;
static bool kDebug = false;
}

@ -12,7 +12,7 @@
#ifndef __CHARS_SEGMENT_H__
#define __CHARS_SEGMENT_H__
#include "core_func.h"
#include "easypr/core/core_func.h"
/*! \namespace easypr
Namespace where all the C++ EasyPR functionality resides
@ -24,7 +24,7 @@ class CCharsSegment {
CCharsSegment();
//! 字符分割
int charsSegment(Mat, std::vector<Mat>&);
int charsSegment(Mat input, std::vector<Mat>& resultVec);
//! 字符尺寸验证
bool verifyCharSizes(Mat r);

@ -1,56 +1,56 @@
#ifndef __CORE_FUNC_H__
#define __CORE_FUNC_H__
#include <opencv2/opencv.hpp>
using namespace cv;
/*! \namespace easypr
Namespace where all the C++ EasyPR functionality resides
*/
namespace easypr {
enum Color { BLUE, YELLOW, WHITE, UNKNOWN };
enum LocateType { SOBEL, COLOR, OTHER };
//! 根据一幅图像与颜色模板获取对应的二值图
//! 输入RGB图像, 颜色模板(蓝色、黄色)
//! 输出灰度图只有0和255两个值255代表匹配0代表不匹配
Mat colorMatch(const Mat& src, Mat& match, const Color r,
const bool adaptive_minsv);
//! 判断一个车牌的颜色
//! 输入车牌mat与颜色模板
//! 返回true或fasle
bool plateColorJudge(const Mat& src, const Color r, const bool adaptive_minsv,
float& percent);
bool bFindLeftRightBound(Mat& bound_threshold, int& posLeft, int& posRight);
bool bFindLeftRightBound1(Mat& bound_threshold, int& posLeft, int& posRight);
bool bFindLeftRightBound2(Mat& bound_threshold, int& posLeft, int& posRight);
//去除车牌上方的钮钉
//计算每行元素的阶跃数如果小于X认为是柳丁将此行全部填0涂黑
// X的推荐值为可根据实际调整
bool clearLiuDing(Mat& img);
void clearLiuDingOnly(Mat& img);
void clearLiuDing(Mat mask, int& top, int& bottom);
//! 获得车牌颜色
Color getPlateType(const Mat& src, const bool adaptive_minsv);
//! 直方图均衡
Mat histeq(Mat in);
Mat features(Mat in, int sizeData);
Rect GetCenterRect(Mat& in);
Mat CutTheRect(Mat& in, Rect& rect);
int ThresholdOtsu(Mat mat);
//! 获取垂直和水平方向直方图
Mat ProjectedHistogram(Mat img, int t);
} /*! \namespace easypr*/
#endif
#ifndef __CORE_FUNC_H__
#define __CORE_FUNC_H__
#include <opencv2/opencv.hpp>
using namespace cv;
/*! \namespace easypr
Namespace where all the C++ EasyPR functionality resides
*/
namespace easypr {
enum Color { BLUE, YELLOW, WHITE, UNKNOWN };
enum LocateType { SOBEL, COLOR, OTHER };
//! 根据一幅图像与颜色模板获取对应的二值图
//! 输入RGB图像, 颜色模板(蓝色、黄色)
//! 输出灰度图只有0和255两个值255代表匹配0代表不匹配
Mat colorMatch(const Mat& src, Mat& match, const Color r,
const bool adaptive_minsv);
//! 判断一个车牌的颜色
//! 输入车牌mat与颜色模板
//! 返回true或fasle
bool plateColorJudge(const Mat& src, const Color r, const bool adaptive_minsv,
float& percent);
bool bFindLeftRightBound(Mat& bound_threshold, int& posLeft, int& posRight);
bool bFindLeftRightBound1(Mat& bound_threshold, int& posLeft, int& posRight);
bool bFindLeftRightBound2(Mat& bound_threshold, int& posLeft, int& posRight);
//去除车牌上方的钮钉
//计算每行元素的阶跃数如果小于X认为是柳丁将此行全部填0涂黑
// X的推荐值为可根据实际调整
bool clearLiuDing(Mat& img);
void clearLiuDingOnly(Mat& img);
void clearLiuDing(Mat mask, int& top, int& bottom);
//! 获得车牌颜色
Color getPlateType(const Mat& src, const bool adaptive_minsv);
//! 直方图均衡
Mat histeq(Mat in);
Mat features(Mat in, int sizeData);
Rect GetCenterRect(Mat& in);
Mat CutTheRect(Mat& in, Rect& rect);
int ThresholdOtsu(Mat mat);
//! 获取垂直和水平方向直方图
Mat ProjectedHistogram(Mat img, int t);
} /*! \namespace easypr*/
#endif
/* endif __CORE_FUNC_H__ */

@ -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__ */

@ -9,7 +9,7 @@ namespace easypr {
class PlateJudge {
public:
static PlateJudge* instance();
static PlateJudge* instance();
//! 对多幅车牌进行SVM判断
int plateJudge(const std::vector<CPlate>&, std::vector<CPlate>&);

@ -25,7 +25,7 @@ class CPlateRecognize : public CPlateDetect, public CCharsRecognise {
CPlateRecognize();
//! 车牌检测与字符识别
int plateRecognize(cv::Mat src, std::vector<std::string>& licenseVec, int index = 0);
int plateRecognize(Mat src, std::vector<std::string> &licenseVec);
//! 生活模式与工业模式切换
inline void setLifemode(bool param) { CPlateDetect::setPDLifemode(param); }

@ -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__ */

@ -1,23 +1,23 @@
// 生成GDTS的文件
// 在捐赠数据到GDTS数据集里请先用这里的方法对图像进行预处理
// EasyPR开源项目非常注重保护原始图片的版权
// 所有的捐赠数据通过GDSL协议进行约定保证使用人仅用于非商业性目的
#ifndef EASYPR_GDTS_H
#define EASYPR_GDTS_H
#include <opencv2/opencv.hpp>
namespace easypr {
namespace preprocess {
// EasyPR的图像预处理函数进行模糊化与裁剪化处理
cv::Mat imageProcess(cv::Mat src);
int generate_gdts();
}
}
#endif //EASYPR_GDTS_H
// 生成GDTS的文件
// 在捐赠数据到GDTS数据集里请先用这里的方法对图像进行预处理
// EasyPR开源项目非常注重保护原始图片的版权
// 所有的捐赠数据通过GDSL协议进行约定保证使用人仅用于非商业性目的
#ifndef EASYPR_GDTS_H
#define EASYPR_GDTS_H
#include <opencv2/opencv.hpp>
namespace easypr {
namespace preprocess {
// EasyPR的图像预处理函数进行模糊化与裁剪化处理
cv::Mat imageProcess(cv::Mat src);
int generate_gdts();
}
}
#endif //EASYPR_GDTS_H

@ -73,7 +73,7 @@ Mat CCharsSegment::preprocessChar(Mat in) {
//! 字符分割与排序
int CCharsSegment::charsSegment(Mat input, vector<Mat>& resultVec, int index) {
int CCharsSegment::charsSegment(Mat input, vector<Mat>& resultVec) {
if (!input.data) return 0x01;
@ -133,25 +133,12 @@ int CCharsSegment::charsSegment(Mat input, vector<Mat>& resultVec, int index) {
destroyWindow("threshold");
}
if (m_debug) {
stringstream ss(stringstream::in | stringstream::out);
ss << "resources/image/tmp/debug_char_threshold_" << index << ".jpg";
utils::imwrite(ss.str(), img_threshold);
}
// 去除车牌上方的柳钉以及下方的横线等干扰
// 并且也判断了是否是车牌
// 并且在此对字符的跳变次数以及字符颜色所占的比重做了是否是车牌的判别条件
// 如果不是车牌返回ErrorCode=0x02
if (!clearLiuDing(img_threshold)) return 0x02;
if (m_debug) {
stringstream ss(stringstream::in | stringstream::out);
ss << "resources/image/tmp/debug_char_clearLiuDing_" << index << ".jpg";
utils::imwrite(ss.str(), img_threshold);
}
// 在二值化图像中提取轮廓
Mat img_contours;
img_threshold.copyTo(img_contours);
@ -187,16 +174,6 @@ int CCharsSegment::charsSegment(Mat input, vector<Mat>& resultVec, int index) {
// 获得特殊字符对应的Rectt,如苏A的"A"
specIndex = GetSpecificRect(sortedRect);
if (m_debug) {
if (specIndex < sortedRect.size()) {
Mat specMat(img_threshold, sortedRect[specIndex]);
stringstream ss(stringstream::in | stringstream::out);
ss << "resources/image/tmp/debug_specMat_" << index
<< ".jpg";
utils::imwrite(ss.str(), specMat);
}
}
// 根据特定Rect向左反推出中文字符
// 这样做的主要原因是根据findContours方法很难捕捉到中文字符的准确Rect因此仅能
// 退过特定算法来指定
@ -206,14 +183,6 @@ int CCharsSegment::charsSegment(Mat input, vector<Mat>& resultVec, int index) {
else
return 0x04;
if (m_debug) {
Mat chineseMat(img_threshold, chineseRect);
stringstream ss(stringstream::in | stringstream::out);
ss << "resources/image/tmp/debug_chineseMat_" << index
<< ".jpg";
utils::imwrite(ss.str(), chineseMat);
}
//新建一个全新的排序Rect
//将中文字符Rect第一个加进来因为它肯定是最左边的
//其余的Rect只按照顺序去6个车牌只可能是7个字符这样可以避免阴影导致的“1”字符
@ -257,14 +226,6 @@ int CCharsSegment::charsSegment(Mat input, vector<Mat>& resultVec, int index) {
// 归一化大小
newRoi = preprocessChar(newRoi);
// 假设我们要重新训练ANN模型在这里需要把训练样板输出
if (i == 0) {
stringstream ss(stringstream::in | stringstream::out);
ss << "resources/image/tmp/debug_char_auxRoi_" << index << "_" << (i)
<< ".jpg";
utils::imwrite(ss.str(), newRoi);
}
// 每个字符图块输入到下面的步骤进行处理
resultVec.push_back(newRoi);
}

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 */

@ -1,4 +1,5 @@
#include "easypr/core/plate_recognize.h"
#include "easypr/config.h"
namespace easypr {
@ -12,7 +13,7 @@ int CPlateRecognize::plateRecognize(Mat src, std::vector<std::string> &licenseVe
std::vector<CPlate> plateVec;
// 进行深度定位使用颜色信息与二次Sobel
int resultPD = plateDetect(src, plateVec, getPDDebug(), 0);
int resultPD = plateDetect(src, plateVec, kDebug, 0);
if (resultPD == 0) {
size_t num = plateVec.size();

@ -1,78 +1,77 @@
#include "easypr/preprocess/gdts.h"
#include "easypr/preprocess/deface.h"
#include "easypr/util/util.h"
namespace easypr {
namespace preprocess {
// TODO 将下面的路径改成你的原始图片路径
// 图片不要多10-30张就足够了EasyPR对GDTS数据集的使用不以量为主要指标
// 只要这些图片足够反映你数据集的主要特征即可
const char* src_path = "F:/data/easypr-data/tmp-1";
// TODO 将下面的路径改成你希望生成捐赠给GDTS数据存放的新路径
const char* dst_path = "F:/data/easypr-data/tmp-2";
int generate_gdts() {
// 获取人脸识别文件
cv::CascadeClassifier cascade;
std::string cascadeName = "resources/model/haarcascade_frontalface_alt_tree.xml";
////获取该路径下的所有文件
auto files = Utils::getFiles(src_path);
size_t size = files.size();
if (0 == size) {
std::cout << "No File Found!" << std::endl;
return 0;
}
std::cout << "Begin to prepare generate_gdts!" << std::endl;
for (size_t i = 0; i < size; i++) {
std::string filepath = files[i].c_str();
std::cout << "------------------" << std::endl;
std::cout << filepath << std::endl;
// EasyPR读取原图片
cv::Mat src = cv::imread(filepath);
// EasyPR开始对图片进行模糊化与裁剪化处理
cv::Mat img = imageProcess(src);
// EasyPR开始对图片进行人脸识别处理
cv::Mat dst = detectAndMaskFace(img, cascade, 1.5);
// 将图片导出到新路径
std::vector<std::string> spilt_path = Utils::splitString(filepath, '\\');
size_t spiltsize = spilt_path.size();
std::string filename = "";
if (spiltsize != 0)
filename = spilt_path[spiltsize - 1];
std::stringstream ss(std::stringstream::in | std::stringstream::out);
ss << dst_path << "/" << filename;
utils::imwrite(ss.str(), dst);
}
return 0;
}
// EasyPR的图像预处理函数进行模糊化与裁剪化处理
cv::Mat imageProcess(cv::Mat img) {
int width = img.size().width;
int height = img.size().height;
cv::Rect_<double> rect(width * 0.01, height * 0.01, width * 0.99, height * 0.99);
cv::Mat dst = img(rect);
//GaussianBlur( dst, dst, Size(1, 1), 0, 0, BORDER_DEFAULT );
return dst;
}
}
}
#include "easypr/preprocess/gdts.h"
#include "easypr/preprocess/deface.h"
#include "easypr/util/util.h"
namespace easypr {
namespace preprocess {
// TODO 将下面的路径改成你的原始图片路径
// 图片不要多10-30张就足够了EasyPR对GDTS数据集的使用不以量为主要指标
// 只要这些图片足够反映你数据集的主要特征即可
const char* src_path = "F:/data/easypr-data/tmp-1";
// TODO 将下面的路径改成你希望生成捐赠给GDTS数据存放的新路径
const char* dst_path = "F:/data/easypr-data/tmp-2";
int generate_gdts() {
// 获取人脸识别文件
cv::CascadeClassifier cascade;
std::string cascadeName = "resources/model/haarcascade_frontalface_alt_tree.xml";
////获取该路径下的所有文件
auto files = Utils::getFiles(src_path);
size_t size = files.size();
if (0 == size) {
std::cout << "No File Found!" << std::endl;
return 0;
}
std::cout << "Begin to prepare generate_gdts!" << std::endl;
for (size_t i = 0; i < size; i++) {
std::string filepath = files[i].c_str();
std::cout << "------------------" << std::endl;
std::cout << filepath << std::endl;
// EasyPR读取原图片
cv::Mat src = cv::imread(filepath);
// EasyPR开始对图片进行模糊化与裁剪化处理
cv::Mat img = imageProcess(src);
// EasyPR开始对图片进行人脸识别处理
cv::Mat dst = detectAndMaskFace(img, cascade, 1.5);
// 将图片导出到新路径
std::vector<std::string> spilt_path = Utils::splitString(filepath, '\\');
size_t spiltsize = spilt_path.size();
std::string filename = "";
if (spiltsize != 0)
filename = spilt_path[spiltsize - 1];
std::stringstream ss(std::stringstream::in | std::stringstream::out);
ss << dst_path << "/" << filename;
utils::imwrite(ss.str(), dst);
}
return 0;
}
// EasyPR的图像预处理函数进行模糊化与裁剪化处理
cv::Mat imageProcess(cv::Mat img) {
int width = img.size().width;
int height = img.size().height;
cv::Rect_<double> rect(width * 0.01, height * 0.01, width * 0.99, height * 0.99);
cv::Mat dst = img(rect);
//GaussianBlur( dst, dst, Size(1, 1), 0, 0, BORDER_DEFAULT );
return dst;
}
}
}

File diff suppressed because it is too large Load Diff

@ -72,7 +72,7 @@ int accuracyTest(const char* test_path) {
cout << "Ô­ÅÆ:" << plateLicense << endl;
vector<string> plateVec;
int result = pr.plateRecognize(src, plateVec, i);
int result = pr.plateRecognize(src, plateVec);
if (result == 0) {
int num = plateVec.size();

Loading…
Cancel
Save