Q:

C# .net wrapper for tessnet

I try to write wrapper for tessnet OCR library. I am getting an error saying "Cannot marshal 'return value': Generic types cannot be marshaled." for this code section
List<Word> k = OCRWrapper.DoOCR(new Bitmap(@"C:\Data\pdf2image\auto.png"), new Rectangle(0, 0, 55, 27));

My wrapper class is 
class OCRWrapper
{
    [DllImport("TrueMarble.dll")]
    public static extern List<Word> DoOCR(Bitmap b, Rectangle rec);
}

please help me, can any one guide me to write this code 
Thanx!

A:

You are on the wrong track with this, Tessnet already is a managed class wrapper around Tesseract.  You don't use [DllImport], just add a reference to the assembly and use the classes directly.  Sample code and assembly download is available here.
Bitmap image = new Bitmap("eurotext.tif");
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // If digit only
ocr.Init(@"c:\temp", "fra", false); // To use correct tessdata

List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
foreach (tessnet2.Word word in result)
    Console.WriteLine("{0} : {1}", word.Confidence, word.Text);

