Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Tessnet2只返回一个字符_C#_.net_Ocr_Tesseract_Tessnet2 - Fatal编程技术网

C# Tessnet2只返回一个字符

C# Tessnet2只返回一个字符,c#,.net,ocr,tesseract,tessnet2,C#,.net,Ocr,Tesseract,Tessnet2,我正在写一个应用程序,我想读一个图像并提取文本。为了测试porpuses,我将传递一个包含6个字符的图像。这是我的密码 Bitmap image = new Bitmap("eurotext.tif"); tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.SetVariable("tessedit_char_whitelist", "abcdefghijklmopqrstuvwxyz0123456789"); // If digit o

我正在写一个应用程序,我想读一个图像并提取文本。为了测试porpuses,我将传递一个包含6个字符的图像。这是我的密码

Bitmap image = new Bitmap("eurotext.tif");
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "abcdefghijklmopqrstuvwxyz0123456789"); // If digit only
ocr.Init(null, "eng", 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);
Bitmap image=新位图(“eurotext.tif”);
tessnet2.Tesseract ocr=新的tessnet2.Tesseract();
ocr.SetVariable(“tessedit_char_whitelist”,“abcdefghijklmopqrstuvwxyz012456789”);//如果只有数字
ocr.Init(null,“eng”,false);//使用正确的数据
列表结果=ocr.DoOCR(图像,矩形,空);
foreach(tessnet2.Word输入结果)
Console.WriteLine(“{0}:{1}”,word.Confidence,word.Text);
结果是 100:~

第二次运行时返回:

100:-


请帮忙!!!谢谢

试着放大一点。当我开始使用tessnet2时,我得到了几次“~”。在我使用了更大的图片(Textsize应该大于12)后,程序运行良好

要放大图片并尝试不同的大小,可以使用轨迹栏和以下代码:

#

在“DoOCR()”方法中使用“OCRImage”位图

        Bitmap originalImage = new Bitmap(imagePath, true);
        double needdedHeigth = Convert.ToDouble(trackbar1.Value);
        double faktor = needdedHeigth / (double)originalImage.Height;
        int newWidth = Convert.ToInt32(faktor * (double)originalImage.Width);
        Bitmap ORCImage = new Bitmap(originalImage,newWidth,Convert.ToInt32(needdedHeigth));