|
|
|
@ -118,29 +118,16 @@ int CPlateRecognize::plateRecognizeAsText(Mat src, std::vector<CPlate> &licenseV
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// !车牌识别模块
|
|
|
|
|
int CPlateRecognize::plateRecognize(Mat src, std::vector<CPlate> &licenseVec, int img_index) {
|
|
|
|
|
|
|
|
|
|
// 车牌集合
|
|
|
|
|
std::vector<CPlate> plateVec;
|
|
|
|
|
|
|
|
|
|
// 对图像进行统一缩放,确保图像不要过大
|
|
|
|
|
// 对速度提升帮助不大
|
|
|
|
|
|
|
|
|
|
//int scale_size = 1600;
|
|
|
|
|
//double scale_ratio = 1;
|
|
|
|
|
//Mat ret = scaleImage(src, Size(scale_size, scale_size), scale_ratio);
|
|
|
|
|
//src = ret;
|
|
|
|
|
|
|
|
|
|
// 进行深度定位,使用颜色信息与二次Sobel
|
|
|
|
|
|
|
|
|
|
int resultPD = plateDetect(src, plateVec, img_index);
|
|
|
|
|
|
|
|
|
|
if (resultPD == 0) {
|
|
|
|
|
size_t num = plateVec.size();
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
//依次识别每个车牌内的符号
|
|
|
|
|
for (size_t j = 0; j < num; j++) {
|
|
|
|
|
CPlate item = plateVec.at(j);
|
|
|
|
|
Mat plateMat = item.getPlateMat();
|
|
|
|
@ -162,7 +149,6 @@ int CPlateRecognize::plateRecognize(Mat src, std::vector<CPlate> &licenseVec, in
|
|
|
|
|
std::cout << "plateColor:" << plateColor << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取车牌号
|
|
|
|
|
std::string plateIdentify = "";
|
|
|
|
|
int resultCR = charsRecognise(item, plateIdentify);
|
|
|
|
|
|
|
|
|
@ -181,10 +167,6 @@ int CPlateRecognize::plateRecognize(Mat src, std::vector<CPlate> &licenseVec, in
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//完整识别过程到此结束
|
|
|
|
|
|
|
|
|
|
//如果是Debug模式,则还需要将定位的图片显示在原图左上角
|
|
|
|
|
|
|
|
|
|
if (getResultShow()) {
|
|
|
|
|
Mat result;
|
|
|
|
|
src.copyTo(result);
|
|
|
|
@ -235,28 +217,21 @@ void CPlateRecognize::LoadChineseANN(std::string path) {
|
|
|
|
|
|
|
|
|
|
int CPlateRecognize::plateRecognize(Mat src, std::vector<std::string> &licenseVec) {
|
|
|
|
|
|
|
|
|
|
// 车牌方块集合
|
|
|
|
|
std::vector<CPlate> plateVec;
|
|
|
|
|
|
|
|
|
|
// 进行深度定位,使用颜色信息与二次Sobel
|
|
|
|
|
int resultPD = plateDetect(src, plateVec, 0, kDebug, 0);
|
|
|
|
|
|
|
|
|
|
if (resultPD == 0) {
|
|
|
|
|
size_t num = plateVec.size();
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
//依次识别每个车牌内的符号
|
|
|
|
|
|
|
|
|
|
for (size_t j = 0; j < num; j++) {
|
|
|
|
|
CPlate item = plateVec[j];
|
|
|
|
|
Mat plate = item.getPlateMat();
|
|
|
|
|
|
|
|
|
|
//获取车牌颜色
|
|
|
|
|
|
|
|
|
|
std::string plateType = getPlateColor(plate);
|
|
|
|
|
|
|
|
|
|
//获取车牌号
|
|
|
|
|
|
|
|
|
|
std::string plateIdentify = "";
|
|
|
|
|
int resultCR = charsRecognise(plate, plateIdentify);
|
|
|
|
|
if (resultCR == 0) {
|
|
|
|
@ -265,10 +240,6 @@ int CPlateRecognize::plateRecognize(Mat src, std::vector<std::string> &licenseVe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//完整识别过程到此结束
|
|
|
|
|
|
|
|
|
|
//如果是Debug模式,则还需要将定位的图片显示在原图左上角
|
|
|
|
|
|
|
|
|
|
if (getResultShow()) {
|
|
|
|
|
Mat result;
|
|
|
|
|
src.copyTo(result);
|
|
|
|
@ -300,8 +271,6 @@ int CPlateRecognize::plateRecognize(Mat src, std::vector<std::string> &licenseVe
|
|
|
|
|
8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//显示定位框的图片
|
|
|
|
|
|
|
|
|
|
showResult(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|