net.sourceforge.tess4j.util.LoadLibs Java Examples

The following examples show how to use net.sourceforge.tess4j.util.LoadLibs. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Tess4jUtil.java    From javautils with Apache License 2.0 6 votes vote down vote up
/**
 * 从图片中提取文字,默认设置英文字库,使用classpath目录下的训练库
 * @param path
 * @return
 */
public static String take(String path){
    // JNA Interface Mapping
    ITesseract instance = new Tesseract();
    // JNA Direct Mapping
    // ITesseract instance = new Tesseract1();
    File imageFile = new File(path);
    //In case you don't have your own tessdata, let it also be extracted for you
    //这样就能使用classpath目录下的训练库了
    File tessDataFolder = LoadLibs.extractTessResources("tessdata");
    //Set the tessdata path
    instance.setDatapath(tessDataFolder.getAbsolutePath());
    //英文库识别数字比较准确
    instance.setLanguage(Constants.ENG);
    return getOCRText(instance, imageFile);
}
 
Example #2
Source File: TessOcr.java    From MillionHero with MIT License 5 votes vote down vote up
TessOcr() {
    instance = new Tesseract();
    File tessDataFolder = LoadLibs.extractTessResources("tessdata");
    instance.setLanguage("chi_sim");
    //Set the tessdata path
    instance.setDatapath(tessDataFolder.getAbsolutePath());
}