Ai
1 Star 0 Fork 1

jack2583/PythonExamples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Extract_Text_from_image.py 589 Bytes
一键复制 编辑 原始数据 按行查看 历史
# extract text from a img and its coordinates using the pytesseract module
import cv2
import pytesseract
# You need to add tesseract binary dependency to system variable for this to work
img =cv2.imread('img.png')
#We need to convert the img into RGB format
img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
hI,wI,k=img.shape
print(pytesseract.image_to_string(img))
boxes=pytesseract.image_to_boxes(img)
for b in boxes.splitlines():
b=b.split(' ')
x,y,w,h=int(b[1]),int(b[2]),int(b[3]),int(b[4])
cv2.rectangle(img,(x,hI-y),(w,hI-h),(0,0,255),0.2)
cv2.imshow('img',img)
cv2.waitKey(0)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jack2583/pythonExamples.git
git@gitee.com:jack2583/pythonExamples.git
jack2583
pythonExamples
PythonExamples
master

搜索帮助