Actual combat | OpenCV+OCR implementation example of circular text recognition (detailed steps + Python/C++ source code)

Click the card below to follow the public account of "  OpenCV and AI Deep Learning "!

Visual/image heavy dry goods, delivered as soon as possible!

Guided reading

    This article will introduce the detailed steps and code demonstrations of using OpenCV+OCR to realize circular text recognition. (Source Public Account: OpenCV and AI Deep Learning)

Background introduction

    There are many special cases in the optical character recognition (OCR) scene, such as noise, dirt, tilt, deformation, etc., which will affect the recognition. Circular text is also one of them, we usually can't recognize them directly, but first convert the text to the horizontal direction, and then do the recognition. As shown below: 

If we identify directly, it is easy to identify failure, so what should we do? The following is a detailed introduction to the recognition steps of the characters in the above figure, which can also be regarded as the general steps of circular character recognition.

Detailed implementation steps

[1] Find the circular outline in the positioning diagram. The positioning circle can be realized by general Blob analysis or Hough circle transformation. Here, because the circle is relatively regular and distinct, the Hough circle transformation can be used directly. The code and detection effect are as follows:

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)gray = cv2.medianBlur(gray,3)circles = cv2.HoughCircles(gray,cv2.HOUGH_GRADIENT,1,100,\         param1=200,param2=30

Guess you like

Origin blog.csdn.net/stq054188/article/details/123952848