提问人:coder 提问时间:11/14/2023 更新时间:11/14/2023 访问量:28
Tesseract OCR 使用 asp.net mvc 而不是结构方式从图像文件中提取文本
Tesseract OCR Extracting text from image file using asp.net mvc but not structure way
问:
Tesseract OCR 在视图包中使用 mvc 从图像文件中提取文本 asp.net 从图像文件中提取文本后获取如下所示的文本
Name raj mobile 90000000 address 5-848-7 india
以下是从图像文件中提取文本的代码
public ActionResult Index(HttpPostedFileBase postedFile)
{
if (postedFile != null)
{
string filePath = Server.MapPath("~/Uploads/" + Path.GetFileName(postedFile.FileName));
postedFile.SaveAs(filePath);
string extractText = this.ExtractTextFromImage(filePath);
ViewBag.Message = extractText.Replace(Environment.NewLine, "<br />");
}
return View();
}
private string ExtractTextFromImage(string filePath)
{
string path = Server.MapPath("~/") + Path.DirectorySeparatorChar + "tessdata";
using (TesseractEngine engine = new TesseractEngine(path, "eng", EngineMode.Default))
{
using (Pix pix = Pix.LoadFromFile(filePath))
{
using (Tesseract.Page page = engine.Process(pix))
{
return page.GetText();
}
}
}
}
在下一行中,OCR 提取文本到视图袋
ViewBag.Message = extractText.Replace(Environment.NewLine, "<br />");
文字如下图所示
ViewBag.Message="Name raj mobile 90000000 address 5-848-7 india";
我不明白如何实现键值对以返回查看袋文本段落以发送以下三个字段编辑表单,以便用户检查和验证并保存此数据。
Name : raj
Mobile: 90000000
address: 5-848-7 india
在真实场景中,我的图像文件如下所示
https://nanonets.com/blog/how-to-ocr-purchase-orders-for-automation/#digitising-purchase-orders
将段落数据转换为实际显示数据。
答: 暂无答案
评论