SomethingSomething
SomethingSomething

Reputation: 12226

OpenCV: Add text to image and get the bounding box of each letter

I read the documentation of the OpenCV function putText(). I could not find there any parameter or returned value that tells where each printed letter is located.

Is there some OpenCV API that gives this data while adding text to images, or maybe in some different library?

Upvotes: 1

Views: 1634

Answers (2)

lucians
lucians

Reputation: 2269

Take a look at my answer, the code may be interesting for your purpose: Detect space between text (OpenCV, Python)

It is used to recognize handwriting text and do ROI on given image.

Upvotes: 1

zindarod
zindarod

Reputation: 6468

You can calculate the width and height of the text you're putting on image by:

cv::Size textSize = cv::getTextSize(text, fontFace, fontScale, thickness, &baseline);

Check for example here.

Upvotes: 1

Related Questions