change verifyRotatedPlateSize, add debug to plateMserLocate

v1.6alpha
liuruoze 9 years ago
parent 68fc98414c
commit bd28606352

@ -1581,3 +1581,7 @@
总图片数:50, 未识出图片:18, 定位率:64%
平均字符差距:0, 完全匹配数:0, 完全匹配率:0%
总时间:273秒, 平均执行时间:5.46秒
2016-06-16 08:44:29
总图片数:200, 未识出图片:7, 定位率:96.5%
平均字符差距:0.689119, 完全匹配数:132, 完全匹配率:68.3938%
总时间:181秒, 平均执行时间:0.905秒

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 KiB

After

Width:  |  Height:  |  Size: 62 KiB

File diff suppressed because it is too large Load Diff

@ -908,8 +908,11 @@ bool verifyRotatedPlateSizes(RotatedRect mr) {
float aspect_min = aspect - aspect * error;
float aspect_max = aspect + aspect * error;
int min = int(40.f * 40.f * aspect_min * 1.f); // minimum area
int max = int(40.f * 40.f * aspect_max * 100.f); // maximum area
float width_max = 400.f;
float width_min = 40.f;
float min = float(width_min * width_min / aspect_max); // minimum area
float max = float(width_max * width_max / aspect_min); // maximum area
float width = mr.size.width;
float height = mr.size.height;
@ -925,18 +928,26 @@ bool verifyRotatedPlateSizes(RotatedRect mr) {
//std::cout << "angle:" << angle << std::endl;
}
float angle_f = -90.f + 50;
float angle_l = 90.f - 50;
float angle_min = -60.f;
float angle_max = 60.f;
float width_max = 400;
float width_min = 40;
// cout << "area:" << area << endl;
// cout << "r:" << r << endl;
//std::cout << "area:" << area << std::endl;
//std::cout << "ratio:" << ratio << std::endl;
//std::cout << "angle:" << angle << std::endl;
if ((area < min || area > max) || (ratio < aspect_min || ratio > aspect_max)
|| (angle < angle_f || angle > angle_l) || (width < width_min || width > width_max))
|| (angle < angle_min || angle > angle_max) || (width < width_min || width > width_max)) {
//if (abs(angle) - 0.f < 3.f ) {
// std::cout << "min:" << min << std::endl;
// std::cout << "max:" << max << std::endl;
// std::cout << "area:" << area << std::endl;
// //std::cout << "ratio:" << ratio << std::endl;
// //std::cout << "angle:" << angle << std::endl;
// return true;
//}
return false;
}
else
return true;
}

@ -83,6 +83,7 @@ bool CPlateLocate::verifySizes(RotatedRect mr) {
int CPlateLocate::mserSearch(const Mat &src, const Color r, Mat &out,
vector<RotatedRect> &outRects, int index) {
Mat match_grey;
Mat result = src.clone();
// width值对最终结果影响很大可以考虑进行多次colorSerch每次不同的值
// 另一种解决方案就是在结果输出到SVM之前进行线与角的再纠正
@ -131,14 +132,15 @@ int CPlateLocate::mserSearch(const Mat &src, const Color r, Mat &out,
RotatedRect mr = minAreaRect(Mat(*itc));
// 需要进行大小尺寸判断
if (!verifySizes(mr))
if (!verifyRotatedPlateSizes(mr))
itc = contours.erase(itc);
else {
++itc;
contourRects.push_back(mr);
float width = mr.size.width;
float height = mr.size.height;
float height = mr.size.height;
RotatedRect candRect(mr.center,
Size2f(float(width * 1.1), float(height * 1.1)), mr.angle);
@ -146,8 +148,11 @@ int CPlateLocate::mserSearch(const Mat &src, const Color r, Mat &out,
Rect_<float> outputRect;
calcSafeRect(candRect, src, outputRect);
cv::rectangle(result, outputRect, Scalar(0, 0, 255));
if (0) {
imshow("inMat", src(outputRect));
imshow("outputRect", src(outputRect));
waitKey(0);
}
}
@ -169,12 +174,27 @@ int CPlateLocate::mserSearch(const Mat &src, const Color r, Mat &out,
RotatedRect candRect(Point2f(float(x + width / 2), float(y + height / 2)),
Size2f(float(width), float(height)), 0);
Rect_<float> outputRect;
calcSafeRect(candRect, src, outputRect);
cv::rectangle(result, outputRect, Scalar(0, 255, 0));
if (0) {
imshow("outputRect", src(outputRect));
waitKey(0);
}
outRects.push_back(candRect);
}
}
}
if (1) {
imshow("result", result);
waitKey(0);
}
return 0;
}

@ -372,6 +372,13 @@ namespace easypr {
}
}
//RotatedRect testrr(Point2f(200, 200), Size2f(375, 100), 1.f);
//Point2f rect_points[4];
//testrr.points(rect_points);
//for (int j = 0; j < 4; j++)
// line(result, rect_points[j], rect_points[(j + 1) % 4], Scalar(0,0,255), 2, 8);
if (1) {
imshow("result", result);
waitKey(0);

@ -91,8 +91,8 @@ namespace easypr {
pr.setMaxPlates(4);
//pr.setDetectType(PR_DETECT_COLOR | PR_DETECT_SOBEL);
pr.setDetectType(PR_DETECT_CMSER);
pr.setDetectType(PR_DETECT_COLOR | PR_DETECT_SOBEL);
//pr.setDetectType(PR_DETECT_CMSER);
int size = files.size();

@ -115,8 +115,8 @@ int test_plate_recognize() {
//vector<string> plateVec;
vector<CPlate> plateVec;
//int result = pr.plateRecognize(src, plateVec);
int result = pr.plateRecognizeAsText(src, plateVec);
int result = pr.plateRecognize(src, plateVec);
//int result = pr.plateRecognizeAsText(src, plateVec);
if (result == 0) {
size_t num = plateVec.size();
for (size_t j = 0; j < num; j++) {

Loading…
Cancel
Save