no commit message

devA
yuxue 5 years ago
parent 8e8e28c235
commit 1fbb6e9523

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

@ -1,23 +0,0 @@
EasyPR 1.0:
svm liner
precise: 0.786207
recall: 0.844444
Fsocre: 0.814286
EasyPR 1.1:
svm liner
precise: 0.96798
recall: 0.933492
Fsocre: 0.950423
EasyPR 1.1:
svm liner:
precise: 0.968974
recall: 0.964371
Fsocre: 0.966667
EasyPR 1.1:
svm rbf(histom feature):
precise: 0.997596
recall: 0.985748
Fsocre: 0.991637

@ -1,4 +1,4 @@
要训练时注意看src/train下的两个cpp文件
数据在data文件夹下svm对应Plate_detectann对应chars_recognise。要先解压然后放置到正确的路径下或者
数据在data文件夹下svm对应plate_detect_svmann对应chars_recognise。要先解压然后放置到正确的路径下或者
你可以修改cpp文件中的文件夹路径。

@ -89,7 +89,7 @@ public class CharsIdentify {
public void loadModel(String s) {
this.ann.clear();
ann=ANN_MLP.loadANN_MLP(s, "ann"); // 加载ann配置文件
ann=ANN_MLP.loadANN_MLP(s, "ann"); // 加载ann配置文件 图像转文字的训练库文件
}
@ -118,7 +118,7 @@ public class CharsIdentify {
int result = -1;
Mat output = new Mat(1, numAll, CV_32FC1);
ann.predict(f, output, 0);
ann.predict(f, output, 0); // 预测结果
int ann_min = (!isChinses) ? ((isSpeci) ? 10 : 0) : numCharacter;
int ann_max = (!isChinses) ? numCharacter : numAll;
@ -133,7 +133,6 @@ public class CharsIdentify {
result = j;
}
}
return result;
}

@ -40,7 +40,7 @@ public class CharsRecognise {
if (0 == result) {
for (int j = 0; j < matVec.size(); j++) {
Mat charMat = matVec.get(j);
// 默认首个字符块是中文字符
// 默认首个字符块是中文字符 第二个字符块是字母
String charcater = charsIdentify.charsIdentify(charMat, (0 == j), (1 == j));
plateIdentify = plateIdentify + charcater;
}

@ -124,18 +124,19 @@ public class CharsSegment {
CV_RETR_EXTERNAL, // retrieve the external contours
CV_CHAIN_APPROX_NONE); // all pixels of each contours
// Start to iterate to each contour founded
// Remove patch that are no inside limits of aspect ratio and area.
// 将不符合特定尺寸的图块排除出去
Vector<Rect> vecRect = new Vector<Rect>();
for (int i = 0; i < contours.size(); ++i) {
Rect mr = boundingRect(contours.get(i));
/*Mat temp = new Mat(img_threshold, mr);
String str = tempPath + "temp_"+i+".jpg";
opencv_imgcodecs.imwrite(str, temp);*/
Mat contour = new Mat(img_threshold, mr);
if (this.isDebug) {
String str = tempPath + "debug_char_contour"+i+".jpg";
opencv_imgcodecs.imwrite(str, contour);
}
if (verifySizes(new Mat(img_threshold, mr))) {
if (verifySizes(contour)) { // 将不符合特定尺寸的图块排除出去
vecRect.add(mr);
}
}
@ -149,7 +150,6 @@ public class CharsSegment {
// 获得指示城市的特定Rect,如苏A的"A"
int specIndex = GetSpecificRect(sortedRect, color);
System.err.println(specIndex);
if (this.isDebug) {
if (specIndex < sortedRect.size()) {

@ -1,22 +1,17 @@
package com.yuxue.test;
import static org.bytedeco.javacpp.opencv_imgproc.CV_CHAIN_APPROX_NONE;
import static org.bytedeco.javacpp.opencv_imgproc.CV_RETR_EXTERNAL;
import static org.bytedeco.javacpp.opencv_imgproc.boundingRect;
import static org.bytedeco.javacpp.opencv_imgproc.findContours;
import org.bytedeco.javacpp.opencv_imgproc;
import java.io.File;
import java.util.Vector;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacpp.opencv_core.MatVector;
import org.bytedeco.javacpp.opencv_core.Rect;
import org.bytedeco.javacpp.opencv_highgui;
import org.bytedeco.javacpp.opencv_imgcodecs;
import org.junit.Test;
import com.yuxue.easypr.core.CharsIdentify;
import com.yuxue.easypr.core.CharsRecognise;
import com.yuxue.easypr.core.CharsSegment;
import com.yuxue.easypr.core.CoreFunc;
import com.yuxue.easypr.core.PlateDetect;
import com.yuxue.easypr.core.PlateLocate;
@ -185,8 +180,8 @@ public class EasyPrTest {
@Test
public void testGreenPlate() {
/*String imgPath = "res/image/test_image/result_0.png";
Mat src = opencv_imgcodecs.imread(imgPath);*/
String imgPath = "res/image/test_image/debug_resize_2.jpg";
Mat src = opencv_imgcodecs.imread(imgPath);
// 获取绿牌的H值范围
/*MatVector hsvSplit = new MatVector();
@ -227,12 +222,33 @@ public class EasyPrTest {
// 判断绿色车牌
/*Mat src_hsv = new Mat();
cvtColor(src, src_hsv, CV_BGR2HSV);
opencv_imgproc.cvtColor(src, src_hsv, opencv_imgproc.CV_BGR2HSV);
src_hsv = CoreFunc.colorMatch(src, PlateColor.GREEN, true);
System.err.println(CoreFunc.plateColorJudge(src, PlateColor.GREEN, true));
String str = "d:/PlateDetect/src_hsv.png";
opencv_imgcodecs.imwrite(str, src_hsv);*/
// 车牌检测对象
PlateDetect plateDetect = new PlateDetect();
plateDetect.setPDLifemode(true);
plateDetect.setDebug(false, ""); // 将过程的图块保存到盘符
Vector<Mat> matVector = new Vector<Mat>();
System.err.println(plateDetect.plateDetect(src, matVector));
System.err.println(matVector.size());
for (int i = 0; i < matVector.size(); ++i) { // 遍历车牌图块Mat进行识别
Mat img = matVector.get(i);
// 识别的车牌,保存图片文件
// 此方法生成的文件中文名称都是乱码试了各种编解码均无效OpenCV自身的编解码问题。
opencv_highgui.imshow("123", img);
String str = "d:/PlateDetect/temp/result_.png";
opencv_imgcodecs.imwrite(str, img);
}
}

Loading…
Cancel
Save