* fine tuning the mserCharSearch algorithm.

v1.6alpha
liuruoze 9 years ago
parent 336baf7c30
commit 8ee0731a3a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 KiB

After

Width:  |  Height:  |  Size: 184 KiB

File diff suppressed because it is too large Load Diff

@ -1848,3 +1848,33 @@ Recall:74.6006%, Precise:76.6991%, Fscore:75.6353%.
Recall:74.6006%, Precise:76.6991%, Fscore:75.6353%.
0-error:60.3604%, 1-error:68.9189%, Chinese-precise:72.5225%
总时间:303秒, 平均执行时间:1.20717秒
2016-07-04 20:57:22
总图片数:251, Plates count:290, 未定位车牌:123, 定位率:57.5862%
Recall:55.0799%, Precise:71.648%, Fscore:62.2809%.
0-error:61.4379%, 1-error:71.8954%, Chinese-precise:74.5098%
总时间:27秒, 平均执行时间:0.10757秒
2016-07-04 21:03:18
总图片数:251, Plates count:290, 未定位车牌:112, 定位率:61.3793%
Recall:58.7062%, Precise:70.3684%, Fscore:64.0105%.
0-error:60.3659%, 1-error:70.7317%, Chinese-precise:73.1707%
总时间:26秒, 平均执行时间:0.103586秒
2016-07-04 21:08:57
总图片数:251, Plates count:290, 未定位车牌:65, 定位率:77.5862%
Recall:69.6754%, Precise:36.5767%, Fscore:47.9707%.
0-error:50.2463%, 1-error:64.0394%, Chinese-precise:66.5025%
总时间:104秒, 平均执行时间:0.414343秒
2016-07-04 21:18:23
总图片数:251, Plates count:290, 未定位车牌:48, 定位率:83.4483%
Recall:74.7407%, Precise:84.3378%, Fscore:79.2498%.
0-error:61.2613%, 1-error:68.9189%, Chinese-precise:72.0721%
总时间:86秒, 平均执行时间:0.342629秒
2016-07-04 21:48:49
总图片数:251, Plates count:290, 未定位车牌:49, 定位率:83.1034%
Recall:74.6006%, Precise:76.6991%, Fscore:75.6353%.
0-error:60.3604%, 1-error:68.9189%, Chinese-precise:72.5225%
总时间:314秒, 平均执行时间:1.251秒
2016-07-04 22:28:44
总图片数:251, Plates count:290, 未定位车牌:49, 定位率:83.1034%
Recall:74.6368%, Precise:76.991%, Fscore:75.7956%.
0-error:60.3604%, 1-error:69.3694%, Chinese-precise:72.5225%
总时间:319秒, 平均执行时间:1.27092秒

@ -1031,7 +1031,12 @@ void searchWeakSeed(const std::vector<CCharacter>& charVec, std::vector<CCharact
float height_diff = abs(height_1 - height_2);
double height_diff_ratio = height_diff / min(height_1, height_2);
if (height_diff_ratio < thresh1) {
float width_diff = abs(width_1 - width_2);
double width_diff_ratio = width_diff / maxrect.width;
if (height_diff_ratio < thresh1 && width_diff_ratio < 0.5) {
//std::cout << "h" << height_diff_ratio << std::endl;
//std::cout << "w" << width_diff_ratio << std::endl;
searchWeakSeedVec.push_back(weakSeed);
}
else {

@ -17,45 +17,44 @@ namespace easypr {
int CPlateDetect::plateDetect(Mat src, std::vector<CPlate> &resultVec, int type,
bool showDetectArea, int img_index) {
std::vector<CPlate> color_Plates;
std::vector<CPlate> sobel_Plates;
sobel_Plates.reserve(16);
std::vector<CPlate> color_Plates;
color_Plates.reserve(16);
std::vector<CPlate> mser_Plates;
mser_Plates.reserve(16);
std::vector<CPlate> all_result_Plates;
if ( !type || type & PR_DETECT_SOBEL) {
m_plateLocate->plateSobelLocate(src, sobel_Plates, img_index);
std::vector<CPlate>& sobel_result_Plates = sobel_Plates;
all_result_Plates.reserve(64);
for (size_t i = 0; i < sobel_result_Plates.size(); i++) {
CPlate plate = sobel_result_Plates[i];
plate.setPlateLocateType(SOBEL);
all_result_Plates.push_back(plate);
if (!type || type & PR_DETECT_SOBEL) {
m_plateLocate->plateSobelLocate(src, sobel_Plates, img_index);
}
if (!type || type & PR_DETECT_COLOR) {
m_plateLocate->plateColorLocate(src, color_Plates, img_index);
}
}
if ( !type || type & PR_DETECT_COLOR) {
m_plateLocate->plateColorLocate(src, color_Plates, img_index);
std::vector<CPlate>& color_result_Plates = color_Plates;
if (!type || type & PR_DETECT_CMSER) {
m_plateLocate->plateMserLocate(src, mser_Plates, img_index);
}
for (size_t i = 0; i < color_result_Plates.size(); i++) {
CPlate plate = color_result_Plates[i];
plate.setPlateLocateType(COLOR);
all_result_Plates.push_back(plate);
}
for (auto plate : sobel_Plates) {
plate.setPlateLocateType(SOBEL);
all_result_Plates.push_back(plate);
}
if ( !type || type & PR_DETECT_CMSER) {
m_plateLocate->plateMserLocate(src, mser_Plates, img_index);
std::vector<CPlate>& mser_result_Plates = mser_Plates;
for (size_t i = 0; i < mser_result_Plates.size(); i++) {
CPlate plate = mser_result_Plates[i];
for (auto plate : color_Plates) {
plate.setPlateLocateType(COLOR);
all_result_Plates.push_back(plate);
}
plate.setPlateLocateType(CMSER);
all_result_Plates.push_back(plate);
}
for (auto plate : mser_Plates) {
plate.setPlateLocateType(CMSER);
all_result_Plates.push_back(plate);
}
// use nms to judge plate

@ -127,6 +127,7 @@ namespace easypr {
destroyWindow("inMat");
}
if (plate.getPlateLocateType() == CMSER) {
int w = inMat.cols;
int h = inMat.rows;
@ -154,52 +155,11 @@ namespace easypr {
else {
plateVec.push_back(plate);
}
}
else {
plateVec.push_back(plate);
}
}
//if (result == 0) {
// plateVec.push_back(plate);
// if (outputResult) {
// std::stringstream ss(std::stringstream::in | std::stringstream::out);
// ss << "resources/image/tmp/plate/has" << "/" << plate.getPlatePos().center << "_"
// << plate.getPlatePos().size << "_" << plate.getPlatePos().angle << "_"
// << plate.getPlateScore() << ".jpg";
// imwrite(ss.str(), inMat);
// }
//}
//else {
// int w = inMat.cols;
// int h = inMat.rows;
// Mat tmpmat = inMat(Rect_<double>(w * 0.05, h * 0.1, w * 0.9, h * 0.8));
// Mat tmpDes = inMat.clone();
// resize(tmpmat, tmpDes, Size(inMat.size()));
// plate.setPlateMat(tmpDes);
// int resultCascade = plateSetScore(plate);
// if (resultCascade == 0) {
// plateVec.push_back(plate);
// if (outputResult) {
// std::stringstream ss(std::stringstream::in | std::stringstream::out);
// ss << "resources/image/tmp/plate/has" << "/" << plate.getPlatePos().center << "_"
// << plate.getPlatePos().size << "_" << plate.getPlatePos().angle << "_"
// << plate.getPlateScore() << ".jpg";
// imwrite(ss.str(), tmpDes);
// }
// }
// else {
// if (outputResult) {
// std::stringstream ss(std::stringstream::in | std::stringstream::out);
// ss << "resources/image/tmp/plate/no" << "/" << plate.getPlatePos().center << "_"
// << plate.getPlatePos().size << "_" << plate.getPlatePos().angle << "_"
// << plate.getPlateScore() << ".jpg";
// imwrite(ss.str(), tmpDes);
// }
// }
//}
}
std::vector<CPlate> reDupPlateVec;

@ -157,10 +157,12 @@ namespace easypr {
string plateLicense = Utils::getFileName(filepath);
img_ss << kv->get("original_plate") << ":" << plateLicense << endl;
XMLNode xNode = xMainNode.addChild("image");
xNode.addChild("imageName").addText(plateLicense.c_str());
XMLNode rectangleNodes = xNode.addChild("taggedRectangles");
// remain
//XMLNode xNode, rectangleNodes;
//xNode = xMainNode.addChild("image");
//xNode.addChild("imageName").addText(plateLicense.c_str());
//rectangleNodes = xNode.addChild("taggedRectangles");
vector<CPlate> plateVec;
int result = pr.plateRecognize(src, plateVec, i);
@ -266,18 +268,19 @@ namespace easypr {
Rect_<float> plateRect_d;
calcSafeRect(platePos_d, src, plateRect_d);
XMLNode rectangleNode = rectangleNodes.addChild("taggedRectangle");
RotatedRect rr = platePos_d;
LocateType locateType = plate_d.getPlateLocateType();
// remain
//XMLNode rectangleNode = rectangleNodes.addChild("taggedRectangle");
//RotatedRect rr = platePos_d;
//LocateType locateType = plate_d.getPlateLocateType();
rectangleNode.addAttribute("x", to_string((int)rr.center.x).c_str());
rectangleNode.addAttribute("y", to_string((int)rr.center.y).c_str());
rectangleNode.addAttribute("width", to_string((int)rr.size.width).c_str());
rectangleNode.addAttribute("height", to_string((int)rr.size.height).c_str());
//rectangleNode.addAttribute("x", to_string((int)rr.center.x).c_str());
//rectangleNode.addAttribute("y", to_string((int)rr.center.y).c_str());
//rectangleNode.addAttribute("width", to_string((int)rr.size.width).c_str());
//rectangleNode.addAttribute("height", to_string((int)rr.size.height).c_str());
rectangleNode.addAttribute("rotation", to_string((int)rr.angle).c_str());
rectangleNode.addAttribute("locateType", to_string(locateType).c_str());
rectangleNode.addText(plate_d.getPlateStr().c_str());
//rectangleNode.addAttribute("rotation", to_string((int)rr.angle).c_str());
//rectangleNode.addAttribute("locateType", to_string(locateType).c_str());
//rectangleNode.addText(plate_d.getPlateStr().c_str());
for (auto plate_g : plateVecGT) {
RotatedRect platePos_g = plate_g.getPlatePos();
@ -345,7 +348,7 @@ namespace easypr {
time(&end);
// the xml detection result
xMainNode.writeToFile(path_result.c_str());
// xMainNode.writeToFile(path_result.c_str());
cout << "------------------" << endl;
cout << "Easypr accuracy test end!" << endl;

Loading…
Cancel
Save