diff --git a/src/core/chars_segment.cpp b/src/core/chars_segment.cpp index f3289dd..202c64d 100644 --- a/src/core/chars_segment.cpp +++ b/src/core/chars_segment.cpp @@ -90,7 +90,7 @@ Mat CCharsSegment::histeq(Mat in) //getPlateType //判断车牌的类型,1为蓝牌,2为黄牌,0为未知,默认蓝牌 //通过像素中蓝色所占比例的多少来判断,大于0.3为蓝牌,否则为黄牌 -int CCharsSegment::getPlateType(Mat input) +PlateColor CCharsSegment::getPlateType(Mat input) { Mat img; input.copyTo(img); @@ -121,11 +121,11 @@ int CCharsSegment::getPlateType(Mat input) double percentWhite = countWhite/nums; if (percentBlue - m_BluePercent > 0 && percentWhite - m_WhitePercent > 0) - return 1; + return PlateColor::Blue; else - return 2; + return PlateColor::Yellow; - return 0; + return PlateColor::Unknown; } //clearLiuDing @@ -162,12 +162,12 @@ int CCharsSegment::charsSegment(Mat input, vector& resultVec) { return -3; } //判断车牌颜色以此确认threshold方法 - int plateType = getPlateType(input); + PlateColor plateType = getPlateType(input); cvtColor(input, input, CV_RGB2GRAY); //Threshold input image Mat img_threshold; - if (1 == plateType) + if (PlateColor::Blue == plateType) threshold(input, img_threshold, 10, 255, CV_THRESH_OTSU+CV_THRESH_BINARY); else threshold(input, img_threshold, 10, 255, CV_THRESH_OTSU+CV_THRESH_BINARY_INV); diff --git a/src/include/chars_recognise.h b/src/include/chars_recognise.h index ea17452..6443d93 100644 --- a/src/include/chars_recognise.h +++ b/src/include/chars_recognise.h @@ -45,9 +45,9 @@ public: { string color = "未知"; int result = m_charsSegment->getPlateType(input); - if (1 == result) + if (PlateColor::Blue == result) color = "蓝牌"; - if (2 == result) + if (PlateColor::Yellow == result) color = "黄牌"; return color; } diff --git a/src/include/chars_segment.h b/src/include/chars_segment.h index c6dc289..4fd896f 100644 --- a/src/include/chars_segment.h +++ b/src/include/chars_segment.h @@ -19,6 +19,12 @@ */ namespace easypr { + enum PlateColor { + Blue, + Yellow, + Unknown + }; + class CCharsSegment { public: @@ -43,7 +49,7 @@ public: Mat histeq(Mat in); //! 获得车牌颜色 - int getPlateType(Mat input); + PlateColor getPlateType(Mat input); //! 去除影响字符识别的柳钉 void clearLiuDing(Mat &img);