使用tess4j3.3.0实现OCR图片识别
2017-09-18 17:51
555 查看
前几天用tesseract-ocr写了一篇博客,但是感觉代码量有点多了,于是发现java开源库有个tess4j,相对来说简洁多了,于是去tess4j的网站上下载最新版 http://tess4j.sourceforge.net/ (需翻墙)
然后打开lib文件夹,把下面图片中的jar引入到项目中:
注意前提是你要先安装tesseract-ocr-setup-3.05.00dev.exe,之前我windows10安装的是3.02,导致一直报错,换成这个最新的就好了,所以tess4j可能跟tesseract版本有对应关系吧
安装的时候可以选择中文字库 ,然后贴一下我项目中测试的代码片段:
这样你会发现tess4j的代码简单多了,当然你还可以根据自己项目的ocr需求进行相应优化,tess4j也有很强大的图片处理工具类,什么灰度化去噪等等
分享下载:
Tess4J-3.3.0-src.zip
tesseract-ocr-setup-3.05.00dev.exe
贴个我项目中优化的方式吧 感觉效果还不错
二值化处理:
BufferedImage grayImage = ImageHelper.convertImageToBinary(ImageIO
.read(imageFile));
然后打开lib文件夹,把下面图片中的jar引入到项目中:
注意前提是你要先安装tesseract-ocr-setup-3.05.00dev.exe,之前我windows10安装的是3.02,导致一直报错,换成这个最新的就好了,所以tess4j可能跟tesseract版本有对应关系吧
安装的时候可以选择中文字库 ,然后贴一下我项目中测试的代码片段:
File imageFile = new File("d:\\9.jpg"); ITesseract instance = new Tesseract(); // JNA Interface Mapping // JNA Interface Mapping // ITesseract instance = new Tesseract1(); // JNA Direct Mapping instance.setDatapath("D:\\Java\\Tesseract-OCR\\tessdata"); // replace <parentPath> with path to parent directory of tessdata instance.setLanguage("eng"); try { BufferedImage bi = ImageIO.read(imageFile); // String result = instance.doOCR(imageFile); String result = instance.doOCR(bi); System.out.println(result); } catch (TesseractException e) { System.err.println(e.getMessage()); } catch (Exception e) { System.err.println(e.getMessage()); }
这样你会发现tess4j的代码简单多了,当然你还可以根据自己项目的ocr需求进行相应优化,tess4j也有很强大的图片处理工具类,什么灰度化去噪等等
分享下载:
Tess4J-3.3.0-src.zip
tesseract-ocr-setup-3.05.00dev.exe
贴个我项目中优化的方式吧 感觉效果还不错
二值化处理:
BufferedImage grayImage = ImageHelper.convertImageToBinary(ImageIO
.read(imageFile));
相关文章推荐
- 图片验证码自动识别,使用tess4j进行验证码自动识别(java实现)
- OCR图像识别技术的JAVA实现(二)之Tess4J的使用
- Java中使用tess4J(Tesseract-OCR)进行图片文字识别(支持中文)
- Java使用OpenCV和Tesseract-OCR实现银行卡图片处理与卡号识别
- linux系统如何使用tess4j(java)进行ocr图片文字识别
- 【识别码】使用(ImageMagick+tesseract-ocr)实现图像验证码识别实例
- 【严肃脸】使用caffe实现色情图片的识别
- Perl使用Tesseract-OCR实现验证码识别教程
- android webView使用js/css实现夜间模式 长按识别图片以及二维码,网页可以上传图片
- IOS_使用coreImage实现图片中的人脸识别
- tesseract-ocr 实现图片识别功能
- 使用Zxing实现拍照,选取图片识别二维码
- 使用Tesseract OCR Engine识别图片文字
- Tess4j+中文识别+使用介绍文档+参考网址+实现源码下载地址
- 使用DELPHI对图片中的文字进行识别的过程(最简单实现)
- java图片开源框架tesseract调用OCR实现图片文件识别代码下载
- tesseract-ocr 实现图片识别功能
- C# 使用Microsoft Office Document Imaging(MODI) 识别 图片中的文字(OCR)
- C# 图片识别asprise-ocr使用步骤
- 使用OCR来帮助LR实现认证码识别 By 云层