问题
We are cropping the pan card image by increasing the height by 20px for every iteration and then we are passing that image to tesseract to do ocr but we are getting noise with output.if you have better solution on Image processing or another libraries like cv2 then please help us.
import pytesseract
from PIL import Image, ImageEnhance, ImageFilter
im = Image.open("image/testpan.jpg")
width = im.size[0]
height = im.size[1]
print('width,height-->',width,height)
yy='img'
zz='.jpg'
x=0
for j in range(x,height):
img2 = im.crop((0, x, width/2,x+70))
img2.save(yy+str(j)+zz)
img = Image.open(yy+str(j)+zz)
# img = img.convert("L")
img.save(yy + str(j) + zz)
text = pytesseract.image_to_string(Image.open(yy+str(j)+zz))
print('IIIII',j, text)
x=x+20
j=x
if j>height:
break
回答1:
Does this ok?
- convert to gray
threshold
findContours
boundingRect
来源:https://stackoverflow.com/questions/47709192/we-are-doing-pan-ocr-using-tesseract-but-is-not-able-to-detect-the-details-like