How to use the pytesseract.pytesseract.image_to_string function in pytesseract

To help you get started, we’ve selected a few pytesseract examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github madmaze / pytesseract / tests / test_pytesseract.py View on Github external
def test_wrong_tesseract_cmd(test_file, test_path):
    """Test wrong or missing tesseract command."""
    import pytesseract
    pytesseract.pytesseract.tesseract_cmd = test_path
    with pytest.raises(TesseractNotFoundError):
        pytesseract.pytesseract.image_to_string(test_file)
    pytesseract.pytesseract.tesseract_cmd = 'tesseract'  # restore the def value
github madmaze / pytesseract / tests / test_pytesseract.py View on Github external
def test_proper_oserror_exception_handling(test_file, test_path):
    """"Test for bubbling up OSError exceptions."""
    import pytesseract
    pytesseract.pytesseract.tesseract_cmd = test_path
    with pytest.raises(
        TesseractNotFoundError if IS_PYTHON_2 and test_path else OSError
    ):
        pytesseract.pytesseract.image_to_string(test_file)
    pytesseract.pytesseract.tesseract_cmd = 'tesseract'  # restore the def value
github dickreuter / Poker / poker / scraper / screen_operations.py View on Github external
if binarize:
        img_resized = binarize_array(img_resized, 200)

    img_min = img_resized.filter(ImageFilter.MinFilter)
    img_mod = img_resized.filter(ImageFilter.ModeFilter)
    img_med = img_resized.filter(ImageFilter.MedianFilter)
    img_sharp = img_resized.filter(ImageFilter.SHARPEN)

    lst.append(
        pytesseract.image_to_string(img_min, 'eng', config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
            replace('$', '').
            replace('£', ''))

    if lst[0] == '' or lst[0] == '.':
        lst.append(
            pytesseract.image_to_string(img_mod, 'eng',
                                        config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                replace('$', '').
                replace('£', ''))

        if lst[1] == '' or lst[1] == '.':
            lst.append(
                pytesseract.image_to_string(img_med, 'eng',
                                            config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                    replace('$', '').
                    replace('£', ''))
            if lst[2] == '' or lst[2] == '.':
                lst.append(
                    pytesseract.image_to_string(img_sharp, 'eng',
                                                config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                        replace('$', '').
                        replace('£', ''))
github dickreuter / Poker / poker / scraper / screen_operations.py View on Github external
lst = []
    basewidth = 300
    wpercent = (basewidth / float(img_orig.size[0]))
    hsize = int((float(img_orig.size[1]) * float(wpercent)))
    img_resized = img_orig.convert('L').resize((basewidth, hsize), Image.ANTIALIAS)
    if binarize:
        img_resized = binarize_array(img_resized, 200)

    img_min = img_resized.filter(ImageFilter.MinFilter)
    img_mod = img_resized.filter(ImageFilter.ModeFilter)
    img_med = img_resized.filter(ImageFilter.MedianFilter)
    img_sharp = img_resized.filter(ImageFilter.SHARPEN)

    lst.append(
        pytesseract.image_to_string(img_min, 'eng', config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
            replace('$', '').
            replace('£', ''))

    if lst[0] == '' or lst[0] == '.':
        lst.append(
            pytesseract.image_to_string(img_mod, 'eng',
                                        config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                replace('$', '').
                replace('£', ''))

        if lst[1] == '' or lst[1] == '.':
            lst.append(
                pytesseract.image_to_string(img_med, 'eng',
                                            config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                    replace('$', '').
                    replace('£', ''))
github dickreuter / Poker / poker / scraper / screen_operations.py View on Github external
if lst[0] == '' or lst[0] == '.':
        lst.append(
            pytesseract.image_to_string(img_mod, 'eng',
                                        config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                replace('$', '').
                replace('£', ''))

        if lst[1] == '' or lst[1] == '.':
            lst.append(
                pytesseract.image_to_string(img_med, 'eng',
                                            config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                    replace('$', '').
                    replace('£', ''))
            if lst[2] == '' or lst[2] == '.':
                lst.append(
                    pytesseract.image_to_string(img_sharp, 'eng',
                                                config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                        replace('$', '').
                        replace('£', ''))
    log.debug(lst)
    for element in lst:
        if element != '':
            if 'B' in element:
                element = element.replace('B', '')
                try:
                    element = float(element) * big_blind
                except:
                    element = 0
            final_element = ''
            allow_dot = True
            for char in str(element):
                if char == '.' and not allow_dot:
github dickreuter / Poker / poker / scraper / screen_operations.py View on Github external
lst.append(
        pytesseract.image_to_string(img_min, 'eng', config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
            replace('$', '').
            replace('£', ''))

    if lst[0] == '' or lst[0] == '.':
        lst.append(
            pytesseract.image_to_string(img_mod, 'eng',
                                        config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                replace('$', '').
                replace('£', ''))

        if lst[1] == '' or lst[1] == '.':
            lst.append(
                pytesseract.image_to_string(img_med, 'eng',
                                            config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                    replace('$', '').
                    replace('£', ''))
            if lst[2] == '' or lst[2] == '.':
                lst.append(
                    pytesseract.image_to_string(img_sharp, 'eng',
                                                config='--psm 6 --oem 1 -c tessedit_char_whitelist=0123456789.$£B').
                        replace('$', '').
                        replace('£', ''))
    log.debug(lst)
    for element in lst:
        if element != '':
            if 'B' in element:
                element = element.replace('B', '')
                try:
                    element = float(element) * big_blind