mardi 3 février 2015

C# OCR Tesseract bug help a bug with reflection?

Hi I am trying to work on a windows form application based off this console application http://ift.tt/1An6JZl


Now when I run my application, I get the following exception, can anyone help with some clues as to what I need to do to fix it?



System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at InteropDotNet.LibraryLoader.LoadLibrary(String fileName, String platformName)
at InteropRuntimeImplementer.LeptonicaApiSignaturesInstance.LeptonicaApiSignaturesImplementation..ctor(LibraryLoader loader)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at InteropDotNet.InteropRuntimeImplementer.CreateInstance[T]()
at Tesseract.Interop.LeptonicaApi.Initialize()
at Tesseract.Interop.TessApi.Initialize()
at Tesseract.Interop.TessApi.get_Native()
at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode, IEnumerable`1 configFiles)
at Tesseract.TesseractEngine..ctor(String datapath, String language, EngineMode engineMode)
at TesseractWindowsOCR.Form1.button2_Click(Object sender, EventArgs e) in c:\Users\USERNAME\Documents\Visual Studio 2012\Projects\TesseractWindowsOCR\TesseractWindowsOCR\Form1.cs:line 39


Here is a sample of the code at line 39



private void button2_Click(object sender, EventArgs e)
{
// string testImagePath= textBox1.Text;
string testImagePath = @"C:\recog\image.jpg";
string tessdataPath = @"C:\Users\USERNAME\Downloads\tesseract-master (1)\Samples\Tesseract.ConsoleDemo\tessdata";
string langCode = "eng";

try
{
var logger = new FormattedConsoleLogger();
var resultPrinter = new ResultPrinter(logger);
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
{
using (var img = Pix.LoadFromFile(testImagePath))
{
using (logger.Begin("Process image"))
{
var i = 1;
using (var page = engine.Process(img))
{
var text = page.GetText();
logger.Log("Text: {0}", text);
logger.Log("Mean confidence: {0}", page.GetMeanConfidence());

using (var iter = page.GetIterator())
{


Line 39 from above is specifically this


using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))






Aucun commentaire:

Enregistrer un commentaire