we are doing pan OCR, using tesseract but is not able to detect the details like name and pan number

五迷三道 提交于 2021-02-08 10:12:55

问题


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?

  1. convert to gray
  2. threshold
  3. findContours
  4. boundingRect



来源:https://stackoverflow.com/questions/47709192/we-are-doing-pan-ocr-using-tesseract-but-is-not-able-to-detect-the-details-like

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!