【问题标题】:extract the main heading from the image using openCV and Tesseract in python在python中使用openCV和Tesseract从图像中提取主标题
【发布时间】:2021-04-10 06:08:22
【问题描述】:

现在我想使用 openCV 和 tesseract 来提取图像的标题。

预期输出--

[演示药品经销商]

请帮忙

【问题讨论】:

  • 你有什么代码可以使用吗?
  • 还没有。代码就是我要找的
  • 好吧,我可以给你我之前正在使用的代码,但你需要使用它。
  • 是的,给我。我会期待的。

标签: python python-3.x python-2.7 image-processing tesseract


【解决方案1】:

正如我所说,该代码用于其他用途,但我认为它可以为您提供一段很好的代码。

import numpy as np
from PIL import ImageGrab
from PIL import Image
import cv2
import time
import pytesseract

p1 = 520
p2 = 760
p3 = 1450
p4 = 830

# Those points are pixel points you will need to adjust for your frame 


while(True):
        frame = np.array(ImageGrab.grab(bbox=(p1 ,p2 , p3, p4)))
        frame = cv2.bitwise_not(frame)
        cv2.imshow("window", frame)
        pytesseract.pytesseract.tesseract_cmd = r'Path\to\tesseract.exe'
        txt = pytesseract.image_to_string(frame)
        str_num = re.findall(r'.*', txt)
        print(txt)
        print(str_num)
        print("-----------")
        if cv2.waitKey(25) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-08
    • 2018-06-18
    • 1970-01-01
    • 2012-05-23
    • 2018-08-26
    • 1970-01-01
    相关资源
    最近更新 更多