0

I want to extract text from image using

MODI OCR

but getting error while creating MODI document.

My Code:

private static string Scan(string imagePath)
        {
            MODI.Document md = new MODI.Document();
            md.Create(imagePath);
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
            MODI.Image image = (MODI.Image)md.Images[0];
            MODI.Layout layout = image.Layout;
            string scanned = string.Empty;

            for (int j = 0; j < layout.Words.Count; j++)
            {
                MODI.Word word = (MODI.Word)layout.Words[j];
                string text = word.Text;
                var rect = word.Rects;
                short Confidence = word.RecognitionConfidence;
                scanned += text + " ";
            }
            md.Close(false);
            return scanned;
        }

I am getting run time error on md.Create(imagePath); File extention is .tif and there is no issue with the image. What will be the reason for this error and how I can solve it?

  • Have nothing to do with image. Program can't create the file or create the constructor for the class. The class is probably loading a dll and is having issue with the dll. what using statements are at top of module? The is issues with a reference. The image file may not be compatible with the graphic card on your machine. Check you card to see if it support the image mode. – jdweng Apr 02 '20 at 09:34
  • Its a file path. – Amol Shinde Apr 30 '20 at 09:58
  • Which means you are reading a file. So the file permissions may not allow you to open the file or the image is not compatible with the MODI library. – jdweng Apr 30 '20 at 10:07

0 Answers0