Mega Code Archive

 
Categories / Delphi / Ide Indy
 

OCR in Delphi

Title: OCR in Delphi Question: How to do some character recognition in delphi. The simpliest way Answer: Before reading, please excuse me for my poor english ... I was looking for nights how to do some character recognition within delphi. Looking after many good but not freeVCls I tried to use the Active X given with Microsoft Office named Microsoft Office Document Imaging. MODI for the guys (or girl) who knows. You can find some more informations on this control in : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Mspauto/html/diproTextSelection_HV01040650.asp Before starting : Go in the Component menu of Delphi and select Import An activeX control. Select the "Microsoft Office Document Imaging 11.0 Type Library" and click on "Create the unit". After doing so, the component will be in the ActiveX component page of the VCL. -- Your ready to Go. Here is a code sample : In the uses clause add : ComObj, MODI_TLB units. Drop a MiDocView object from the activeX page onto your form. Add a button and add a Tmemo procedure TForm.Button1Click(Sender: TObject); Var doc :IDocument; Img :IImage; Layout :ILayout; begin doc := IDispatch(CreateOleObject('MODI.Document')) as IDocument; doc.create(FileName); // just put here the filename of an image doc.OCR(miLANG_ENGLISH,true,true); Img := IDispatch(doc.Images[0]) as IImage; Layout := IDispatch(Img.Layout) as ILayout; Memo1.Lines.Add(Layout.Text); MiDocView1.Document := doc; doc.Close(false); Img := nil; Layout := nil; end; You can also recognize character in other language, go in the MODI_TLB.pas file to know are the other supported languages by this control. Hope this will help. If someone find this interesting, I'm still looking how to select the area of the caracter recognition. I am still investiganting and I will post my new discovers. Bye from south of France.