1# ... 2# 3# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> 4# 5# This work is licensed under the terms of the GNU GPL, version 2 or 6# later. See the COPYING file in the top-level directory. 7 8import logging 9 10from . import run_cmd 11 12def tesseract_ocr(image_path, tesseract_args=''): 13 console_logger = logging.getLogger('console') 14 console_logger.debug(image_path) 15 (stdout, stderr, ret) = run_cmd(['tesseract', image_path, 16 'stdout']) 17 if ret: 18 return None 19 lines = [] 20 for line in stdout.split('\n'): 21 sline = line.strip() 22 if len(sline): 23 console_logger.debug(sline) 24 lines += [sline] 25 return lines 26