|
|
@ -2,8 +2,17 @@
|
|
|
|
#ifndef __UTIL_H__
|
|
|
|
#ifndef __UTIL_H__
|
|
|
|
#define __UTIL_H__
|
|
|
|
#define __UTIL_H__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace easypr {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Utils {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static long getTimestamp();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//C++的获取文件夹函数
|
|
|
|
//C++的获取文件夹函数
|
|
|
|
void getFiles(string path, vector<string>& files);
|
|
|
|
void getFiles(std::string path, std::vector<std::string>& files);
|
|
|
|
|
|
|
|
|
|
|
|
//Linux下的GetTickCount函数
|
|
|
|
//Linux下的GetTickCount函数
|
|
|
|
#if defined (linux) || defined (__linux__)
|
|
|
|
#if defined (linux) || defined (__linux__)
|
|
|
@ -11,24 +20,24 @@ double GetTickCount();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//C++的spilt函数
|
|
|
|
//C++的spilt函数
|
|
|
|
void SplitString(const string& s, vector<string>& v, const string& c);
|
|
|
|
void SplitString(const std::string& s, std::vector<std::string>& v, const std::string& c);
|
|
|
|
|
|
|
|
|
|
|
|
//C++的从文件路径名称到文件名称(不包括后缀)的方法
|
|
|
|
//C++的从文件路径名称到文件名称(不包括后缀)的方法
|
|
|
|
void getFileName(const string& filepath, string& name);
|
|
|
|
void getFileName(const std::string& filepath, std::string& name);
|
|
|
|
|
|
|
|
|
|
|
|
//! levenshtein距离,用于计算两个车牌的距离
|
|
|
|
//! levenshtein距离,用于计算两个车牌的距离
|
|
|
|
//!EasyPR中用levenshtein距离衡量车牌识别与真实车牌的误差
|
|
|
|
//!EasyPR中用levenshtein距离衡量车牌识别与真实车牌的误差
|
|
|
|
template<class T>
|
|
|
|
template<class T>
|
|
|
|
unsigned int levenshtein_distance(const T &s1, const T & s2) {
|
|
|
|
unsigned int levenshtein_distance(const T &s1, const T & s2) {
|
|
|
|
const size_t len1 = s1.size(), len2 = s2.size();
|
|
|
|
const size_t len1 = s1.size(), len2 = s2.size();
|
|
|
|
vector<unsigned int> col(len2+1), prevCol(len2+1);
|
|
|
|
std::vector<unsigned int> col(len2+1), prevCol(len2+1);
|
|
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < prevCol.size(); i++)
|
|
|
|
for (unsigned int i = 0; i < prevCol.size(); i++)
|
|
|
|
prevCol[i] = i;
|
|
|
|
prevCol[i] = i;
|
|
|
|
for (unsigned int i = 0; i < len1; i++) {
|
|
|
|
for (unsigned int i = 0; i < len1; i++) {
|
|
|
|
col[0] = i+1;
|
|
|
|
col[0] = i+1;
|
|
|
|
for (unsigned int j = 0; j < len2; j++)
|
|
|
|
for (unsigned int j = 0; j < len2; j++)
|
|
|
|
col[j+1] = min( min(prevCol[1 + j] + 1, col[j] + 1), \
|
|
|
|
col[j+1] = std::min(std::min(prevCol[1 + j] + 1, col[j] + 1), \
|
|
|
|
prevCol[j] + (s1[i]==s2[j] ? 0 : 1) );
|
|
|
|
prevCol[j] + (s1[i]==s2[j] ? 0 : 1) );
|
|
|
|
col.swap(prevCol);
|
|
|
|
col.swap(prevCol);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,13 +49,13 @@ unsigned int levenshtein_distance(const T &s1, const T & s2) {
|
|
|
|
int testMain();
|
|
|
|
int testMain();
|
|
|
|
|
|
|
|
|
|
|
|
/// accuracy_test.cpp中方法
|
|
|
|
/// accuracy_test.cpp中方法
|
|
|
|
int acurayTest(const string&);
|
|
|
|
int acurayTest(const std::string&);
|
|
|
|
|
|
|
|
|
|
|
|
/// mc_data_prepare.cpp中方法
|
|
|
|
/// mc_data_prepare.cpp中方法
|
|
|
|
void getLearnData();
|
|
|
|
void getLearnData();
|
|
|
|
void Code2Province(const string& code, string& province);
|
|
|
|
void Code2Province(const std::string& code, std::string& province);
|
|
|
|
void changeFileName();
|
|
|
|
void changeFileName();
|
|
|
|
void getPlateLicense(const string& filepath, string& plateLicense);
|
|
|
|
void getPlateLicense(const std::string& filepath, std::string& plateLicense);
|
|
|
|
|
|
|
|
|
|
|
|
/// learn_prepare.cpp中方法
|
|
|
|
/// learn_prepare.cpp中方法
|
|
|
|
void label_data();
|
|
|
|
void label_data();
|
|
|
|