[英]How to rotate cv2.putText based on x, y and z axes in Python?
I'm -simply- setting a text value in Python's cv2 like this: 我-简单地-在Python的cv2中设置文本值,如下所示:
cv2.putText(image, landmark['type'], (x, x), cv2.FONT_HERSHEY_PLAIN, 1, (0,255,0), 1)
However, I have a third value: z
. 但是,我有第三个值:
z
。 How can I rotate the text according to the z
value? 如何根据
z
值旋转文本?
Example of values: 值示例:
'position': {
'y': 404.0564,
'x': 1122.9471,
'z': 1.4555236
}
or 要么
'position': {
'y': 404.0564,
'x': 1122.9471,
'z': -12.8743
}
z does not make much sense regarding the default usage of put text and the common x/y/z axis system for space since put text is being used for 2D images. 对于放置文本和空间的公共x / y / z轴系统的默认用法,z没有太大意义,因为将放置文本用于2D图像。
You need to use some image manipulation techniques and workout the algorithms you want to use depending on your requirements if z should reflect some kind of depth/height. 如果z应该反映某种深度/高度,则需要根据需要使用一些图像处理技术并锻炼要使用的算法。 (for example shrink the text in size if you just want it to look like its further away etc...)
(例如,如果只希望看起来更远,则缩小文本的大小,等等。)
If z for you means a simple rotation on the x/y plane then this question is a semantic duplicate of using putText() diagonally? 如果对您来说z意味着在x / y平面上的简单旋转,那么这个问题是对角使用putText()的语义重复吗? Using OpenCV .
使用OpenCV 。
The way to go is to create the text onto an empty image (just use alpha 0 on your image), then rotate it and add it on top of your base image. 解决方法是将文本创建到空白图像上(只需在图像上使用alpha 0),然后旋转 文本并将其添加到基础图像的顶部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.