Skip to content

Instantly share code, notes, and snippets.

@nathzi1505
Created June 29, 2020 06:21
Show Gist options
  • Save nathzi1505/904ce98d09e5f5785eb98d99171ab214 to your computer and use it in GitHub Desktop.
Save nathzi1505/904ce98d09e5f5785eb98d99171ab214 to your computer and use it in GitHub Desktop.
Custom OpenCV font
import cv2
import numpy as np
img = np.zeros((100, 300, 3), dtype=np.uint8)
ft = cv2.freetype.createFreeType2()
ft.loadFontData(fontFileName='Ubuntu-R.ttf',
id=0)
ft.putText(img=img,
text='Quick Fox',
org=(15, 70),
fontHeight=60,
color=(255, 255, 255),
thickness=-1,
line_type=cv2.LINE_AA,
bottomLeftOrigin=True)
cv2.imwrite('image.png', img)
@thomasbergersen
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment