The given key was not present in the dictionary in Aspose.OCR

Hi all,

I wanted to try the trial version of Aspose.ocr and include the latest version via nuget console. I tried a simple ocr process:

 static void Main(string[] args)
    {
        var engine = new OcrEngine();
        string path = System.IO.Directory.GetCurrentDirectory() + "\\Sampleocr.bmp";

        engine.Image = ImageStream.FromFile(path);

        try
        {
            if (engine.Process())
            {
                Console.WriteLine(engine.Text);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }
}

and got an error says

Aspose.OCR.OcrException: Error occurred during recognition. —> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at . ?( )
at ? .(? , ? , ? , OCRConfig, ? )
at ? . ?(? , OCRConfig )
at Aspose.OCR.OcrEngine.()
— End of inner exception stack trace —
at Aspose.OCR.OcrEngine.()
at Aspose.OCR.OcrEngine.Process()
at ConsoleApp1.Program.Main(String[] args) in C:\AsposeOCR\ConsoleApp1\ConsoleApp1\Program.cs:line 22

As I said earlier, I am just using it for evaluation purposes and I do not know where I am doing wrong.

@ilhank

Thanks for contacting support.

Would you please share your sample Image file with us. We will test the scenario in our environment and address it accordingly.

Sampleocr.jpg (37.4 KB)
Sure,
In the code, I posted I used a .bmp file. However, I could not upload it since uploader does not let me upload the .bmp file. I covert it to .jpg and tried it with the code I provided you with and got the same error.

@ilhank

Thanks for sharing sample image.

You could add .bmp file into ZIP Archive and upload with your post.

We have tested the scenario in our environment using Aspose.OCR for .NET 17.11 and were unable to notice any issue. For your kind reference, an output screenshot is also attached.
OCROutput.png (2.7 KB)

Would you please make sure to use latest version of the API and in case issue still persists, please share a sample console application with us which is able to reproduce the issue. We will test the scenario in our environment and address it accordingly.

Ali thank you so much for your reply,

I tried to upload it but having a problem with uploading. I am trying to send the whole solution and it is nearly 60 MB. Is there any other way to send it to you?

@ilhank

Thanks for writing back.

You may please upload your sample project to Dropbox or Google Drive and share the link with us.

Here is the link : ConsoleApp1_OCR_ASPOSE.zip - Google Drive

@ilhank

Thanks for sharing sample project.

We have tested the scenario by running your project with Visual Studio 2017 Community in Windows 10 EN x64 and were still unable to notice the issue. Please check attached screenshot. OCROutput_.png (15.9 KB)

It seems like it is your environment specific issue. Would you please share your environment details with us like OS name and version, Visual Studio version, etc. You can also try to run the program on another machine and provide your feedback about the results you got there. We will further proceed to assist you accordingly.

I am also using Win10 EN x64 and I have Visual Studio 2013 Ultimate. I just created a new solution in a new environment, I installed the latest version of Aspose.OCR and could not compile the project because it was initially targeting to the dll in …packages\Aspose.OCR.17.11.0\lib\net45. Everything was seemed to be ok since my target framework is .net Framework 4.5. Then without changing my target framework, I referenced to the dll which is in …packages\Aspose.OCR.17.11.0\lib\net40-client, then it worked. I do not know why I could not use the one in the lib\net45 folder.

@ilhank

You may have faced an issue because the DLL in ...packages\Aspose.OCR.17.11.0\lib\net45 is built with framework version 4.5.2 which is higher than 4.5. You may surely use the assembly present in packages\Aspose.OCR.17.11.0\lib\net40-client with targeting framework 4.0 as well as 4.5. In case you face any other issue, please feel free to let us know.