no commit message

devA
yuxue 5 years ago
parent a6acd3a426
commit 76a289ec88

@ -18,11 +18,36 @@ import com.yuxue.util.Convert;
*/
public class CharsIdentify {
private int predictSize = 10;
// 车牌不使用I及O字母防止0,1混淆
private final char strCharacters[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', /* 没有I */'J', 'K', 'L', 'M', 'N', /* 没有O */'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z' };
private final String strChinese[] = { "zh_cuan" /* 川 */, "zh_e" /* 鄂 */, "zh_gan" /* 赣 */, "zh_gan1"/* 甘 */,
"zh_gui"/* 贵 */, "zh_gui1"/* 桂 */, "zh_hei" /* 黑 */, "zh_hu" /* 沪 */, "zh_ji" /* 冀 */, "zh_jin" /* 津 */,
"zh_jing" /* 京 */, "zh_jl" /* 吉 */, "zh_liao" /* 辽 */, "zh_lu" /* 鲁 */, "zh_meng" /* 蒙 */,
"zh_min" /* 闽 */, "zh_ning" /* 宁 */, "zh_qing" /* 青 */, "zh_qiong" /* 琼 */, "zh_shan" /* 陕 */,
"zh_su" /* 苏 */, "zh_sx" /* 晋 */, "zh_wan" /* 皖 */, "zh_xiang" /* 湘 */, "zh_xin" /* 新 */, "zh_yu" /* 豫 */,
"zh_yu1" /* 渝 */, "zh_yue" /* 粤 */, "zh_yun" /* 云 */, "zh_zang" /* 藏 */, "zh_zhe" /* 浙 */};
private final static int numCharacter = 34; // 没有I和0,10个数字与24个英文字符之和
private final static int numAll = 65; /* 34+31=65 */
private ANN_MLP ann=ANN_MLP.create();
private String path = "res/model/ann.xml";
static boolean hasPrint = false;
private Map<String, String> map = new HashMap<String, String>();
public CharsIdentify() {
loadModel(); // 加载ann配置文件
if (this.map.isEmpty()) {
map.put("zh_cuan", "川");
map.put("zh_e", "鄂");
@ -57,8 +82,17 @@ public class CharsIdentify {
map.put("zh_zhe", "浙");
}
}
private void loadModel() {
loadModel(this.path);
}
public void loadModel(String s) {
this.ann.clear();
ann=ANN_MLP.loadANN_MLP(s, "ann"); // 加载ann配置文件
}
/**
* @param input
* @param isChinese
@ -102,22 +136,6 @@ public class CharsIdentify {
return result;
}
private ANN_MLP ann=ANN_MLP.create();
private String path = "res/model/ann.xml";
private void loadModel() {
loadModel(this.path);
}
public void loadModel(String s) {
this.ann.clear();
ann=ANN_MLP.loadANN_MLP(s, "ann");
}
static boolean hasPrint = false;
public final void setModelPath(String path) {
this.path = path;
@ -128,26 +146,5 @@ public class CharsIdentify {
}
private int predictSize = 10;
// 车牌不使用I及O字母防止0,1混淆
private final char strCharacters[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', /* 没有I */'J', 'K', 'L', 'M', 'N', /* 没有O */'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z' };
private final String strChinese[] = { "zh_cuan" /* 川 */, "zh_e" /* 鄂 */, "zh_gan" /* 赣 */, "zh_gan1"/* 甘 */,
"zh_gui"/* 贵 */, "zh_gui1"/* 桂 */, "zh_hei" /* 黑 */, "zh_hu" /* 沪 */, "zh_ji" /* 冀 */, "zh_jin" /* 津 */,
"zh_jing" /* 京 */, "zh_jl" /* 吉 */, "zh_liao" /* 辽 */, "zh_lu" /* 鲁 */, "zh_meng" /* 蒙 */,
"zh_min" /* 闽 */, "zh_ning" /* 宁 */, "zh_qing" /* 青 */, "zh_qiong" /* 琼 */, "zh_shan" /* 陕 */,
"zh_su" /* 苏 */, "zh_sx" /* 晋 */, "zh_wan" /* 皖 */, "zh_xiang" /* 湘 */, "zh_xin" /* 新 */, "zh_yu" /* 豫 */,
"zh_yu1" /* 渝 */, "zh_yue" /* 粤 */, "zh_yun" /* 云 */, "zh_zang" /* 藏 */, "zh_zhe" /* 浙 */};
private final static int numCharacter = 34; // 没有I和0,10个数字与24个英文字符之和
@SuppressWarnings("unused")
private final static int numChinese = 31;
private final static int numAll = 65; /* 34+31=65 */
}

@ -13,6 +13,11 @@ import com.yuxue.enumtype.PlateColor;
* @date 2020-04-24 15:31
*/
public class CharsRecognise {
private CharsSegment charsSegment = new CharsSegment();
private CharsIdentify charsIdentify = new CharsIdentify();
public void loadANN(final String s) {
charsIdentify.loadModel(s);
@ -21,8 +26,7 @@ public class CharsRecognise {
/**
* Chars segment and identify
*
* @param plate
* the input plate
* @param plate the input plate
* @return the result of plate recognition
*/
public String charsRecognise(final Mat plate) {
@ -128,7 +132,5 @@ public class CharsRecognise {
return charsSegment.getWhitePercent();
}
private CharsSegment charsSegment = new CharsSegment();
private CharsIdentify charsIdentify = new CharsIdentify();
}

@ -30,12 +30,35 @@ import org.bytedeco.javacpp.opencv_imgcodecs;
import com.yuxue.util.Convert;
/**
*
*
* @author yuxue
* @date 2020-04-28 09:45
*/
public class CharsSegment {
// preprocessChar所用常量
final static int CHAR_SIZE = 20;
final static int HORIZONTAL = 1;
final static int VERTICAL = 0;
final static int DEFAULT_LIUDING_SIZE = 7;
final static int DEFAULT_MAT_WIDTH = 136;
final static int DEFAULT_COLORTHRESHOLD = 150;
final static float DEFAULT_BLUEPERCEMT = 0.3f;
final static float DEFAULT_WHITEPERCEMT = 0.1f;
private int liuDingSize = DEFAULT_LIUDING_SIZE;
private int theMatWidth = DEFAULT_MAT_WIDTH;
private int colorThreshold = DEFAULT_COLORTHRESHOLD;
private float bluePercent = DEFAULT_BLUEPERCEMT;
private float whitePercent = DEFAULT_WHITEPERCEMT;
private boolean isDebug = false;
/**
*
*
@ -53,7 +76,7 @@ public class CharsSegment {
// 判断车牌颜色以此确认threshold方法
Mat img_threshold = new Mat();
Mat input_grey = new Mat();
cvtColor(input, input_grey, CV_RGB2GRAY);
@ -408,28 +431,7 @@ public class CharsSegment {
this.isDebug = isDebug;
}
// 是否开启调试模式常量默认false代表关闭
final static boolean DEFAULT_DEBUG = false;
// preprocessChar所用常量
final static int CHAR_SIZE = 20;
final static int HORIZONTAL = 1;
final static int VERTICAL = 0;
final static int DEFAULT_LIUDING_SIZE = 7;
final static int DEFAULT_MAT_WIDTH = 136;
final static int DEFAULT_COLORTHRESHOLD = 150;
final static float DEFAULT_BLUEPERCEMT = 0.3f;
final static float DEFAULT_WHITEPERCEMT = 0.1f;
private int liuDingSize = DEFAULT_LIUDING_SIZE;
private int theMatWidth = DEFAULT_MAT_WIDTH;
private int colorThreshold = DEFAULT_COLORTHRESHOLD;
private float bluePercent = DEFAULT_BLUEPERCEMT;
private float whitePercent = DEFAULT_WHITEPERCEMT;
private boolean isDebug = DEFAULT_DEBUG;
}

@ -13,8 +13,10 @@ import org.bytedeco.javacpp.opencv_core.Mat;
*/
public class PlateDetect {
// 车牌定位, 图片处理对象
private PlateLocate plateLocate = new PlateLocate();
// 切图判断对象
private PlateJudge plateJudge = new PlateJudge();
/**

@ -101,7 +101,6 @@ public class PlateLocate {
/**
*
*
* @param src
* @return Mat
*/
@ -269,7 +268,6 @@ public class PlateLocate {
/**
* 便
*
* @param src
* @param rect_size
* @param center
@ -362,6 +360,4 @@ public class PlateLocate {
return debug;
}
}

Loading…
Cancel
Save