c# - Tessnet2 returning only one character -
i'm writing application , want read image , extract text. testing porpuses i'm passing in image 6 characters. here code.
bitmap image = new bitmap("eurotext.tif"); tessnet2.tesseract ocr = new tessnet2.tesseract(); ocr.setvariable("tessedit_char_whitelist", "abcdefghijklmopqrstuvwxyz0123456789"); // if digit ocr.init(null, "eng", false); // 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);
the result 100 : ~
the second time ran returned:
100 : -
please help!!! thanks
try bigger picture. got "~" few times result when started tessnet2. after used bigger picture (textsize should more 12) programm worked fine.
to enlarge picture , try different sizes, can use trackbar , following code:
c#
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));
use "ocrimage' bitmap in 'doocr()' method
Comments
Post a Comment