简体   繁体   English

使用OpenCV C#检测图像中的文本块

[英]Detecting text blocks in images using opencv c#

Hello I want to extract text-blocks from images and pass it to ocr for better accuracy. 您好,我想从图像中提取文本块,并将其传递给ocr,以获得更好的准确性。 I have been searching on internet but not able to find suitable example for this. 我一直在互联网上搜索,但找不到适合的示例。 I am very new to this concept can anyone please help me out on the same? 我对这个概念很陌生,有人可以帮我吗?

在此处输入图片说明

在此处输入图片说明

This is what I want to achieve. 这是我想要实现的。 Note I am using EMGUCV for opencv and ocr. 注意我正在使用EMGUCV的opencv和ocr。 I want to scan receipt mostly. 我想主要扫描收据。 If you can help with that it would be great. 如果您可以提供帮助,那就太好了。

Is your text always in the same location? 您的文字总是在同一位置吗? If yes, you will have the location of the region of interest. 如果是,您将拥有感兴趣区域的位置。

//Create the rectangle
cv::Rect roi(0, 0, 500, 500);
//Create the cv::Mat with the ROI you need
cv::Mat imageRoi = image(roi)

Then you can send to the ocr this images 然后,您可以将此图片发送到ocr

You can threshold your image into a binary image. 您可以将图像阈值化为二进制图像。 After that you can use the morphologic operation "DILATE" (repeatedly) do join the letters. 之后,您可以使用形态运算“ DILATE”(反复地)加入字母。 When the letters are joined us the "findContours()" function to extract the contour and the bounding boy of it. 当字母加入我们后,“ findContours()”函数将提取轮廓和轮廓男孩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM