|
|
|
@ -7,14 +7,12 @@
|
|
|
|
|
|
|
|
|
|
using namespace easypr;
|
|
|
|
|
|
|
|
|
|
int acurayTest(const string& test_path)
|
|
|
|
|
{
|
|
|
|
|
int acurayTest(const string& test_path) {
|
|
|
|
|
////获取该路径下的所有文件
|
|
|
|
|
vector<string> files;
|
|
|
|
|
getFiles(test_path, files);
|
|
|
|
|
auto files = Utils::getFiles(test_path);
|
|
|
|
|
|
|
|
|
|
CPlateLocate lo;
|
|
|
|
|
CPlateJudge ju;
|
|
|
|
|
// CPlateLocate lo;
|
|
|
|
|
// CPlateJudge ju;
|
|
|
|
|
CPlateRecognize pr;
|
|
|
|
|
|
|
|
|
|
pr.LoadANN("model/ann.xml");
|
|
|
|
@ -32,8 +30,7 @@ int acurayTest(const string& test_path)
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
@ -60,8 +57,7 @@ int acurayTest(const string& test_path)
|
|
|
|
|
time_t begin, end;
|
|
|
|
|
time(&begin);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < size; i++)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
|
string filepath = files[i].c_str();
|
|
|
|
|
cout << "------------------" << endl;
|
|
|
|
|
|
|
|
|
@ -74,22 +70,16 @@ int acurayTest(const string& test_path)
|
|
|
|
|
|
|
|
|
|
vector<string> plateVec;
|
|
|
|
|
int result = pr.plateRecognize(src, plateVec);
|
|
|
|
|
if (result == 0)
|
|
|
|
|
{
|
|
|
|
|
if (result == 0) {
|
|
|
|
|
int num = plateVec.size();
|
|
|
|
|
|
|
|
|
|
if (num == 0)
|
|
|
|
|
{
|
|
|
|
|
cout << ""<< "ÎÞ³µÅÆ" <<endl;
|
|
|
|
|
if (plateLicense != "ÎÞ³µÅÆ")
|
|
|
|
|
count_norecogin++;
|
|
|
|
|
}
|
|
|
|
|
else if ( num > 1)
|
|
|
|
|
{
|
|
|
|
|
if (num == 0) {
|
|
|
|
|
cout << "ÎÞ³µÅÆ" << endl;
|
|
|
|
|
if (plateLicense != "ÎÞ³µÅÆ") count_norecogin++;
|
|
|
|
|
} else if (num > 1) {
|
|
|
|
|
// 多车牌使用diff最小的那个记录
|
|
|
|
|
int mindiff = 10000;
|
|
|
|
|
for (int j = 0; j < num; j++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < num; j++) {
|
|
|
|
|
cout << plateVec[j] << " (" << j + 1 << ")" << endl;
|
|
|
|
|
string colorplate = plateVec[j];
|
|
|
|
|
|
|
|
|
@ -97,27 +87,22 @@ int acurayTest(const string& test_path)
|
|
|
|
|
vector<string> spilt_plate = Utils::splitString(colorplate, ':');
|
|
|
|
|
|
|
|
|
|
int size = spilt_plate.size();
|
|
|
|
|
if (size == 2 && spilt_plate[1] != "")
|
|
|
|
|
{
|
|
|
|
|
int diff = levenshtein_distance(plateLicense, spilt_plate[size-1]);
|
|
|
|
|
if (diff < mindiff)
|
|
|
|
|
mindiff = diff;
|
|
|
|
|
if (size == 2 && spilt_plate[1] != "") {
|
|
|
|
|
int diff =
|
|
|
|
|
levenshtein_distance(plateLicense, spilt_plate[size - 1]);
|
|
|
|
|
if (diff < mindiff) mindiff = diff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cout << "差距:" << mindiff << "个字符" << endl;
|
|
|
|
|
if(mindiff == 0)
|
|
|
|
|
{
|
|
|
|
|
if (mindiff == 0) {
|
|
|
|
|
// 完全匹配
|
|
|
|
|
match_count++;
|
|
|
|
|
}
|
|
|
|
|
diff_all = diff_all + mindiff;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
} else {
|
|
|
|
|
// 单车牌只计算一次diff
|
|
|
|
|
for (int j = 0; j < num; j++)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < num; j++) {
|
|
|
|
|
cout << plateVec[j] << endl;
|
|
|
|
|
string colorplate = plateVec[j];
|
|
|
|
|
|
|
|
|
@ -125,29 +110,24 @@ int acurayTest(const string& test_path)
|
|
|
|
|
vector<string> spilt_plate = Utils::splitString(colorplate, ':');
|
|
|
|
|
|
|
|
|
|
int size = spilt_plate.size();
|
|
|
|
|
if (size == 2 && spilt_plate[1] != "")
|
|
|
|
|
{
|
|
|
|
|
int diff = levenshtein_distance(plateLicense, spilt_plate[size-1]);
|
|
|
|
|
if (size == 2 && spilt_plate[1] != "") {
|
|
|
|
|
int diff =
|
|
|
|
|
levenshtein_distance(plateLicense, spilt_plate[size - 1]);
|
|
|
|
|
cout << "差距:" << diff << "个字符" << endl;
|
|
|
|
|
|
|
|
|
|
if(diff == 0)
|
|
|
|
|
{
|
|
|
|
|
if (diff == 0) {
|
|
|
|
|
// 完全匹配
|
|
|
|
|
match_count++;
|
|
|
|
|
}
|
|
|
|
|
diff_all = diff_all + diff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
} else {
|
|
|
|
|
cout << "错误码:" << result << endl;
|
|
|
|
|
count_err++;
|
|
|
|
|
}
|
|
|
|
|
count_all++;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
time(&end);
|
|
|
|
|
|
|
|
|
@ -161,7 +141,7 @@ int acurayTest(const string& test_path)
|
|
|
|
|
|
|
|
|
|
float count_recogin = count_all - (count_err + count_norecogin);
|
|
|
|
|
float count_rate = count_recogin / count_all;
|
|
|
|
|
float count_norate = 1 - count_rate;
|
|
|
|
|
//float count_norate = 1 - count_rate;
|
|
|
|
|
cout << "定位率:" << count_rate * 100 << "% " << endl;
|
|
|
|
|
|
|
|
|
|
diff_avg = diff_all / count_recogin;
|
|
|
|
@ -171,7 +151,6 @@ int acurayTest(const string& test_path)
|
|
|
|
|
cout << "完全匹配数:" << match_count << "张, ";
|
|
|
|
|
cout << "完全匹配率:" << match_rate << "% " << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double seconds = difftime(end, begin);
|
|
|
|
|
double avgsec = seconds / double(count_all);
|
|
|
|
|
|
|
|
|
@ -183,8 +162,7 @@ int acurayTest(const string& test_path)
|
|
|
|
|
cout << "------------------" << endl;
|
|
|
|
|
|
|
|
|
|
ofstream myfile("run_accuracy.txt", ios::app);
|
|
|
|
|
if (myfile.is_open())
|
|
|
|
|
{
|
|
|
|
|
if (myfile.is_open()) {
|
|
|
|
|
time_t t = time(0); // get time now
|
|
|
|
|
struct tm* now = localtime(&t);
|
|
|
|
|
char buf[80];
|
|
|
|
@ -201,9 +179,8 @@ int acurayTest(const string& test_path)
|
|
|
|
|
myfile << "总时间:" << seconds << "秒, ";
|
|
|
|
|
myfile << "平均执行时间:" << avgsec << "秒 " << endl;
|
|
|
|
|
myfile.close();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
cout << "Unable to open file";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|