Skip to content

Commit

Permalink
Merge branch 'Micooz-master-gbk'
Browse files Browse the repository at this point in the history
  • Loading branch information
liuruoze committed Mar 25, 2015
2 parents 98d9443 + fb4b399 commit 84b92b8
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 92 deletions.
95 changes: 50 additions & 45 deletions src/core/chars_recognise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,53 @@
/*! \namespace easypr
Namespace where all the C++ EasyPR functionality resides
*/
namespace easypr{

CCharsRecognise::CCharsRecognise()
{
//cout << "CCharsRecognise" << endl;
m_charsSegment = new CCharsSegment();
m_charsIdentify = new CCharsIdentify();
}

void CCharsRecognise::LoadANN(string s)
{
m_charsIdentify->LoadModel(s.c_str());
}

int CCharsRecognise::charsRecognise(Mat plate, string& plateLicense)
{
//车牌字符方块集合
vector<Mat> matVec;

string plateIdentify = "";

int result = m_charsSegment->charsSegment(plate, matVec);
if (result == 0)
{
int num = matVec.size();
for (int j = 0; j < num; j++)
{
Mat charMat = matVec[j];
bool isChinses = false;

//默认首个字符块是中文字符
if (j == 0)
isChinses = true;

string charcater = m_charsIdentify->charsIdentify(charMat, isChinses);
plateIdentify = plateIdentify + charcater;
}
}

plateLicense = plateIdentify;

return 0;
}

} /*! \namespace easypr*/
namespace easypr {

CCharsRecognise::CCharsRecognise()
: m_charsSegment(nullptr), m_charsIdentify(nullptr) {
m_charsSegment = new CCharsSegment();
m_charsIdentify = new CCharsIdentify();
}

CCharsRecognise::~CCharsRecognise() {
if (m_charsSegment) {
delete m_charsSegment;
m_charsSegment = nullptr;
}
if (m_charsIdentify) {
delete m_charsIdentify;
m_charsIdentify = nullptr;
}
}

void CCharsRecognise::LoadANN(string s) {
m_charsIdentify->LoadModel(s.c_str());
}

int CCharsRecognise::charsRecognise(Mat plate, string& plateLicense) {
//车牌字符方块集合
vector<Mat> matVec;

string plateIdentify = "";

int result = m_charsSegment->charsSegment(plate, matVec);
if (result == 0) {
int num = matVec.size();
for (int j = 0; j < num; j++) {
Mat charMat = matVec[j];
bool isChinses = false;

//默认首个字符块是中文字符
if (j == 0) isChinses = true;

string charcater = m_charsIdentify->charsIdentify(charMat, isChinses);
plateIdentify = plateIdentify + charcater;
}
}

plateLicense = plateIdentify;

return 0;
}

} /*! \namespace easypr*/
108 changes: 61 additions & 47 deletions src/include/chars_recognise.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,66 @@ Namespace where all the C++ EasyPR functionality resides
*/
namespace easypr {

class CCharsRecognise
{
public:
CCharsRecognise();

//! 字符分割与识别
int charsRecognise(Mat, String&);

//! 装载ANN模型
void LoadANN(string s);

//! 是否开启调试模式
inline void setCRDebug(int param){ m_charsSegment->setDebug(param); }

//! 获取调试模式状态
inline int getCRDebug(){ return m_charsSegment->getDebug(); }


//! 获得车牌颜色
inline string getPlateColor(Mat input) const
{
string color = "未知";
Color result = getPlateType(input, true);
if (BLUE == result)
color = "蓝牌";
if (YELLOW == result)
color = "黄牌";
return color;
}

//! 设置变量
inline void setLiuDingSize(int param){ m_charsSegment->setLiuDingSize(param); }
inline void setColorThreshold(int param){ m_charsSegment->setColorThreshold(param); }
inline void setBluePercent(float param){ m_charsSegment->setBluePercent(param); }
inline float getBluePercent() const { return m_charsSegment->getBluePercent(); }
inline void setWhitePercent(float param){ m_charsSegment->setWhitePercent(param); }
inline float getWhitePercent() const { return m_charsSegment->getWhitePercent(); }

private:
//!字符分割
CCharsSegment* m_charsSegment;

//! 字符识别
CCharsIdentify* m_charsIdentify;
};

} /* \namespace easypr */
class CCharsRecognise {
public:
CCharsRecognise();

~CCharsRecognise();

//! 字符分割与识别
int charsRecognise(Mat, String&);

//! 装载ANN模型
void LoadANN(string s);

//! 是否开启调试模式
inline void setCRDebug(int param) { m_charsSegment->setDebug(param); }

//! 获取调试模式状态
inline int getCRDebug() { return m_charsSegment->getDebug(); }

//! 获得车牌颜色
inline string getPlateColor(Mat input) const {
string color = "未知";
Color result = getPlateType(input, true);
if (BLUE == result) color = "蓝牌";
if (YELLOW == result) color = "黄牌";
return color;
}

//! 设置变量
inline void setLiuDingSize(int param) {
m_charsSegment->setLiuDingSize(param);
}

inline void setColorThreshold(int param) {
m_charsSegment->setColorThreshold(param);
}

inline void setBluePercent(float param) {
m_charsSegment->setBluePercent(param);
}

inline float getBluePercent() const {
return m_charsSegment->getBluePercent();
}

inline void setWhitePercent(float param) {
m_charsSegment->setWhitePercent(param);
}

inline float getWhitePercent() const {
return m_charsSegment->getWhitePercent();
}

private:
//!字符分割
CCharsSegment* m_charsSegment;

//! 字符识别
CCharsIdentify* m_charsIdentify;
};

} /* \namespace easypr */

#endif /* endif __CHARS_RECOGNISE_H__ */

0 comments on commit 84b92b8

Please sign in to comment.