meena manne

meena manne

  • NA
  • 1
  • 2.1k

C#.net

Jan 29 2013 7:16 AM
Hi,
I want to read the text from image file of any format like .jpg,.png,.tif...
By using the following code Iam unable to read tha text in the correct format and also iam getting some error for different image formats..
And this code is unable to read Cursive Writing images and Large images.. 
Can any one Suggest me the proper code or y am getting that errors..




    private void readtext_Click(object sender, EventArgs e)
        {
            MODI.Document doc = new MODI.Document();
            doc.Create(getFileName);               // Here am getting File Sharing Voilation error for .tiff images

            doc.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true); // Here for some image formats am getting OCR running error
            
            MODI.Image img = (MODI.Image)doc.Images[0];
            MODI.Layout layout = img.Layout;

            FileStream createFile = new FileStream(getFileName + ".txt", FileMode.CreateNew);
            //save the image text in the text file 
            StreamWriter writeFile = new StreamWriter(createFile);
            writeFile.Write(img.Layout.Text);
            writeFile.Close();

            for (int i = 0; i < layout.Words.Count; i++)
            {
                MODI.Word word = (MODI.Word)layout.Words[i];

                if (extractedText.Length > 0)
                {
                    extractedText += " ";
                }

                extractedText += word.Text;
                richTextBox1.Text = extractedText;

            }
        }

Answers (1)