简体   繁体   中英

Extract text from captcha image with python

Hello i am trying to learn python Currently i want to extract text from images like captcha. But i tried ocr-pytesseract and 1 more which i dont remember name. When i try to extract text from image 1 it works fine but when i want to extract text from image it gives me nothing. Any advice? Thank you. And here is my code.

from PIL import Image
from pytesseract import pytesseract

path_to_tesseract = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
pytesseract.tesseract_cmd = path_to_tesseract

path_to_image = 'alz.png'
img = Image.open(path_to_image)

#image to text
text = pytesseract.image_to_string(img)
print(text)

图片_1 图 2

I used yolov5 and with 100 images dataset I have achieved 60% accuracy on test data.

Example image

is the image probably containing handwritten or printed text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM