How can i set textord_equation_detect true in TessBaseApi in Android

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

How can i set textord_equation_detect true in TessBaseApi in Android

问题

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

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

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

  1. public static boolean init(AssetManager assetManager){
  2. mTess = new TessBaseAPI();
  3. String datapath = CommonUtils.APP_PATH;
  4. File dir = new File(datapath + "tessdata/");
  5. if (!dir.exists()) {
  6. dir.mkdir();
  7. try {
  8. InputStream inStream = assetManager.open("CSDL/eng.traineddata");
  9. FileOutputStream outStream = new FileOutputStream(datapath + "tessdata/eng.traineddata");
  10. byte[] buffer = new byte[1024];
  11. int readCount = 0;
  12. while ((readCount = inStream.read(buffer)) != -1) {
  13. outStream.write(buffer, 0, readCount);
  14. }
  15. outStream.flush();
  16. outStream.close();
  17. } catch (IOException e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. mTess.init(datapath, "eng");
  22. return true;
  23. }

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

英文:

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

  1. 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

  1. public static boolean init(AssetManager assetManager){
  2. mTess = new TessBaseAPI();
  3. String datapath = CommonUtils.APP_PATH;
  4. File dir =new File(datapath + "tessdata/");
  5. if(!dir.exists()) {
  6. dir.mkdir();
  7. try {
  8. InputStream inStream = assetManager.open("CSDL/eng.traineddata");
  9. FileOutputStream outStream = new FileOutputStream(datapath + "tessdata/eng.traineddata");
  10. byte[] buffer = new byte[1024];
  11. int readCount = 0;
  12. while (((readCount = inStream.read(buffer)) != -1)) {
  13. outStream.write(buffer, 0, readCount);
  14. }
  15. outStream.flush();
  16. outStream.close();
  17. } catch (IOException e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. mTess.init(datapath,"eng");
  22. return true;
  23. }

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:

确定