Live visualisation of various facial recognition algorithms.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
801 B

from PIL import ImageFont, ImageDraw, Image
import cv2
import numpy as np
text_to_show = "The quick brown fox jumps over the lazy dog"
# Load image in OpenCV
image = cv2.imread("Me.jpg")
# Convert the image to RGB (OpenCV uses BGR)
cv2_im_rgb = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
# Pass the image to PIL
pil_im = Image.fromarray(cv2_im_rgb)
draw = ImageDraw.Draw(pil_im)
# Draw the text
draw.text((10, 700), text_to_show, font=font)
# Get back the image to OpenCV
cv2_im_processed = cv2.cvtColor(np.array(pil_im), cv2.COLOR_RGB2BGR)
cv2.imshow('Fonts', cv2_im_processed)
cv2.waitKey(0)
cv2.destroyAllWindows()
def get_font(filename, size):
return ImageFont.truetype(filename, size)
def draw_text(img, ):