Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text labels in opencv image

Tags:

c++

opencv

label

I have got an image in opencv, and I want to add labels in the axis. Actually I want similar implementation as xlabel and ylabel matlab functions. How is it then, to add labels in both x and y axis of an image?

like image 269
Jose Ramon Avatar asked Jan 21 '14 11:01

Jose Ramon


People also ask

How do I show text in OpenCV?

Algorithm. Step 1: Import cv2 Step 2: Define the parameters for the puttext( ) function. Step 3: Pass the parameters in to the puttext() function. Step 4: Display the image.

How do you write text on a bounding box in Python?

putText() to overlay text information on top of a rectangle. For example, you can grab the contour coordinates, draw a rectangle, and put text on top of it by shifting it upwards.


1 Answers

If you have a string a label variable label image matrix img and positions x and y , you can do

putText(img, label, Point(x, y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);

The additional parameters are for font attributes.

like image 127
Jos Avatar answered Sep 27 '22 00:09

Jos