我正在嘗試做一些簡單的OCR任務,而且我仍在搜索免費的圖書館。由於每個人似乎都使用tesseract,有人可以提供一個簡單但實用的例子,用C#或VB.NET使用tesseractengine3.dll嗎?搜索幾個小時後,我無法找到任何文件或在VS2010和.Net編譯4.tesseractengine3 .net包裝的簡單示例
3
A
回答
0
沒有爲正方體3.01 .NET包裝的例子:tesseract-ocr-dotnet
1
試試這個
Ocr ocr = new Ocr();
private void button1_Click(object sender, EventArgs e)
{
using (Bitmap bmp = new Bitmap(@"C:\OCR\ocr-test.jpg"))
{
tessnet2.Tesseract tessocr = new tessnet2.Tesseract();
tessocr.Init(null, "eng", false);
tessocr.GetThresholdedImage(bmp, Rectangle.Empty).Save("c:\\temp\\" + Guid.NewGuid().ToString() + ".bmp");
// Tessdata directory must be in the directory than this exe
Console.WriteLine("Multithread version");
ocr.DoOCRMultiThred(bmp, "eng");
Console.WriteLine("Normal version");
ocr.DoOCRNormal(bmp, "eng");
}
}
public class Ocr
{
public void DumpResult(List<tessnet2.Word> result)
{
foreach (tessnet2.Word word in result)
Console.WriteLine("{0} : {1}", word.Confidence, word.Text);
}
public List<tessnet2.Word> DoOCRNormal(Bitmap image, string lang)
{
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.Init(null, lang, false);
List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
DumpResult(result);
return result;
}
ManualResetEvent m_event;
public void DoOCRMultiThred(Bitmap image, string lang)
{
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.Init(null, lang, false);
// If the OcrDone delegate is not null then this'll be the multithreaded version
ocr.OcrDone = new tessnet2.Tesseract.OcrDoneHandler(Finished);
// For event to work, must use the multithreaded version
ocr.ProgressEvent += new tessnet2.Tesseract.ProgressHandler(ocr_ProgressEvent);
m_event = new ManualResetEvent(false);
ocr.DoOCR(image, Rectangle.Empty);
// Wait here it's finished
m_event.WaitOne();
}
public void Finished(List<tessnet2.Word> result)
{
DumpResult(result);
m_event.Set();
}
void ocr_ProgressEvent(int percent)
{
Console.WriteLine("{0}% progression", percent);
}
}
1
嘗試使用https://github.com/charlesw/tesseract庫中使用的http://vietocr.sourceforge.net/真棒開源OCR和簡單的例子看庫的源代碼中的BaseApiTester項目。
相關問題
- 1. .net UIAutomation C++中的簡單示例
- 2. 用ctypes包裝簡單的C++示例;分段錯誤
- 3. 簡單單例EJB示例
- 4. 簡單PDO包裝
- 5. 簡單的jdbc包裝器
- 6. 安裝簡單的java包
- 7. ReactiveSwift簡單示例
- 8. NSBrowser簡單示例
- 9. 簡單Silverlight示例
- 10. MKAnnotation,簡單示例
- 11. SocketAsyncEventArgs? - 簡單示例
- 12. NSXMLParser簡單示例
- 13. 簡單示例SwingUtilities
- 14. WebApplicationInitializer簡單示例
- 15. 創建簡單的C++ .net包裝。一步一步
- 16. Guice Servlets的簡單示例
- 17. 簡單的GoLang SSL示例
- 18. SenchaTouch的簡單JSON示例
- 19. 簡單的MediaElement類示例
- 20. 簡單的Java OAuth示例
- 21. 簡單的C++ hash_set示例
- 22. 簡單的sqlite示例?
- 23. 簡單的GWT OpenID示例
- 24. 簡單的Android RecyclerView示例
- 25. 模板的簡單示例
- 26. 簡單的ASP.NET MVC示例
- 27. 簡單的mod_rewrite示例
- 28. DispatcherHelper的簡單示例
- 29. 需要一個包含單位的類型的簡單示例
- 30. 最簡單的protobuf-net示例所需的幫助4
不工作=(無法加載程序集 – 2012-11-02 15:32:46