Add text labels in opencv image

蹲街弑〆低调 提交于 2019-12-10 14:22:28

问题


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?


回答1:


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.




回答2:


You will need to get the size of the original image and then create a new image that is larger than the existing image from this, manually draw your Axis in this image, and label them using the putText function. Then insert the original image into the relevant portion of this new image.

Images dont have "Axis" as such, so your labels and axis will need to be part of the image!



来源:https://stackoverflow.com/questions/21256914/add-text-labels-in-opencv-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!