Pointer to Image
Thomas Heller
theller at python.net
Wed Oct 20 20:54:00 CEST 2004
cjankowski at hbr-inc.com (Chris Jankowski) writes:
> Here is what I have now.
>
> from ctypes import *
> def myOutputHandler(infotype, param):
> outputFile.write("outhandler")
> if infotype == "OT_TEXT":
> print param
> ## return param
> ## elif infotype == "OT_ENDL":
> ## return "\n"
> ## elif infotype == "OT_ENDZ":
> ## return "\n\n"
> return
> #***************************************************************
> #* main process *
> #* myList - requests *
> #* inList - data file *
> #***************************************************************
> if __name__ == '__main__':
> outputFile=open('c:\\newOCR.txt', 'w')
> myOcr = cdll.LoadLibrary('C:\\SimpleOCR\\ocrdll.dll')
> loadImg = myOcr.LoadMultipleImg
> x = loadImg("c:\\chris.tif")
> print x
> setLanguage = myOcr.SetLanguage
> setLanguage('ENGLISH',".")
>
> setOutputMode = myOcr.SetOutputMode
> setOutputMode("OM_TEXT")
>
> setOutputHandler = myOcr.OCRSetOutputHandler
> z = id(myOutputHandler)
> errorx = setOutputHandler(z)
>
> getImage = myOcr.GetImage
> img = getImage(x,0)
>
> getNBImages = myOcr.GetNbImages
> numImg = getNBImages(x)
>
> processOCR = myOcr.OCR
> myTest = processOCR(img) ## it will run without this line.
>
> freeMultipleImage = myOcr.FreeMultipleImg
> freeMultipleImage(x)
>
> outputFile.close()
>
> This will not run it abends when I try to call the .OCR function. I
> am thinking that it cannot call the procedure to write the file. Any
> ideas?
At least one problem that I see is that you are passing
id(myOutputHandler) to setOutputHandler call. Assuming that
setOutputHandler expects a C callback function, this will not work.
Ok - send me (in private email) a pointer to where I can download the
ocrdll.dll including C header files, plus your 'chris.tif' image, and I
will take a look at it.
Thomas
More information about the Python-list
mailing list