我正在使用OCR来识别图片上的数字
var engine = new TesseractEngine(@"C:\Projects\tessdata", "eng", EngineMode.Default,);
var currentImage = TakeScreen();
var page = engine.Process(ScaleByPercent(currentImage, 500));
var text = page.GetText().Replace("\n", "");
比例尺:
public Bitmap ScaleByPercent(Bitmap imgPhoto, int Percent)
{
float nPercent = ((float)Percent / 100);
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
var destWidth = (int)(sourceWidth * nPercent);
var destHeight = (int)(sourceHeight * nPercent);
var bmPhoto = new Bitmap(destWidth, destHeight,
PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution,
imgPhoto.VerticalResolution);
Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;
grPhoto.DrawImage(imgPhoto,
new System.Drawing.Rectangle(0, 0, destWidth, destHeight),
new System.Drawing.Rectangle(0, 0, sourceWidth, sourceHeight),
GraphicsUnit.Pixel);
bmPhoto.Save(@"D:\Scale.png", System.Drawing.Imaging.ImageFormat.Png);
grPhoto.Dispose();
return bmPhoto;
}
但是我得到的结果是"10g"。
- 如何强制引擎只识别数字?
- 如何获得数字1013。