参考:
[url]http://code.google.com/p/tesseract-ocr/[/url]
[url]https://stackoverflow.com/questions/2363490/limit-characters-tesseract-is-looking-for[/url]
[url]http://resources.infosecinstitute.com/case-study-cracking-online-banking-captcha-login-using-python/[/url]
[color=blue][b]1. 安装:[/b][/color]
[color=blue][b]2. 预先处理图片,代码片段:[/b][/color]
[color=blue][b]3. 使用tesseract命令识别图片:[/b][/color]
[quote]0 = Orientation and script detection (OSD) only.
1 = Automatic page segmentation with OSD.
2 = Automatic page segmentation, but no OSD, or OCR
3 = 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.
[color=blue]7 = Treat the image as a single text line.[/color]
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.[/quote]
[color=blue][b]4. 限制Tesseract搜索的字符[/b][/color]
1)在tessdata/configs文件夹中创建一个新的配置文件
2)在配置文件中添加如下:
[quote]tessedit_char_whitelist abcdefghijklmnopqrstuvwxyz [/quote]
3. 使用新建的配置文件调用tessdata命令。
[color=blue][b]5. 训练Tesseract识图能力[/b][/color]
参考文章:
[url]http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract2[/url]
[url]http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract3[/url]
[url]http://code.google.com/p/tesseract-ocr/[/url]
[url]https://stackoverflow.com/questions/2363490/limit-characters-tesseract-is-looking-for[/url]
[url]http://resources.infosecinstitute.com/case-study-cracking-online-banking-captcha-login-using-python/[/url]
[color=blue][b]1. 安装:[/b][/color]
apt-get install tesseract-ocr
[color=blue][b]2. 预先处理图片,代码片段:[/b][/color]
from PIL import Image
import os
import time
def crack(cap_name):
img = Image.open(cap_name+'.JPEG')
img = img.convert("RGB")
pixdata = img.load()
for y in xrange(img.size[1]):
for x in xrange(img.size[0]):
if pixdata[x, y][0] < 90:
pixdata[x, y] = (0, 0, 0, 255)
for y in xrange(img.size[1]):
for x in xrange(img.size[0]):
if pixdata[x, y][1] < 136: pixdata[x, y] = (0, 0, 0, 255) for y in xrange(img.size[1]): for x in xrange(img.size[0]): if pixdata[x, y][2] > 0:
pixdata[x, y] = (255, 255, 255, 255)
ext = ".tif"
img.save(cap_name + ext)
[color=blue][b]3. 使用tesseract命令识别图片:[/b][/color]
tesseract imagename outbase [-l lang] [-psm N] [configfile ...]
[quote]0 = Orientation and script detection (OSD) only.
1 = Automatic page segmentation with OSD.
2 = Automatic page segmentation, but no OSD, or OCR
3 = 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.
[color=blue]7 = Treat the image as a single text line.[/color]
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.[/quote]
[color=blue][b]4. 限制Tesseract搜索的字符[/b][/color]
1)在tessdata/configs文件夹中创建一个新的配置文件
2)在配置文件中添加如下:
[quote]tessedit_char_whitelist abcdefghijklmnopqrstuvwxyz [/quote]
3. 使用新建的配置文件调用tessdata命令。
[color=blue][b]5. 训练Tesseract识图能力[/b][/color]
参考文章:
[url]http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract2[/url]
[url]http://code.google.com/p/tesseract-ocr/wiki/TrainingTesseract3[/url]