2016-09-28 188 views
12

我已经在我的linux环境中安装了tesseract。tesseract没有得到小标签

它的工作原理,当我执行类似

# tesseract myPic.jpg /output 

但我的照片有一些小标签和正方体没有看到他们。

是否有可用于设置音高或类似的选项?

文本标签的例子:

enter image description here

有了这个PIC,正方体不承认任何价值...

但有了这个图:

enter image description here

我有以下输出:

J8 

J7A-J7B P7 \ 

2 
40 50 0 180 190 

200 

P1 P2 7 

110 110 
\ l 

例如,在这种情况下,90(上左上)不是由正方体看到...

我认为它只是界定或somethink这样,没有一个选择吗?

THX

回答

5

为了从正方体(以及任何OCR引擎)得到准确的结果,您需要遵循一些准则,可以在我对这个职位的回答中可以看出: Junk results when using Tesseract OCR and tess-two

这里是它的要点:

  • 使用(如果需要)的高分辨率图像300 DPI最小

  • 确保有图像没有阴影或弯曲

  • 如果有任何偏差,则需要修复代码的图像之前,OCR

  • 使用字典,以帮助取得好成绩

  • 调整文字大小(12磅的字体是理想的)

  • 二值化图像,并使用图像处理算法,以去除噪声

此外,还建议花一些时间训练OCR引擎,以收到更好的效果在这个链接看到:Training Tesseract

我把你的共享和使用运行在他们的一些图像处理的2个图像LEADTOOLS SDK(免责声明:我是该公司的雇员),并且能够获得比使用处理过的图像更好的结果,但是由于原始图像不是最大的 - 它仍然不是100%。下面是我用来尝试和修复图像的代码:

//initialize the codecs class 
using (RasterCodecs codecs = new RasterCodecs()) 
{ 
    //load the file 
    using (RasterImage img = codecs.Load(filename)) 
    { 
     //Run the image processing sequence starting by resizing the image 
     double newWidth = (img.Width/(double)img.XResolution) * 300; 
     double newHeight = (img.Height/(double)img.YResolution) * 300; 
     SizeCommand sizeCommand = new SizeCommand((int)newWidth, (int)newHeight, RasterSizeFlags.Resample); 
     sizeCommand.Run(img); 

     //binarize the image 
     AutoBinarizeCommand autoBinarize = new AutoBinarizeCommand(); 
     autoBinarize.Run(img); 

     //change it to 1BPP 
     ColorResolutionCommand colorResolution = new ColorResolutionCommand(); 
     colorResolution.BitsPerPixel = 1; 
     colorResolution.Run(img); 

     //save the image as PNG 
     codecs.Save(img, outputFile, RasterImageFormat.Png, 0); 
    } 
} 

下面是这个过程的输出图像:

image1 processed image2 processed

+0

THX的答复,但为什么它不能识别所有的标签,例如第二张图片左上方的90,看起来很容易被读取 – Paul

+0

您可能需要训练引擎以获得更好的结果或使用更好的起始图像,以便您没有插入像素并调整它们的大小。 – hcham1

+0

什么是用于我的案例的最佳分割方法? – Paul