Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,16 @@ RUN pip install flashtext && \
pip install pykalman && \
/tmp/clean-layer.sh

# Tesseract and some associated utility packages
RUN apt-get install tesseract-ocr -y && \
pip install pytesseract && \
pip install wand && \
pip install pdf2image && \
pip install PyPDF && \
pip install pyocr && \
/tmp/clean-layer.sh
ENV TESSERACT_PATH=/usr/bin/tesseract

# Pin Vowpal Wabbit v8.6.0 because 8.6.1 does not build or install successfully
RUN cd /usr/local/src && \
git clone -b 8.6.0 https://github.com/JohnLangford/vowpal_wabbit.git && \
Expand Down
Binary file added tests/data/test.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/test_pytesseract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest
import io
import pytesseract
import numpy as np
from PIL import Image
from wand.image import Image as wandimage

class TestPytesseract(unittest.TestCase):
def test_tesseract(self):
# Open pdf with Wand
with wandimage(filename='/input/tests/data/test.pdf') as wand_image:
img_buffer = np.asarray(bytearray(wand_image.make_blob(format='png')), dtype='uint8')
bytesio = io.BytesIO(img_buffer)
test_string = pytesseract.image_to_string(Image.open(bytesio))
self.assertTrue(type(test_string) == str)