|
|
|
@ -16,34 +16,16 @@ namespace easypr {
|
|
|
|
|
svm_ = ml::SVM::load<ml::SVM>(kDefaultSvmPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! Ö±·½Í¼¾ùºâ
|
|
|
|
|
Mat PlateJudge::histeq(Mat in) {
|
|
|
|
|
Mat out(in.size(), in.type());
|
|
|
|
|
if (in.channels() == 3) {
|
|
|
|
|
Mat hsv;
|
|
|
|
|
std::vector<Mat> hsvSplit;
|
|
|
|
|
cvtColor(in, hsv, CV_BGR2HSV);
|
|
|
|
|
split(hsv, hsvSplit);
|
|
|
|
|
equalizeHist(hsvSplit[2], hsvSplit[2]);
|
|
|
|
|
merge(hsvSplit, hsv);
|
|
|
|
|
cvtColor(hsv, out, CV_HSV2BGR);
|
|
|
|
|
}
|
|
|
|
|
else if (in.channels() == 1) {
|
|
|
|
|
equalizeHist(in, out);
|
|
|
|
|
}
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//! 对单幅图像进行SVM判断
|
|
|
|
|
int PlateJudge::plateJudge(const Mat& inMat, int& result) {
|
|
|
|
|
Mat features;
|
|
|
|
|
getHistogramFeatures(inMat, features);
|
|
|
|
|
|
|
|
|
|
//通过直方图均衡化后的彩色图进行预测
|
|
|
|
|
Mat p = features.reshape(1, 1);
|
|
|
|
|
p.convertTo(p, CV_32FC1);
|
|
|
|
|
/*Mat p = features.reshape(1, 1);
|
|
|
|
|
p.convertTo(p, CV_32F);*/
|
|
|
|
|
|
|
|
|
|
float response = svm_->predict(p);
|
|
|
|
|
float response = svm_->predict(features);
|
|
|
|
|
result = (int)response;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|