Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mike Gagnon - Re: OCR code

Status
Not open for further replies.

Imaginecorp

IS-IT--Management
Jan 7, 2007
635
US
Mike I came across this code you wrote for converting .Tiff to Text.
Code:
Local miDoc,miLayout,lcStr
lcStr=''
CREATE CURSOR mondocument (mondococr m)
miDoc = Createobject('MODI.Document')
miDoc.Create( "C:\era\beacon0001.tif")
miDoc.Images(0).OCR
miLayout = miDoc.Images(0).Layout
strLayoutInfo ="Language: " + Transform(miLayout.Language )+Chr(13)+Chr(10)
strLayoutInfo=strLayoutInfo+"Number of characters: " + Transform(miLayout.NumChars)+Chr(13)+Chr(10)
strLayoutInfo=strLayoutInfo+"Number of fonts: "+ Transform(miLayout.NumFonts )+Chr(13)+Chr(10)
strLayoutInfo=strLayoutInfo+"Number of words: " + Transform(miLayout.NumWords)+Chr(13)+Chr(10)+Chr(13)+Chr(10)
strLayoutinfo = strLayoutinfo+miLayout.text
INSERT INTO mondocument (mondococr) VALUES (strLayoutinfo)
MODIFY MEMO mondocument.mondococr
This is exactly what I need but is there a way to retain the layout?
I need to convert and read an incoming fax to be able to populate a VFP9 form.
Any help/advice would be greatly appreceated... Thanks
 
Hello Mike;
This is for a dispatch system for a roadside assistance company. We get the dispatch via fax. The HP officejet 8500 all in one printer, stores the fax in a network folder. When a Fax comes in the user clicks a button which starts the conversion, and displays the information in a form after populating the dispatch database.
Using your code without the document stats, I could use GETWORDCOUNT() and GETWORDNUM() to populate the database BUT we deal with 11 motor clubs all sending in different formats and one motor club that sends faxes in 3 different format.
Another problem is when certain information is missing or present it would throw the “GET…” functions off and hard coding word locations would not work.
In your experience is there any way for the conversion to keep the info intact?

Example:
Address: 2970 some street, some town, some state 12345

Now all I have to do is search for “Address:” and take everything after the “:”
All advice/help would be greatly appreciated…. Thanks

 
Sorry wrong way to upload a file... will try again
 
Not that I can see. Any not with Microsoft Office Document Imaging. The activex is too limited. Even using OneNote from Microsoft does not maintain the formating.
I noticed you uploaded a Gif file rather than a Tif file. Is that the format you receive your faxes?
There is a free OCR that claims to keep the formatting, but it reads Tif files and you cannot automate it.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks Mike; I got it figuired using memo functions etc.
We get a Fax which gets converted to a .tif file (default on the all in one printer).

Now I have a different problem.
When I rerun the program within the same vfp session line

Code:
miDoc.Create( "C:\era\roadamerica.tif")

returns an error

Code:
"OLE exception error: Exception code c000005, OLE object may be corrupt"

If I restart VFP it works. seems like something is hanging...
Any ideas....
Thanks again
 
Fixed it... Not the most elegent way, but created a seperate .exe that only converts the .tif into text and stores in the memo field.
Seemed like some refrences were left hanging and the code could not "Create". thus throwing the un-informative error unless VFP was shut down and restarted. Will keep looking into this and if a solution exists will post for anyone else trying to OCR.
Anybody else here who might have an insight into this problem - please post... Thanks
 
Quick Question:
where does the Modi.ocx reside. On another machine running XP and another one running windows 7, its not found... Do I have to download it?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top