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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With