简体   繁体   English

Tess-两个OCR不起作用

[英]Tess-two OCR not working

im trying to get text from an image using tess-two on android. 我试图在android上使用tess-two从图像获取文本。

But its giving me a really bad result 但这给了我一个非常糟糕的结果

01-16 12:00:25.339: I/Tesseract(native)(29038): Initialized Tesseract API with language=spa

and like 30 seconds later it shows this as result string: 大约30秒后,它显示为结果字符串:

{ga
 .,
r¿
 y“: A
  r M í
:3 
'  ‘Ev’.-:.. -: A 7
 » w- ?" _
 Á.» ¿"A ¿rw-V r
 mjÏfn 'n’n . Y
' "\'ZA".‘.¡ A‘ :‘ïvAv- « ‘
:"Éf‘Ï'" -Ï«l :‘,.v:...»- .
 ' RFI' .. ’ g)" 3;:- 1-;4',
= * ¿,arifgggk mw; .1.  ,
'  "53» "J
't‘ ‘ ¿Las ;.‘».L',-‘»
 ' '  'N‘“ "“=: - '. V  .  ‘9!
5.? ' “F a .“ 
Y , <_  7- . 7.-, .
;«  z "1:;2wr . A - . ' -»‘ 5“:
“4-”, ¿rn 73:33: w v'.‘ ¿a ‘ A ,z, v VA
...,,« ' 'Q ' ‘ 4 214€. 5 . AV ¿JL y .13:
1  » . 21mm; » ¿ati-“fl ¿ab-1377*“ w”
. x ‘ ‘ ú  F v'v: 
1 . ' . ; (“ya  í .

of course thats not correct, im using this photo: 当然那是不正确的,即时通讯使用这张照片: 在此处输入图片说明

i have tried it a lot of times, always similar result. 我已经尝试了很多次,总是得到相似的结果。

What can be wrong, this is my code using tess-two 可能会出错,这是我使用tess-two的代码

    TessBaseAPI baseApi = new TessBaseAPI();
    baseApi.init("/mnt/sdcard/external_sd/tess/", "spa",TessBaseAPI.OEM_TESSERACT_ONLY);
    baseApi.setImage(bitmap);
    String recognizedText = baseApi.getUTF8Text();
    Log.d("Texto leido", "texto: "+recognizedText);
    baseApi.end();

and this is how i get bitmap from file 这就是我从文件中获取位图的方式

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap bitmap = BitmapFactory.decodeFile(photopath.getAbsolutePath(), options);

im using that bitmap on a imageview and it seems correct, so i cant find why its working that bad. 我在imageview上使用该位图,它似乎是正确的,所以我找不到为什么它的效果不好。

Any idea? 任何想法?

Here change the language code for image text language. 在此更改图像文本语言的语言代码。

eg: if you want English language text recognition, then use 'eng', or Spanish language for 'spa' 例如:如果您想要英语文本识别,则使用“ eng”或西班牙语作为“ spa”

1) 1)

   TessBaseAPI baseApi = new TessBaseAPI();
        baseApi.init("/mnt/sdcard/external_sd/tess/", "eng");
        baseApi.setImage(bitmap);
        String recognizedText = baseApi.getUTF8Text();
        Log.d("Texto leido", "texto: "+recognizedText);
        baseApi.end();

2)Download language package files from Download here you must download osd.traineddata.zip file and tesseract-ocr-3.01.eng.tar.zip(here eng for English, spa for Spanish.. etc) files paste into assets folder. 2)从“ 下载此处”下载语言包文件。您必须下载osd.traineddata.zip文件和tesseract-ocr-3.01.eng.tar.zip(此处eng为英文,spa为西班牙文..等)文件粘贴到资产文件夹中。

3)before set bitmap convert into gray scale image bitmap 3)在设置位图之前将其转换为灰度图像位图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM