1 Star 3 Fork 1

小luo爱学习/python截取发票图片指定位置并识别

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
1.py 912 Bytes
一键复制 编辑 原始数据 按行查看 历史
小luo爱学习 提交于 4年前 . 提交代码
import os
import cv2
# 遍历指定目录,显示目录下的所有文件名
pathDir = os.listdir('img/') # 列出文件路径中的所有路径或文件
for allDir in pathDir:
child = os.path.join('img/', allDir)
dest = os.path.join('img_cut/',allDir)
if os.path.isfile(child):
image = cv2.imread(child)
sp=image.shape # 获取图像形状:返回【行数值,列数值】列表
sz1=sp[0] # 图像的高度(行 范围)
sz2=sp[1] # 图像的宽度(列 范围)
#sz3 = sp[2] # 像素值由【RGB】三原色组成
print(sz1)
print(sz2)
#你想对文件的操作对应的坐标,想要截取的位置
a=int(5) # x start
b=int(111) # x end
c=int(567) # y start
d=int(813) # y end
cropImg = image[a:b,c:d] #裁剪图像
cv2.imwrite(dest,cropImg) #写入图像路径
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/sjzjams/python-pytesseract-image_to_string.git
git@gitee.com:sjzjams/python-pytesseract-image_to_string.git
sjzjams
python-pytesseract-image_to_string
python截取发票图片指定位置并识别
master

搜索帮助