diff options
Diffstat (limited to 'pyload/plugin/OCR.py')
-rw-r--r-- | pyload/plugin/OCR.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pyload/plugin/OCR.py b/pyload/plugin/OCR.py index df32b9f23..df5eeea1f 100644 --- a/pyload/plugin/OCR.py +++ b/pyload/plugin/OCR.py @@ -26,21 +26,26 @@ class OCR(Base): __license = "GPLv3" __authors = [("pyLoad Team", "admin@pyload.org")] + 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 deactivate(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""" @@ -51,6 +56,7 @@ class OCR(Base): 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, pagesegmode=None): # tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") try: @@ -113,15 +119,18 @@ class OCR(Base): except Exception: 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 @@ -132,6 +141,7 @@ class OCR(Base): else: self.pixels[x, y] = 0 + def clean(self, allowed): pixels = self.pixels @@ -177,6 +187,7 @@ class OCR(Base): self.pixels = pixels + def derotate_by_average(self): """rotate by checking each angle and guess most suitable""" @@ -250,6 +261,7 @@ class OCR(Base): self.pixels = pixels + def split_captcha_letters(self): captcha = self.image started = False @@ -289,6 +301,7 @@ class OCR(Base): return letters + def correct(self, values, var=None): if var: result = var |