Cannt extract number from image screenshot

85 views
Skip to first unread message

Master - Event

unread,
Apr 29, 2024, 3:17:02 PM4/29/24
to tesseract-ocr
i try  extract number from screenshot but i cannt. someone help me why.
my code ```
img_data = base64.b64decode(screenshot)
image_pil = Image.open(BytesIO(img_data))
box = (0, 222, 80, 240)
cropped_img = image_pil.crop(box)
image_cv2 = np.array(cropped_img)
image_cv2 = cv2.cvtColor(image_cv2, cv2.COLOR_RGB2BGR)
gray_image = cv2.cvtColor(image_cv2, cv2.COLOR_BGR2GRAY)
resized_image = cv2.resize(gray_image, None, fx=3, fy=3, interpolation=cv2.INTER_CUBIC)
cv2.imshow('__', resized_image)
cv2.waitKey(0)
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
extracted_text = pytesseract.image_to_string(resized_image, config="-c tessedit_char_whitelist=0123456789,./")

```
Screenshot 2024-04-29 202702.png

Zdenko Podobny

unread,
Apr 29, 2024, 3:19:34 PM4/29/24
to tesser...@googlegroups.com
First, show us that you tried everything from the documentation. 

Zdenko


po 29. 4. 2024 o 21:16 Master - Event <dun...@gmail.com> napísal(a):
--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/88882fdb-4bd8-47de-b905-467a863f53adn%40googlegroups.com.

Master - Event

unread,
Apr 29, 2024, 10:09:58 PM4/29/24
to tesseract-ocr

i try invert color, white to black, try enchance image sharpness, contracst,  convert color grb, gray, config pytesseract lang, page segmentation method,  OCR engine mode but it not work :(
Vào lúc 21:19:34 UTC+2 ngày Thứ Hai, 29 tháng 4, 2024, zdenop đã viết:

René JM Clais

unread,
Apr 30, 2024, 8:50:32 AM4/30/24
to tesser...@googlegroups.com
I try your image with tesseract 5 and lang = eng   (from here tessdata/eng.traineddata at main · tesseract-ocr/tessdata · GitHub)  It works well. Please try again, I can send you my python script if needed.

Reply all
Reply to author
Forward
0 new messages