Merge branch '1.3ver'

Conflicts:
	run_accuracy.txt
1.3
liuruoze 10 years ago
commit 33c6a23871

@ -70,36 +70,30 @@ int CPlateDetect::plateDetectDeep(Mat src, vector<CPlate>& resultVec, bool showD
const int color_find_max = m_maxPlates;
m_plateLocate->plateColorLocate(src, color_Plates, index);
//m_plateJudge->plateJudge(color_Plates, color_result_Plates);
//下面代码是sunjunlishi添加
for (int i=0;i<color_Plates.size();++i)
{
//暂时屏蔽车牌的判断,车牌判断采用 字符跳变的方式判断
//字符跳变的形式 | | | | | | |,根据跳变的规律直接判断车牌,更准,效率更高
//当然判断跳变用的还是原始代码,在后面我加上了主食
color_result_Plates.push_back(color_Plates[i]);
}
m_plateJudge->plateJudge(color_Plates, color_result_Plates);
//for (int i=0;i<color_Plates.size();++i)
//{
// color_result_Plates.push_back(color_Plates[i]);
//}
for (int i = 0; i< color_result_Plates.size(); i++)
{
CPlate plate = color_result_Plates[i];
plate.setPlateLocateType(COLOR);
all_result_Plates.push_back(plate);
}
//颜色和边界闭操作同时采用
{
m_plateLocate->plateSobelLocate(src, sobel_Plates, index);
//m_plateJudge->plateJudge(sobel_Plates, sobel_result_Plates);
m_plateJudge->plateJudge(sobel_Plates, sobel_result_Plates);
//下面代码是sunjunlishi添加
for (int i=0;i<sobel_Plates.size();++i)
/*for (int i=0;i<sobel_Plates.size();++i)
{
//暂时屏蔽车牌的判断,车牌判断采用 字符跳变的方式判断
//字符跳变的形式 | | | | | | |,根据跳变的规律直接判断车牌,更准,效率更高
//当然判断跳变用的还是原始代码,在后面我加上了主食
sobel_result_Plates.push_back(sobel_Plates[i]);
}
}*/
for (int i = 0; i< sobel_result_Plates.size(); i++)
{
@ -113,6 +107,7 @@ int CPlateDetect::plateDetectDeep(Mat src, vector<CPlate>& resultVec, bool showD
}
plate.bColored = false;
plate.setPlateLocateType(SOBEL);
all_result_Plates.push_back(plate);
}
@ -131,8 +126,8 @@ int CPlateDetect::showResult(const Mat& result)
{
namedWindow("EasyPR", CV_WINDOW_AUTOSIZE);
const int RESULTWIDTH = 930; //640 930
const int RESULTHEIGHT = 710; //540 710
const int RESULTWIDTH = 640; //640 930
const int RESULTHEIGHT = 540; //540 710
Mat img_window;
img_window.create(RESULTHEIGHT, RESULTWIDTH, CV_8UC3);

@ -12,51 +12,21 @@ CPlateRecognize::CPlateRecognize()
//m_charsRecognise = new CCharsRecognise();
}
////! 装载SVM模型
//void CPlateRecognize::LoadSVM(string strSVM)
//{
// m_plateDetect->LoadModel(strSVM.c_str());
//}
//
////! 装载ANN模型
//void CPlateRecognize::LoadANN(string strANN)
//{
// m_charsRecognise->LoadModel(strANN.c_str());
//}
//
//int CPlateRecognize::plateDetect(Mat src, vector<Mat>& resultVec)
//{
// int result = m_plateDetect->plateDetect(src, resultVec);
// return result;
//}
//
//int CPlateRecognize::charsRecognise(Mat plate, string& plateLicense)
//{
// int result = m_charsRecognise->charsRecognise(plate, plateLicense);
// return result;
//}
// !车牌识别模块
int CPlateRecognize::plateRecognize(Mat src, vector<string>& licenseVec, int index)
{
// 车牌方块集合
vector<CPlate> plateVec;
// 如果设置了Debug模式就依次显示所有的图片
bool showDetectArea = getPDDebug();
// 进行深度定位使用颜色信息与二次Sobel
int resultPD = plateDetectDeep(src, plateVec, showDetectArea, 0);
Mat result;
src.copyTo(result);
int resultPD = plateDetectDeep(src, plateVec, getPDDebug(), 0);
if (resultPD == 0)
{
int num = plateVec.size();
int index = 0;
//依次识别每个车牌内的符号
for (int j = 0; j < num; j++)
{
CPlate item = plateVec[j];
@ -72,36 +42,51 @@ int CPlateRecognize::plateRecognize(Mat src, vector<string>& licenseVec, int ind
{
string license = plateType + ":" + plateIdentify;
licenseVec.push_back(license);
}
}
//完整识别过程到此结束
//如果是Debug模式则还需要将定位的图片显示在原图左上角
if (getPDDebug() == true)
{
Mat result;
src.copyTo(result);
for (int j = 0; j < num; j++)
{
CPlate item = plateVec[j];
Mat plate = item.getPlateMat();
/*int height = 36;
int height = 36;
int width = 136;
if(height*index + height < result.rows)
if( height*index + height < result.rows )
{
Mat imageRoi = result(Rect(0, 0 + height*index, width, height));
addWeighted(imageRoi, 0, plate, 1, 0, imageRoi);
addWeighted(imageRoi, 0, plate, 1, 0, imageRoi);
}
index++;*/
index++;
RotatedRect minRect = item.getPlatePos();
Point2f rect_points[4];
minRect.points( rect_points );
Point2f rect_points[4];
minRect.points(rect_points);
if(item.bColored)
{
for (int j = 0; j < 4; j++)
line(result, rect_points[j], rect_points[(j + 1) % 4], Scalar(255, 255, 0), 2, 8);
}
else
{
for( int j = 0; j < 4; j++ )
line(result, rect_points[j], rect_points[(j+1)%4], Scalar(0,0,255), 2, 8 );//sobel定位车牌红色方框
}
Scalar lineColor = Scalar(255, 255, 255);
if (item.getPlateLocateType() == SOBEL)
lineColor = Scalar(255, 0, 0);
if (item.getPlateLocateType() == COLOR)
lineColor = Scalar(0, 255, 0);
for (int j = 0; j < 4; j++)
line(result, rect_points[j], rect_points[(j + 1) % 4], lineColor, 2, 8);
}
}
}
if (showDetectArea)
showResult(result);
//显示定位框的图片
showResult(result);
}
}
return resultPD;
}

@ -41,7 +41,6 @@ namespace easypr {
//! »ñÈ¡µ÷ÊÔģʽ״̬
inline int getCRDebug(){ return m_charsSegment->getDebug(); }
//! »ñµÃ³µÅÆÑÕÉ«
inline string getPlateColor(Mat input) const
{

@ -8,6 +8,8 @@ namespace easypr {
enum Color{ BLUE, YELLOW, WHITE, UNKNOWN};
enum LocateType { SOBEL, COLOR, OTHER };
//! 根据一幅图像与颜色模板获取对应的二值图
//! 输入RGB图像, 颜色模板(蓝色、黄色)
//! 输出灰度图只有0和255两个值255代表匹配0代表不匹配

@ -11,6 +11,7 @@
#define __PLATE_H__
#include "prep.h"
#include "core_func.h"
/*! \namespace easypr
Namespace where all the C++ EasyPR functionality resides
@ -35,6 +36,9 @@ namespace easypr {
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;
@ -44,6 +48,9 @@ namespace easypr {
//! 车牌字符串
String m_plateStr;
//! 车牌定位的方法
LocateType m_locateType;
};
} /*! \namespace easypr*/

@ -29,8 +29,6 @@ class CPlateLocate
public:
CPlateLocate();
enum LocateType { SOBEL, COLOR };
//! Sobel第一次搜索
//! 不限制大小和形状获取的BoundRect进入下一步
int sobelFrtSearch(const Mat& src, vector<Rect_<float>>& outRects);

@ -7,30 +7,27 @@
using namespace easypr;
int acurayTest(const string& test_path) {
////获取该路径下的所有文件
int acurayTest(const string& test_path)
{
auto files = Utils::getFiles(test_path);
// CPlateLocate lo;
// CPlateJudge ju;
CPlateRecognize pr;
pr.LoadANN("model/ann.xml");
pr.LoadSVM("model/svm.xml");
pr.setLifemode(true);
// ÉèÖÃDebugģʽ
pr.setDebug(false);
pr.setLifemode(true);
// 设置要处理的一张图片中最多有多少车牌
pr.setMaxPlates(4);
// CPlateDetect pd;
// pd.LoadSVM("model/svm.xml");
// pd.setPDLifemode(true);
int size = files.size();
// int size = 200;
if (0 == size) {
if (0 == size)
{
cout << "No File Found in general_test/native_test!" << endl;
return 0;
}

Loading…
Cancel
Save