0

Pytesseract unable to identify proper characters as well it is predicting slashed zero wrong.

Here is my Image: enter image description here

from PIL import Image
import pytesseract
import cv2
import numpy as np

img = cv2.imread('dilation_1_0.png') #dilation_1.png working,eroded.png,eroded_1.png

text = pytesseract.image_to_string(img,config="--psm 6 oem 0")

print(text)
cv2.imshow("image",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
Sidey1238
  • 11
  • 2

1 Answers1

0

For any image, you need to preprocess it make it detect more easily some methods are

  • 1.grayscale image
  • 2.erosion
  • 3.opening - erosion followed by dilation
  • 4.canny edge detection
  • 5.skew correction
  • 6.template matching

Choose which one works best for you, or you can do it in combinations. Check the following link for detailed explanations Preprocessing for Pytesseract

NB;Make sure you installed tesseract.exe also. If it is working for normal text images, your tesseract.exe is installed(this is different from pytessearct)

Ajay Tom George
  • 1,890
  • 1
  • 14
  • 26
  • Template matching wont work in this case because this is dot matrix 8*8 pixel format characters , i have been working closely on your methods , the issue is i am unable to find proper perspective of the display of machine and canny edge works different in every image , do you have any thing in your mind that i can do so called generalized canny edges detection (means it will extract same part from different images taking from different angles ) ? – Sidey1238 Mar 06 '20 at 12:06
  • Extract same part is easy, u can slice that particular part if the object remains at the same position. If the images are similar, u can subtract the new image from the original image to get the difference and perform operations https://www.pyimagesearch.com/2017/06/19/image-difference-with-opencv-and-python/. If you want more advanced you can try EAST TEXT DETECTION https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/. Other than this check about transformations in opencv. – Ajay Tom George Mar 06 '20 at 12:31