英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论