diff options
Diffstat (limited to 'module/plugins/captcha')
-rw-r--r-- | module/plugins/captcha/GigasizeCom.py | 1 | ||||
-rw-r--r-- | module/plugins/captcha/LinksaveIn.py | 5 | ||||
-rw-r--r-- | module/plugins/captcha/NetloadIn.py | 1 | ||||
-rw-r--r-- | module/plugins/captcha/ShareonlineBiz.py | 1 | ||||
-rw-r--r-- | module/plugins/captcha/captcha.py | 12 |
5 files changed, 20 insertions, 0 deletions
diff --git a/module/plugins/captcha/GigasizeCom.py b/module/plugins/captcha/GigasizeCom.py index 8fe67c0d0..d7fe25ab7 100644 --- a/module/plugins/captcha/GigasizeCom.py +++ b/module/plugins/captcha/GigasizeCom.py @@ -16,6 +16,7 @@ class GigasizeCom(OCR): def __init__(self): OCR.__init__(self) + def get_captcha(self, image): self.load_image(image) self.threshold(2.8) diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index e8487c387..6535dd11f 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -26,6 +26,7 @@ class LinksaveIn(OCR): OCR.__init__(self) self.data_dir = dirname(abspath(__file__)) + sep + "LinksaveIn" + sep + def load_image(self, image): im = Image.open(image) frame_nr = 0 @@ -53,6 +54,7 @@ class LinksaveIn(OCR): self.pixels = self.image.load() self.result_captcha = '' + def get_bg(self): stat = {} cstat = {} @@ -89,6 +91,7 @@ class LinksaveIn(OCR): max_p = value return bg + def substract_bg(self, bgpath): bg = Image.open(bgpath) img = self.image.convert("P") @@ -111,6 +114,7 @@ class LinksaveIn(OCR): if rgb_c == rgb_bg: orgpix[x, y] = (255,255,255) + def eval_black_white(self): new = Image.new("RGB", (140, 75)) pix = new.load() @@ -132,6 +136,7 @@ class LinksaveIn(OCR): self.image = new self.pixels = self.image.load() + def get_captcha(self, image): self.load_image(image) bg = self.get_bg() diff --git a/module/plugins/captcha/NetloadIn.py b/module/plugins/captcha/NetloadIn.py index 514cb259f..a8a05b210 100644 --- a/module/plugins/captcha/NetloadIn.py +++ b/module/plugins/captcha/NetloadIn.py @@ -16,6 +16,7 @@ class NetloadIn(OCR): def __init__(self): OCR.__init__(self) + def get_captcha(self, image): self.load_image(image) self.to_greyscale() diff --git a/module/plugins/captcha/ShareonlineBiz.py b/module/plugins/captcha/ShareonlineBiz.py index 7435710d5..41caa3697 100644 --- a/module/plugins/captcha/ShareonlineBiz.py +++ b/module/plugins/captcha/ShareonlineBiz.py @@ -16,6 +16,7 @@ class ShareonlineBiz(OCR): def __init__(self): OCR.__init__(self) + def get_captcha(self, image): self.load_image(image) self.to_greyscale() diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index fb85d8996..dda6fed02 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -28,18 +28,22 @@ class OCR(object): def __init__(self): self.logger = logging.getLogger("log") + def load_image(self, image): self.image = Image.open(image) self.pixels = self.image.load() self.result_captcha = '' + def unload(self): """delete all tmp images""" pass + def threshold(self, value): self.image = self.image.point(lambda a: a * value + 10) + def run(self, command): """Run a command""" @@ -50,6 +54,7 @@ class OCR(object): popen.stderr.close() self.logger.debug("Tesseract ReturnCode %s Output: %s" % (popen.returncode, output)) + def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") tmpTif = open(join("tmp", "tmpTif_%s.tif" % self.__name__), "wb") @@ -103,15 +108,18 @@ class OCR(object): except: pass + def get_captcha(self, name): raise NotImplementedError + def to_greyscale(self): if self.image.mode != 'L': self.image = self.image.convert('L') self.pixels = self.image.load() + def eval_black_white(self, limit): self.pixels = self.image.load() w, h = self.image.size @@ -122,6 +130,7 @@ class OCR(object): else: self.pixels[x, y] = 0 + def clean(self, allowed): pixels = self.pixels @@ -167,6 +176,7 @@ class OCR(object): self.pixels = pixels + def derotate_by_average(self): """rotate by checking each angle and guess most suitable""" @@ -241,6 +251,7 @@ class OCR(object): self.pixels = pixels + def split_captcha_letters(self): captcha = self.image started = False @@ -280,6 +291,7 @@ class OCR(object): return letters + def correct(self, values, var=None): if var: result = var |