修改了SVM模型,优化了车牌定位的参数

dev
hzy 5 years ago
parent 6f56b92a97
commit 363da4f8e1

@ -27,7 +27,7 @@ namespace easypr {
int plateRecognize(const Mat& src, std::vector<CPlate> &plateVec, int img_index = 0);
int plateRecognize(const Mat& src, std::vector<std::string> &licenseVec);
inline void setLifemode(bool param) { CPlateDetect::setPDLifemode(param); }
inline void setLifemode(bool param) { CPlateDetect::setPDLifemode(param); }
inline void setDetectType(int param) { CPlateDetect::setDetectType(param); }
inline void setResultShow(bool param) { m_showResult = param; }

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

@ -61,20 +61,32 @@ int CCharsRecognise::charsRecognise(CPlate& plate, std::string& plateLicense) {
if (result == 0) {
int num = matChars.size();
for (int j = 0; j < num; j++)
{
Mat charMat = matChars.at(j);
Mat grayChar = grayChars.at(j);
if (color != Color::BLUE)
grayChar = 255 - grayChar;
for (int j = 0; j < num; j++)
{
Mat charMat = matChars.at(j);
Mat grayChar = grayChars.at(j);
if (!charMat.empty()) {
imshow("charMat", charMat);
waitKey(0);
destroyWindow("charMat");
}
if (color != Color::BLUE)
grayChar = 255 - grayChar;
if (j == 0) {
if (!grayChar.empty()) {
imshow("grayChar", grayChar);
waitKey(0);
destroyWindow("grayChar");
}
}
bool isChinses = false;
std::pair<std::string, std::string> character;
float maxVal;
float maxVal=0;
if (0 == j) {
isChinses = true;
bool judge = true;
character = CharsIdentify::instance()->identifyChineseGray(grayChar, maxVal, judge);
character = CharsIdentify::instance()->identifyChinese(charMat, maxVal, judge);
plateLicense.append(character.second);
// set plate chinese mat and str
@ -82,16 +94,16 @@ int CCharsRecognise::charsRecognise(CPlate& plate, std::string& plateLicense) {
plate.setChineseKey(character.first);
if (0) writeTempImage(grayChar, "char_data/" + character.first + "/chars_");
}
else if (1 == j) {
else if (1 == j||2 == j) {
isChinses = false;
bool isAbc = true;
character = CharsIdentify::instance()->identify(charMat, isChinses, isAbc);
character = CharsIdentify::instance()->identify(charMat, isChinses, isAbc);
plateLicense.append(character.second);
}
else {
isChinses = false;
SHOW_IMAGE(charMat, 0);
character = CharsIdentify::instance()->identify(charMat, isChinses);
character = CharsIdentify::instance()->identify(charMat, isChinses);
plateLicense.append(character.second);
}

@ -1012,6 +1012,25 @@ int CCharsSegment::charsSegmentUsingOSTU(Mat input, vector<Mat>& resultVec, vect
else {
judgeChinese(auxRoi, newRoi, plateType);
}
if (useSlideWindow) {
float slideLengthRatio = 0.1f;
//float slideLengthRatio = CParams::instance()->getParam1f();
if (!slideChineseWindow(input_grey, mr, newRoi, plateType, slideLengthRatio, useAdapThreshold))
judgeChinese(auxRoi, newRoi, plateType);
}
else
judgeChinese(auxRoi, newRoi, plateType);
if (0) {
imshow("newChineseRoi", newChineseRoi);
waitKey(0);
destroyWindow("newChineseRoi");
}
if (0) {
imshow("newRoi", newRoi);
waitKey(0);
destroyWindow("newRoi");
}
grayChars.push_back(newChineseRoi);
}
else {
@ -1023,12 +1042,23 @@ int CCharsSegment::charsSegmentUsingOSTU(Mat input, vector<Mat>& resultVec, vect
default: threshold(auxRoi, newRoi, 0, 255, CV_THRESH_OTSU + CV_THRESH_BINARY); break;
}
newRoi = preprocessChar(newRoi);
if (0) {
resizeWindow("newRoi", 300, 200);
imshow("newRoi", newRoi);
waitKey(0);
destroyWindow("newRoi");
}
// genenrate gray chinese char
Rect fit_mr = rectFit(mr, input_grey.cols, input_grey.rows);
Mat grayChar(input_grey, fit_mr);
grayChars.push_back(grayChar);
if (0) {
imshow("grayChar", grayChar);
waitKey(0);
destroyWindow("grayChar");
}
}
resultVec.push_back(newRoi);
}
return 0;

@ -26,7 +26,7 @@ CPlateLocate::CPlateLocate() {
}
void CPlateLocate::setLifemode(bool param) {
if (param) {
/*if (param) {
setGaussianBlurSize(5);
setMorphSizeWidth(10);
setMorphSizeHeight(3);
@ -34,7 +34,17 @@ void CPlateLocate::setLifemode(bool param) {
setVerifyAspect(4.0);
setVerifyMin(1);
setVerifyMax(200);
} else {
}*/
if (param) {
setGaussianBlurSize(5);
setMorphSizeWidth(7);
setMorphSizeHeight(3);
setVerifyError(0.9);
setVerifyAspect(4.0);
setVerifyMin(1);
setVerifyMax(30);
}
else {
setGaussianBlurSize(DEFAULT_GAUSSIANBLUR_SIZE);
setMorphSizeWidth(DEFAULT_MORPH_SIZE_WIDTH);
setMorphSizeHeight(DEFAULT_MORPH_SIZE_HEIGHT);

@ -12,13 +12,14 @@ int test_plate_locate() {
cout << "test_plate_locate" << endl;
//const string file = "resources/image/plate_locate.jpg";
const string file = "resources/image/plate_judge1.jpg";
// const string file = "resources/image/plate_judge1.jpg";
const string file = "resources/image/test1.jpg";
cv::Mat src = imread(file);
vector<cv::Mat> resultVec;
CPlateLocate plate;
//plate.setDebug(1);
//plate.setLifemode(true);
plate.setDebug(1);
plate.setLifemode(true);
int result = plate.plateLocate(src, resultVec);
if (result == 0) {
@ -43,8 +44,8 @@ int test_plate_judge() {
vector<cv::Mat> resultVec;
CPlateLocate lo;
//lo.setDebug(1);
//lo.setLifemode(true);
lo.setDebug(1);
lo.setLifemode(true);
int resultLo = lo.plateLocate(src, matVec);
@ -79,11 +80,11 @@ int test_plate_detect() {
cout << "test_plate_detect" << endl;
//cv::Mat src = imread("resources/image/plate_detect.jpg");
cv::Mat src = imread("resources/image/plate_judge1.jpg");
//cv::Mat src = imread("resources/image/plate_judge1.jpg");
cv::Mat src = imread("resources/image/test1.jpg");
vector<CPlate> resultVec;
CPlateDetect pd;
//pd.setPDLifemode(true);
pd.setPDLifemode(true);
int result = pd.plateDetect(src, resultVec);
if (result == 0) {
@ -104,10 +105,11 @@ int test_plate_recognize() {
cout << "test_plate_recognize" << endl;
//Mat src = imread("resources/image/test.jpg");
Mat src = imread("resources/image/plate_judge1.jpg");
// Mat src = imread("resources/image/plate_judge1.jpg");
Mat src = imread("resources/image/test1.jpg");
CPlateRecognize pr;
pr.setLifemode(true);
pr.setDebug(false);
//pr.setDebug(false);
pr.setMaxPlates(1);
//pr.setDetectType(PR_DETECT_COLOR | PR_DETECT_SOBEL);
//pr.setDetectType(easypr::PR_DETECT_CMSER);

Loading…
Cancel
Save