Draw text on an angle (rotated) in Python

Viewed 9140

I am drawing text onto a numpy array image in Python (using a custom font). Currently I am converting the image to PIL, drawing the text and then converting back to a numpy array.

import numpy as np
import cv2

from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont

char_image = np.zeros((200, 300, 3), np.uint8)

# convert to pillow image
pillowImage = Image.fromarray(char_image)
draw = ImageDraw.Draw(pillowImage)

# add chars to image
font = ImageFont.truetype("arial.ttf", 32)
draw.text((50, 50), 'ABC', (255, 255, 255), font=font)

# convert back to numpy array
char_image = np.array(pillowImage, np.uint8)

# show image on screen
cv2.imshow('myImage', char_image)
cv2.waitKey(0)

Is there anyway to draw the text on a given angle, ie. 33 degrees?

Rotating the image once the text has been drawn is not an option

2 Answers
Related