أولا لمن لا يعرف ال OCR :
يقوم هذا البرنامج باستخراج الكتابة من ملف صورة .. وتحويلها الى Text يمكن نسخها والتعديل عليها
1- نقوم باضافة Microsoft Office Document Imaging 11.0 Type Library من ال References
من ال COM .... وهذا يؤدي الى اضافة MODI Namespace إلى مشروعنا .
2- نقوم بتعريف document من نوع MODI.Document
ونربطها بمتغير من نوع AxMODI.AxMiDocView ... والذي سوف يتم عرض ال Document بداخله
private MODI.Document _MODIDocument; private AxMODI.AxMiDocView axMiDocView1; private string fileName;// مسار الصورة التي سوف يتم تحليلها _MODIDocument = new MODI.Document(); _MODIDocument.Create(fileName); axMiDocView1.Document = _MODIDocument; axMiDocView1.Refresh();
3- لبدأ عملية التحليل .. بكل بساطة نستدعي ال Method التالي :
_MODIDocument.OCR(MODI.MiLANGUAGES.miLANG_SYSDEFAULT,true,true);
ال Parameter الأول :
Language : وتم اعطاء System Default Language
ال Parameter الثاني :
OCROrientImage : Specifies whether the OCR engine attempts to determine the orientation of the page
ال Parameter الثالث :
OCRStraightenImage : Specifies whether the OCR engine attempts to "de-skew" the page to correct for small angles of misalignment from the vertical
4- اذا تمت العملية بنجاح .. ال Text التي تم الحصول عليها تكون موجودة في :
axMiDocView1.TextSelection.Text
بعض الملاحظات :
1- أنواع الصور التي يتم التعامل معها :
يجب ان تكون الصور من نوع TIFF, multi page TIFF and BMP فقط
2- قبل استدعاء ال MODIDocument.OCR يجب أن نقوم باختيار المنطقة التي سوف يتم تحليلها :
إما بالماوس أو بالكود التالي :
int pageNumber = 0; axMiDocView1.SelectAll(pageNumber);
صورة عن البرنامج :

