Answer the question
In order to leave comments, you need to log in
How to improve the accuracy of reading text from an image?
from PIL import Image
from pytesseract import image_to_string
import requests
from io import BytesIO
import re
url = 'https://pbs.twimg.com/media/Dh-ZHUPX4AAQwG-.jpg:large'
response = requests.get(url)
img = Image.open(BytesIO(response.content))
text_from_image = image_to_string(img)
print(text_from_image)
Answer the question
In order to leave comments, you need to log in
Crop everything superfluous (in this case, the image of a weapon), increase sharpness, remove the background (gray) and convert the resulting image to a black and white image. After such manipulations, you will get a white background and black text on it. His tesseract recognizes much better.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question