simnotpixman not presentt

ubuntu安装tesseract 进行OCR识别 - san_yun - ITeye技术网站
博客分类:
之前使用 sudo apt-get install tesseract-ocr 安装的tesseract-ocr有问题,不能使用psm参数。决定手动编译安装。下面参考别人的安装过程。
安装所需的库
sudo apt-get install libpng12-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libtiff4-dev
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install automake
pytesser 调用了 tesseract,因此需要安装 tesseract,安装 tesseract 需要安装 leptonica,否则编译tesseract 的时候出现 "configure: error: leptonica not found"。
以下都是解压编译安装的老步骤:
./configure
sudo make install
下载安装leptonica
下载安装tesseract
下载安装 tesseract 的语言数据包
解压tessdata目录下的文件(9个)到 "/usr/local/share/tessdata"目录下
注意:这个网址下载到的只有一个,不能用,使用中会报错,
下载安装 pytesser
测试pytesser
到pytesser的安装目录,创建一个test.py,python test.py 查看结果。
from pytesser import *
#im = Image.open('fnord.tif')
#im = Image.open('phototest.tif')
#im = Image.open('eurotext.tif')
im = Image.open('fonts_test.png')
text = image_to_string(im)
print text
tesseract 目录还有其他tif文件,也可以复制过来测试,上面测试的tif,png文件正确识别出文字。
pytesser的验证码识别能力较低,只能对规规矩矩不歪不斜数字和字母验证码进行识别。测试了几个网站的验证码,显示 Empty page,看来用它来识别验证码是无望了。
测试发现提高对比度后再识别有助于提高识别准确率。
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(4)
1.遇到这个错误
$ tesseract foo.png bar tesseract: error while loading shared libraries: libtesseract_api.so.3 cannot open shared object file: No such file or directory
You need to update the cache for the runtime linker. The following should get you up and running:
$ sudo ldconfig
2. 使用遇到如下错误
坑爹居然是leptonica1.69的bug,参考:https://bugs.mageia.org/show_bug.cgi?id=10411#c4,坑爹的是居然没有找到组新修复版,不得已我使用leptonica-1.68,可以了。
安装成功的提示:
yunpeng@yunpeng-duitang:~/下载/tesseract-temp$ tesseractUsage:tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]pagesegmode values are:0 = Orientation and script detection (OSD) only.1 = Automatic page segmentation with OSD.2 = Automatic page segmentation, but no OSD, or OCR3 = Fully automatic page segmentation, but no OSD. (Default)4 = Assume a single column of text of variable sizes.5 = Assume a single uniform block of vertically aligned text.6 = Assume a single uniform block of text.7 = Treat the image as a single text line.8 = Treat the image as a single word.9 = Treat the image as a single word in a circle.10 = Treat the image as a single character.-l lang and/or -psm pagesegmode must occur before anyconfigfile.Single options:
-v --version: version info
--list-langs: list available languages for tesseract engine
====================================================================================
使用pytesser遇到问题:Traceback (most recent call last):
File "test.py", line 15, in &module&
pytesser.image_to_string(data)
File "/home/jose/Documentos/Geek/pytesser.py", line 31, in image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "/home/jose/Documentos/Geek/pytesser.py", line 21, in call_tesseract
proc = subprocess.Popen(args)
File "/usr/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1213, in _execute_child
raise child_exceptionOSError: [Errno 2] No such file or directory参考:/p/pytesser/issues/detail?id=2需要安装tesseract-ocrsudo apt-get install tesseract-ocr使用: tesseract test.jpg -l
engTesseract是图盲,默认情况下只能看得懂未压缩的TIFF图像,如果直接用tesseract处理其它格式的图片,会报错如下: name_to_image_type:Error:Unrecognized image type:test.jpgIMAGE::read_header:Error:Can't read this image type:test.jpgtesseract:Error:Read of file failed:test.jpg所以我们需要用ImageMagick来转换图片格式。安装ImageMagick:sudo apt-get install imagemagick使用imagemagick转换图片格式:convert -compress none -depth 8 -alpha off
test.tif使用tesseract,结果保存在out.txt中tesseract test.tif out问题:如何让tesseract只识别字母或者数字?编辑:sudo vi /usr/share/tesseract-ocr/tessdata/configs/digitstessedit_char_whitelist abcdefghijklmnopqrstuvwxyz执行:tesseract 1.tif out nobatch digits附录:Usage:tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]pagesegmode values are:0 = Orientation and script detection (OSD) only.1 = Automatic page segmentation with OSD.2 = Automatic page segmentation, but no OSD, or OCR3 = Fully automatic page segmentation, but no OSD. (Default)4 = Assume a single column of text of variable sizes.5 = Assume a single uniform block of vertically aligned text.6 = Assume a single uniform block of text.7 = Treat the image as a single text line.8 = Treat the image as a single word.9 = Treat the image as a single word in a circle.10 = Treat the image as a single character.-l lang and/or -psm pagesegmode must occur before anyconfigfile.tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]tesseract
输出文件名 -l 字库文件 -psd pagesegmode 配置文件例如:tesseract code.jpg result
-l chi_sim -psd 7 nobatch-l chi_sim 表示用简体中文字库(需要下载中文字库文件,解压后,存放到tessdata目录下去,字库文件扩展名为.raineddata,简体中文字库文件名为:
chi_sim.traineddata)-psd 7 表示告诉tesseract code.jpg图片是一行文本
这个参数可以减少识别错误率.
默认为 3configfile 参数值为tessdata\configs 和
tessdata\tessconfigs 目录下的文件名
下载次数: 9
浏览: 547394 次
来自: 杭州
champion2008 写道不错的设计,之前我也试过,但是如 ...
楼主的意思是,想要实现搜索词的分词搜索,就必须将搜索词先调用分 ...
你好,我是个webx框架初学者。 我的同事写的ajax调用是把 ...
不错的设计,之前我也试过,但是如果在条件中不指定userid, ...

我要回帖

更多关于 media is not present 的文章

 

随机推荐