Skip to content

C#.net

meena manne

Asked Jan 29, 2013, 2:16 AM EST1 answer
Share
LinkedInX
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..




TypeScript
    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
            
Java
            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;


            }
        }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.