How Can i read text from image using C#

Posted by Lakhangarg under ASP.NET on 9/29/2009 | Views : 43577 | Status : [Member] [Moderator] | Replies : 11
Hello friends-

can anyone tell me how can i read the text from image. i have small idea about that. and that is we can do this using OCR. i have checked the following Code using Microsoft Office Document Imaging 12.0 library

private void ReadTextFromImage()
{

MODI.Document objModi = new MODI.Document();

objModi.Create(@"c:\AGENCYR.tiff");
objModi.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
objModi.Close(false);

MODI.Image image = (MODI.Image)objModi.Images[0];
MODI.Layout layout = image.Layout;
MODI.Word word = (MODI.Word)layout.Words[5];
//for (int j = 0; j < layout.Words.Count; j++)
//{
// // Get this word and deal with it.
// MODI.Word word = (MODI.Word)layout.Words[j];
//}

}


But the above code gave me error at objModi.Create(@"c:\AGENCYR.tiff"); IO.error

Thanks & Regards
Lakhan Pal Garg
Free Code Snippets
http://lakhangarg.blogspot.com/




Responses

Posted by: Santosh4u on: 8/23/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Akfkmupiwu

i have tried your code but it' throwing error in below line,not able to created the object
Dim objModi As MODI.Document

i guess this error is coming due to unavailability of microsoft office in my ststem , do u have any solution for this

how it will work if system doesn't contain microsoft iffice...


waiting for your quick reply

Thanks & Regards
Santosh

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 8/25/2012 [Member] Bronze | Points: 25

Up
0
Down
hi
how can i do the same operation without MS office installed in the system...

Thanks
Santosh



Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 8/25/2012 [Member] Bronze | Points: 25

Up
0
Down
any reply for the above post..
it's very urgent......

thanks
santosh

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Arronlee on: 8/8/2013 [Member] Starter | Points: 25

Up
0
Down
I have some code about OCR program using in C#.NET:
using System.IO;

using System.Drawing.Printing;
using Yiigo.Imaging;
using Yiigo.Imaging.Processing;
using Yiigo.Imaging.Recognition.OCR;

// Initialize OCR Engine
TesseractOcrEngine OcrEngine = new TesseractOcrEngine();
TesseractOcrEngine.Initialize();
TesseractOcrEngine.Translate(imageCollection, "application/msword", outputPath);
TesseractOcrEngine.Shutdown();
TesseractOcrEngine.Dispose();

// Cancel OCR in Progress
TesseractOcrEngine.PageProgressCancel = "True";

// Recognize Pages
private void button6_Click(object sender, EventArgs e)
{
_ocrDocument.Pages.Recognize(null);

string pdfFileName = @"C:\Ocr1.pdf";
_ocrDocument.Save(pdfFileName, DocumentFormat.Pdf, null);
System.Diagnostics.Process.Start(pdfFileName);
}

// Create a Searchable PDF
TesseractOcrEngine OcrEngine = new TesseractOcrEngine();
PDFGenerator PDFGenerator = new PDFGenerator();
PDFGenerator.Save = @"C: \Ocr1.pdf";

Or you can refer to its tutoial page about OCR http://www.yiigo.com/guides/csharp/how-to-ocr.shtml in C#.NET. I hope you success. Good luck.

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rimi1289 on: 8/10/2013 [Member] Starter | Points: 25

Up
0
Down
Captcha's will fail if you do that.

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabuhi_Asad on: 5/1/2014 [Member] Starter | Points: 25

Up
0
Down
Thanks for this articles. I use this program when i use modi for english text not problem. But i need use modi for azeri latin but i can not use azeri language in modi please help me

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jonygreen on: 11/14/2015 [Member] Starter | Points: 25

Up
0
Down
I'm developing an OCR application using Tesseract engine but not MODI. In my opinion, tesseract ocr is more powerful and easier to use. there is a free online ocr tool http://www.online-code.net/ocr.html using tesseract, please have a try.

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rtpharry on: 9/29/2009 [Member] [MVP] Bronze

Up
0
Down
Sounds like the app doesnt have permission to read the path C:\ or the file was not found.

Try putting a breakpoint on it and examining the exception to see what specific IO error has occured?

Is this a console app or an asp.net webpage?

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 9/29/2009 [Member] [Moderator] Silver

Up
0
Down
Hi -

Its a Web app. and the IO error is related to interop not related to permission.


Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akfkmupiwu on: 10/21/2009 [Member] Starter

Up
0
Down
Create a folder in C drive, and remove readonly access right ..
This will proceed but now it is throwing error on objModi.OCR,

Object is not initiliased...

Please reply, if you had overcome...

my code

rivate Sub ReadTextFromImage()

Dim _utput As String = ""
Dim objModi As MODI.Document
'MODI.Document objModi = new MODI.Document();
objModi = New MODI.Document()
objModi.Create("c:\omrtest\omrTest.tif")
objModi.OCR()
objModi.Close()

Dim _image As MODI.Image
_image = objModi.Images(0)

Dim _layout As MODI.Layout
_layout = _image.Layout
Dim _word As MODI.Word

For Each _word In _layout.Words
'_word = _layout.Words(i)
_utput = _utput & _word.Text
Next



End Sub


Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rai_shahid on: 11/10/2009 [Member] Starter

Up
0
Down
Dear akfkmupiwu;
Can u please describe which reference u r using for "MODI.Document "?

Best Regards;
Rai Shahid

Lakhangarg, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response