我们正在使用 tesseract 进行 pan OCR,但无法检测名称和 pan 编号等详细信息 [英] we are doing pan OCR, using tesseract but is not able to detect the details like name and pan number

查看:45
本文介绍了我们正在使用 tesseract 进行 pan OCR,但无法检测名称和 pan 编号等详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们通过每次迭代将高度增加 20px 来裁剪 pan card 图像,然后我们将该图像传递给 tesseract 以执行 ocr,但我们在输出时会产生噪音.如果您有更好的图像处理解决方案或另一个库,如 cv2 那么请帮助我们.

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. 转换为灰色
  2. 阈值
  3. findContours
  4. boundingRect

这篇关于我们正在使用 tesseract 进行 pan OCR,但无法检测名称和 pan 编号等详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆