【问题标题】:Emgcucv: Gray scale to threshold image not working for OCREmgu Cv:灰度到阈值图像不适用于 OCR
【发布时间】:2020-06-15 20:26:04
【问题描述】:

好的,我同意我是图像处理和 OCR 方面的菜鸟。我有我必须传递给 tesseract OCR 的彩色 Pan 卡。我在 [这里] 找到了以下线程。

(we are doing pan OCR, using tesseract but is not able to detect the details like name and pan number)。我知道我可能需要执行以下步骤。

  • 转换为灰色
  • 阈值
  • 查找轮廓
  • boundingRect

当我将彩色图像转换为灰度图像并将灰度图像转换为阈值时,我的灰度图像会变成完全黑色。 我玩弄了参数,但没有得到任何积极的结果。 那么有人可以帮我解决吗?

另一件事我想知道是否需要将彩色图像转换为灰度然后转换为 OCR 的阈值?或者我可以直接将彩色图像转换为阈值?

我忘了提到我正在使用 emguCV、Tesseract 和 Csharp。

我已经发布了上面的图片和下面的代码。

Image<Bgr, byte> imgInput; = new Image<Bgr, byte>(impath);
 Image<Gray, Byte> img2 = imgInput.Convert<Gray, Byte>(); 
Image<Gray, byte> imgout = imgInput.Convert<Gray, byte>().Not().ThresholdBinary(new Gray(50), new Gray(125));
VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint(); 
var blurredImage = imgout.SmoothGaussian(5, 5, 0, 0); 

CvInvoke.AdaptiveThreshold(imgout, imgout, 255, Emgu.CV.CvEnum.AdaptiveThresholdType.GaussianC, Emgu.CV.CvEnum.ThresholdType.Binary, 5, 45);

我们将不胜感激。

【问题讨论】:

  • 你能发布一些示例图像和代码吗?
  • 已更新。

标签: c# .net ocr tesseract emgucv


【解决方案1】:

我总是更喜欢使用 Cvinvoke 方法,而不是使用 Image 类中的阈值函数。您可以阅读下面的文档,但您可以使用以下代码根据自己的喜好进行调整。但请确保您的图像仍处于灰度状态。

CvInvoke.Threshold(img, output, 20, 50, ThresholdType.Binary);

http://www.emgu.com/wiki/files/3.0.0/document/html/54f2f6fb-b6dc-b974-16f4-f6b4bbb578d8.htm

如果它仍然看起来是黑色的,请尝试扩大阈值图像。尽管您的算法整体上不需要此方法,但它可以帮助您直观地了解问题所在。

http://www.emgu.com/wiki/files/3.2.0/document/html/25f5c3ea-ed93-fcbd-20b7-b046874f8fbe.htm

【讨论】:

  • 好的。我去做。在您回复之后,我每次都需要对 OCR 进行颜色到灰度到阈值转换时得出的结论。
猜你喜欢
  • 2012-11-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-20
相关资源
最近更新 更多