How can i set textord_equation_detect true in TessBaseApi in Android

huangapple go评论75阅读模式
英文:

How can i set textord_equation_detect true in TessBaseApi in Android

问题

我在 build.gradle 中添加了 tess-two 库,如下所示:

implementation 'com.rmtheis:tess-two:9.1.0'

我想使用 TessBaseApi() 来识别数学表达式和符号,所以我需要设置 textord_equation_detect 为 true,但我不知道如何做。我使用 TessBaseApi 编写的代码如下:

public static boolean init(AssetManager assetManager){
    mTess = new TessBaseAPI();
    String datapath = CommonUtils.APP_PATH;
    File dir = new File(datapath + "tessdata/");
    if (!dir.exists()) {
        dir.mkdir();
        try {
            InputStream inStream = assetManager.open("CSDL/eng.traineddata");
            FileOutputStream outStream = new FileOutputStream(datapath + "tessdata/eng.traineddata");

            byte[] buffer = new byte[1024];
            int readCount = 0;
            while ((readCount = inStream.read(buffer)) != -1) {
                outStream.write(buffer, 0, readCount);
            }
            outStream.flush();
            outStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    mTess.init(datapath, "eng");
    return true;
}

请问如何将 textord_equation_detect 设置为 true?能帮助我吗?

英文:

I added tess-two library in build.gradle like below

        implementation 'com.rmtheis:tess-two:9.1.0'

and I want to recognize mathematical expression,symbol with TessBaseApi() so i need set true textord_equation_detect but i don't know how to do this.The code I wrote using TessBaseApi is as follows

    public static boolean init(AssetManager assetManager){
    mTess = new TessBaseAPI();
    String datapath = CommonUtils.APP_PATH;
    File dir =new File(datapath + "tessdata/");
    if(!dir.exists()) {
        dir.mkdir();
        try {
            InputStream inStream = assetManager.open("CSDL/eng.traineddata");

            FileOutputStream outStream = new FileOutputStream(datapath + "tessdata/eng.traineddata");

            byte[] buffer = new byte[1024];
            int readCount = 0;
            while (((readCount = inStream.read(buffer)) != -1)) {
                outStream.write(buffer, 0, readCount);

            }
            outStream.flush();
            outStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    mTess.init(datapath,"eng");
    return true;
}

How can i set true textord_equation_detect? Can you help me please?

答案1

得分: 1

mTess.SetVariable("textord_equation_detect", "T");

参考以下示例:
https://github.com/tesseract-ocr/tesseract/issues/2204

英文:

mTess.SetVariable("textord_equation_detect", "T");

following examples in
https://github.com/tesseract-ocr/tesseract/issues/2204

huangapple
  • 本文由 发表于 2020年4月8日 02:33:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/61086992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定