How do I get pytesseract to find an integer value from this screenshot?

38 Views Asked by At

I am running tesseract v5.3.3.20231005

enter image description here

I am trying to turn the number in this image above into an integer value.

Here is my code:

# Convert the extracted text to a number (if it contains numerical characters)
number_text = pytesseract.image_to_string(buy_offers_screenshot)

buy_offer = float(''.join(filter(str.isdigit, number_text)))
print(buy_offer)

But the response I get is:

Traceback (most recent call last):
  File "C:\python\tesseract.py", line 8, in <module>
    buy_offer = float(''.join(filter(str.isdigit, number_text)))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: ''

Could anyone point me in the right direction on how to get an integer value from this screenshot?

0

There are 0 best solutions below