苔丝个OCR不工作 [英] Tess-two OCR not working

查看:251
本文介绍了苔丝个OCR不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用苔丝两Android上获得从图像中的文本。

im trying to get text from an image using tess-two on android.

但它给了我一个非常糟糕的结果。

But its giving me a really bad result

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

和像30秒后它表明这是结果字符串:

and like 30 seconds later it shows this as result string:

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

什么可能是错的,这是用我的code苔丝个

What can be wrong, this is my code using 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);

使用上的ImageView位图IM和它似乎正确的,所以我找不到为什么它的工作坏。

im using that bitmap on a imageview and it seems correct, so i cant find why its working that bad.

任何想法?

推荐答案

下面更改语言code图像文本的语言。

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'

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)下载语言包文件下载这里
您必须下载osd.traineddata.zip文件和tesseract-ocr-3.01.eng.tar.zip(这里承揽英语,西班牙语温泉..等)的文件粘贴到资产的文件夹。

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.

3)设置位图前转换成灰度图像的位图

3)before set bitmap convert into gray scale image bitmap

这篇关于苔丝个OCR不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆