<filename>ocrTessExample.py
import cv2.cv as cv
import tesseract
import argparse

############################# testing part  #########################
#argument parserap = argparse.ArgumentParser()
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required = True, help = "path to the image file")
args = vars(ap.parse_args())

#open arg file
image=cv.LoadImage(args["image"], cv.CV_LOAD_IMAGE_GRAYSCALE)

api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
#api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
api.SetPageSegMode(tesseract.PSM_AUTO)
tesseract.SetCvImage(image,api)
text=api.GetUTF8Text()
conf=api.MeanTextConf()
print text

<filename>ocrTessExample.py
import cv2.cv as cv
import tesseract
import argparse

############################# testing part  #########################
#argument parserap = argparse.ArgumentParser()
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required = True, help = "path to the image file")
args = vars(ap.parse_args())

#open arg file
image=cv.LoadImage(args["image"], cv.CV_LOAD_IMAGE_GRAYSCALE)

api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
#api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)
api.SetPageSegMode(tesseract.PSM_AUTO)
tesseract.SetCvImage(image,api)
text=api.GetUTF8Text()
conf=api.MeanTextConf()
print text

############################# testing part  ######################### #argument parserap = argparse.ArgumentParser() #open arg file #api.SetPageSegMode(tesseract.PSM_SINGLE_WORD)