Tesseract是否提供整个图像的置信度?

时间:2017-11-23 13:20:52

标签: ocr tesseract

Tesseract在TSV配置中提供置信度分数,但我正在寻找整个图像处理的置信度分数。

1 个答案:

答案 0 :(得分:1)

下面的代码将返回每个图像的置信度得分。

interface Colored {
    Color getColor();
}

// in Color
public static boolean isRed(Colored colored) {
    return Objects.equals(colored.getColor(), RED);
}

在maven依赖项下面,您需要添加:

    String datapath = "D:\\Tesseract";
    String language = "eng";
    TessAPI1 api = new TessAPI1();
    TessBaseAPI handle = api.TessBaseAPICreate();

    File image = new File("testocr.png");
    Leptonica leptInstance = Leptonica.INSTANCE;
    Pix pix = leptInstance.pixRead(image.getPath());
    api.TessBaseAPIInit3(handle, datapath, language);
    api.TessBaseAPISetImage2(handle, pix);

    int conf = api.TessBaseAPIMeanTextConf(handle);
    System.out.println("conf" + conf);

    // release Pix and Boxa resources
    LeptUtils.dispose(pix);