Zaar Hai
Zaar Hai

Reputation: 9859

drawing GoNoto emoji with opencv-python

I'm trying to print Noto Emoji font emojis over opencv image. Here is my test code adapted from here, however while the original code works fine, with noto emoji it doesn't output anything.

How to output emojis (with text) using opencv? (no PIL, etc.)

import cv2 as cv
import numpy as np

text = "🥳"
font_height = 40
thickness = 1

# load font and check text size
ft = cv.freetype.createFreeType2()
ft.loadFontData("NotoColorEmoji-Regular.ttf", 0)


# create empty white image (slightly bigger than text size)
img = np.ones((200, 500), dtype=np.uint8) * 255

# adjust text positioning
text_origin = (0, 50)

# add text to image
ft.putText(img, text, text_origin, font_height, (0, 0, 0), thickness, cv.LINE_8, True)

# display image
cv.imshow("", img)
cv.waitKey()

Upvotes: 0

Views: 74

Answers (0)

Related Questions