tess4j 自动识别图片中的验证码

自动识别图片中的验证码

tess4j 项目地址 👉 github.com/javakam/Ver…

效果

🍎识别结果为 4043

🍎识别结果为 8505

样例

  1. 引入
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
    <groupId>net.sourceforge.tess4j</groupId>
    <artifactId>tess4j</artifactId>
    <version>4.5.3</version>
</dependency>
  1. 使用说明 tess4j.sourceforge.net/usage.html

BUG

  1. Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
ITesseract instance = new Tesseract();  // JNA Interface Mapping
//In case you don't have your own tessdata, let it also be extracted for you
File tessDataFolder = LoadLibs.extractTessResources(DEST);
//Set the tessdata path
instance.setDatapath(tessDataFolder.getAbsolutePath());
posted @ 2020-10-26 16:08  javakam  阅读(0)  评论(0)    收藏  举报  来源