python 银行回执
时间: 2023-10-20 12:32:14 浏览: 124
通过使用OpenCV和Python,可以对银行回执进行文字识别。首先需要将回执图像转换为灰度图像,并进行二值化降噪处理。可以使用PIL库进行图像处理,具体代码如下:
```
import pytesseract
from PIL import Image, ImageEnhance, ImageFilter
img = Image.open('bank_receipt.png')
# 将图片转为灰度图片
img_gray = img.convert('L')
img_gray.save('./tmp/bank_receipt_gray.png')
# 转成黑白图片
img_black_white = img_gray.point(lambda x: 0 if x > 200 else 255)
pic1 = './tmp/bank_receipt_black_white.png'
img_black_white.save(pic1)
# 去掉黑点,进行二值化降噪
im = Image.open(pic1)
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
im.save('./tmp/bank_receipt_processed.png')
pytesseract.pytesseract.tesseract_cmd = 'C://Program Files (x86)/Tesseract-OCR/tesseract.exe'
text = pytesseract.image_to_string(im, lang='chi_sim')
print(text)
```
这段代码会对银行回执图像进行处理,并使用Tesseract库进行文字识别。你可以将你的银行回执图像命名为"bank_receipt.png",然后运行以上代码进行文字识别。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Python+OCR图片文字识别,验证码识别,银行卡识别](https://blog.csdn.net/weixin_43746433/article/details/89819913)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文