So I'm trying to get the orientation of a table image with Tesseract's image_to_osd()
. Full code here:
import cv2
from PIL import Image
import pytesseract
from skimage import io
from skimage.transform import rotate
import os
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'
# pytesseract.pytesseract.osd_filename = r'/usr/share/tesseract-ocr/tessdata/osd.traineddata'
image_path = "my_image.jpg"
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
text = pytesseract.image_to_osd(image,config="osd --psm 0",output_type=pytesseract.Output.DICT)
orientation = int(text.split('Rotate: ')[-1])
However, every time I run the code I get this error: [Errno 2] No such file or directory: '/tmp/tess_838ogh77.osd' The file name of the temporary file is different every time. I checked in the pytesseract script and the file is actually created but apparently it can't be found. I'm using tesseract 3.04.01 on Ubuntu 16.04 What could be the issue here?
Thanks a lot.