Beispiel #1
0
def getTextTest():
    image = cv2.imread("okey-check6.jpg", 0)
    api = PyTessBaseAPI()
    api.SetImage(Image.fromarray(image))
    # print api.GetUTF8Text()
    image = api.GetThresholdedImage()
    image.save("rus.new.exp6.tiff")
    text = image_to_text(image, lang="rus")
    # text = image_to_string(image, lang="rus")
    print text
    return receiptParser.getJson(text)
Beispiel #2
0
def getText(rotation, image):
    ImageFile.LOAD_TRUNCATED_IMAGES = True
    image = Image.open(image)
    image.save("loaded.jpg", dpi=(600, 600))
    image = cv2.imread("loaded.jpg", 0)
    if rotation != 0:
        image = np.rot90(image, (360 - rotation) / 90)
    # cv2.imwrite("rotated.jpg", image)
    api = PyTessBaseAPI()
    api.SetImage(Image.fromarray(image))
    image = api.GetThresholdedImage()
    text = image_to_text(image, lang="rus")
    return receiptParser.getJson(text)
Beispiel #3
0
def getText(rotation, image):
    ImageFile.LOAD_TRUNCATED_IMAGES = True
    image = Image.open(image).convert("RGB")
    b, g, r = image.split()
    image = Image.merge("RGB", (r, g, b))
    image = cv2.cvtColor(np.array(image), cv2.COLOR_BGR2GRAY)
    if rotation != 0:
        image = np.rot90(image, (360 - rotation) / 90)
    api = PyTessBaseAPI()
    api.SetImage(Image.fromarray(image))
    image = api.GetThresholdedImage()
    text = image_to_text(image, lang="rus")
    # print text
    return receiptParser.getJson(text)
Beispiel #4
0
from tesserocr import file_to_text
from tesserocr import PyTessBaseAPI

api = PyTessBaseAPI()
api.__init__(lang="rus")
api.SetImageFile("images/okey-micro.jpg")
api.GetThresholdedImage().save("dfd.png")
print file_to_text("dfd.png", lang="rus")