From c5234a8b3d223f9860de161894ae8a4623e1ae05 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Wed, 17 Jun 2009 23:18:27 +0200 Subject: plugins can import captcha method, see #6 --- captcha/captcha.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'captcha/captcha.py') diff --git a/captcha/captcha.py b/captcha/captcha.py index 361893fa3..de3e61cf0 100644 --- a/captcha/captcha.py +++ b/captcha/captcha.py @@ -2,13 +2,19 @@ import Image import ImageOps import subprocess -class Ocr(object): - def __init__(self, image): +class OCR(object): + def __init__(self): + pass + + def load_image(self, image): self.image = Image.open(image) self.pixels = self.image.load() self.image_name = 'captcha_clean.png' self.result_captcha = '' + def unload(): + """delete all tmp images""" + pass def threshold(self, value): self.image = self.image.point(lambda a: a * value +10) @@ -27,7 +33,7 @@ class Ocr(object): self.result_captcha = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].replace('\n','') def get_captcha(self): - pass + raise NotImplementedError def to_greyscale(self): if self.image.mode != 'L': @@ -74,5 +80,5 @@ class Ocr(object): if __name__ == '__main__': - ocr = Ocr('gigasize-com/7.jpg') + ocr = OCR('gigasize-com/7.jpg') print ocr.get_captcha() -- cgit v1.2.3