|
|
|
@ -12,13 +12,13 @@ public class Ocr {
|
|
|
|
|
|
|
|
|
|
ITesseract instance = new Tesseract();
|
|
|
|
|
//如果未将tessdata放在根目录下需要指定绝对路径
|
|
|
|
|
instance.setDatapath("E:\\workspace\\wbocr\\src\\main\\resources\\tessdata");
|
|
|
|
|
instance.setDatapath("D:\\wbSource\\wbocr\\src\\main\\resources\\tessdata");
|
|
|
|
|
|
|
|
|
|
//如果需要识别英文之外的语种,需要指定识别语种,并且需要将对应的语言包放进项目中
|
|
|
|
|
instance.setLanguage("chi_sim");
|
|
|
|
|
|
|
|
|
|
// 指定识别图片
|
|
|
|
|
File imgDir = new File("D:\\2018041914044684.png");
|
|
|
|
|
File imgDir = new File("D:\\wbSource\\wbocr\\1.png");
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
String ocrResult = null;
|
|
|
|
|
try {
|
|
|
|
|