3
我正在用Tessnet作爲C#包裝器在tesseract引擎上運行OCR。我已經獲得了識別單詞的圖像座標,並且我想使用這些座標來僅顯示頁面的那一部分。我不關心這個頁面部分是保存爲一個單獨的圖像,還是隻是突出顯示了tif圖像的部分。如何顯示從Tessnet(Tesseract)獲得的tif座標的圖像
這裏是我當前的代碼:
TextWriter tw = new StreamWriter(@"U:\user files\bwalker\ocrTesting.txt");
Bitmap image = new Bitmap(@"u:\user files\bwalker\2849257.tif");
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,$-/#&=()\"':?"); // If digit only
ocr.Init(@"C:\Users\bwalker\Documents\Visual Studio 2010\Projects\tessnetWinForms\tessnetWinForms\bin\Release\", "eng", false); // To use correct tessdata
List<tessnet2.Word> result = ocr.DoOCR(image, System.Drawing.Rectangle.Empty);
string Results = "";
foreach (tessnet2.Word word in result)
{
Results += word.Confidence + ", " + word.Text + ", " +word.Top+", "+word.Bottom+", "+word.Left+", "+word.Right+"\n";
}
using (StreamWriter writer = new StreamWriter(@"U:\user files\bwalker\ocrTesting2.txt", true))
{
writer.WriteLine(Results);
writer.Close();
}
MessageBox.Show("Completed");
而這裏所產生的.txt文件的一部分:
14, Due, 105, 136, 1886, 1962
89, Date, 105, 136, 1978, 2064
50, 06/16/2009, 105, 136, 2298, 2504