C# Tessnet2 OCR只返回数字
我试图在c#应用程序中使用tessnet2从图像中读取文本。 这是我的代码:C# Tessnet2 OCR只返回数字,c#,ocr,tesseract,tessnet2,C#,Ocr,Tesseract,Tessnet2,我试图在c#应用程序中使用tessnet2从图像中读取文本。 这是我的代码: string valoare=""; lblOCR.Text = ""; Bitmap image = new Bitmap(@"C:\Stamp\test.png"); tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.Init(@"F:\Manipulare pdf\bin(1)\Release32\tessdata", "eng", false);
string valoare="";
lblOCR.Text = "";
Bitmap image = new Bitmap(@"C:\Stamp\test.png");
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.Init(@"F:\Manipulare pdf\bin(1)\Release32\tessdata", "eng", false);
var rect = new System.Drawing.Rectangle();
List<tessnet2.Word> result = ocr.DoOCR(image, rect);
int lc = tessnet2.Tesseract.LineCount(result);
foreach (tessnet2.Word word in result)
{
lblOCR.Text += word.Text+" "+word.Confidence+"<br/>";
}
string valoare=“”;
lblOCR.Text=“”;
位图图像=新位图(@“C:\Stamp\test.png”);
tessnet2.Tesseract ocr=新的tessnet2.Tesseract();
初始化(@“F:\Manipulare pdf\bin(1)\Release32\tessdata”,“eng”,false);
var rect=new System.Drawing.Rectangle();
列表结果=ocr.DoOCR(图像,矩形);
int lc=tessnet2.Tesseract.LineCount(结果);
foreach(tessnet2.Word输入结果)
{
lblOCR.Text+=word.Text+“”+word.Confidence+“
”;
}
结果字符串只包含数字,但我的图片包含字母,我不明白为什么
谢谢请尝试再次放入语言包
Tessnet2使用语言包2及更高版本。我知道我已经很晚了。我在别的地方找到了解决办法 我的ocr配置为只查看数字。但我看你没有这句台词:
ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // If digits only
对我来说,删除它成功了。可能您需要进行类似的配置。是否与图像的方向有关?我不确定他们是否为C++包装器实现了“自动”的定位,我知道它是C++源代码…