![](/img/trans.png)
[英]How to improve handwritten text recognition using pytesseract in small image?
[英]image recognition using pytesseract python
我有一张图片,但它无法得到价格这就是我所拥有的
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
print(pytesseract.image_to_string("local-filename.jpg"))
output
Nestle Bakers’
Choice Melts
290g/
Choc Bits
200g
Altimate
Salted Caramel
Waffle Cones
12's
~ Seitarium ss, :
et-E Ly y ”.
oss a
=| x
) " 4
oat
.
FruitCo Juice 2 Litres
‘Apple/ Apricot/ Apple, Mange,
‘Banana/ Apple Pea
Cottee’s Jams
Betty Crocker Triple
500g
Sanitarium Weet-bix
750g Chocolate Muffin Mix 500g
Ss
>
s
Authentic Thai
; Sweet Chili Sauce
Vanilla em, ‘ 725ml
Dell
cours ® ‘OCOMUT HE
Sandhurst Coconut Milk
Chelsea Berry/ Vanilla
400m!
Icing Sugar 3759
Process finished with exit code 0
这就是我要分析的图像
- 我需要的是具有相应名称的图像的价格 - 我能够提取产品名称但无法获得价格 - 我该如何实现这一点 任何帮助将不胜感激 请注意我对图像非常陌生加工
尝试了两种选择:
结果如下:
image = cv2.imread('795.png')
print(pytesseract.image_to_string(sk1)) # printed spaces i.e no result
import easyocr
reader = easyocr.Reader(['en'],gpu = False) # load model into memory once
result = reader.readtext(image,detail=0) # resul ['s7.95', 'cach']
easyocr 工作得更好!!
image = cv2.imread('795 Product.png')
reader.readtext(image,detail=0)
'''
['Nestle',
'eaa',
'Nestle',
'RuS',
'aa',
'melts',
'PARKCHOC',
'chocbts',
'Nestle Bakers',
'S',
'Choice Melts',
'290g/',
'cach',
'Choc Bits',
'200g',
'Nestle',
'"8628',
'nelts',
'(Neste)',
'JTE CHOC',
'7.95']
'''
print(pytesseract.image_to_string(image))
'''
Nestle Bakers’
Choice Melts
290g/
Choc Bits
200g
'''
easyocr 在这些图像上效果更好。
您需要探索要转发的选项。 你也可以试试@nathancy 提供的推荐How to process and extract text from image by
Google Vision API 给出了最好的结果。 谷歌云为每位用户提供 300 美元的免费积分。
下面是相同的代码片段。
def detect_text(path):
"""Detects text in the file."""
from google.cloud import vision
import io
client = vision.ImageAnnotatorClient()
with io.open(path, 'rb') as image_file:
content = image_file.read()
image = vision.Image(content=content)
response = client.text_detection(image=image)
texts = response.text_annotations
print('Texts:')
for text in texts:
print('\n"{}"'.format(text.description))
vertices = (['({},{})'.format(vertex.x, vertex.y)
for vertex in text.bounding_poly.vertices])
print('bounds: {}'.format(','.join(vertices)))
if response.error.message:
raise Exception(
'{}\nFor more info on error messages, check: '
'https://cloud.google.com/apis/design/errors'.format(
response.error.message))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.