1

I'm -simply- setting a text value in Python's cv2 like this:

cv2.putText(image, landmark['type'], (x, x), cv2.FONT_HERSHEY_PLAIN, 1, (0,255,0), 1)

However, I have a third value: z. How can I rotate the text according to the z value?

Example of values:

'position': {
    'y': 404.0564,
    'x': 1122.9471,
    'z': 1.4555236
}

or

'position': {
    'y': 404.0564,
    'x': 1122.9471,
    'z': -12.8743
}
Bob van Luijt
  • 7,153
  • 12
  • 58
  • 101

1 Answers1

2

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.

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. (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? Using 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.

Community
  • 1
  • 1
t0b4cc0
  • 319
  • 4
  • 19