标签:ttext for pre str enter win show numpy window
import cv2
import numpy as np
img = np.zeros([512, 512, 3], dtype=np.uint8)
for i in range(512):
for j in range(512):
img[i, j, :] = [i % 256, j % 256, (i + j) % 256]
cv2.rectangle(img, (200, 200), (400, 400), (0, 0, 255), 3)
cv2.circle(img, (300, 300), 100, (0, 255, 255), 3)
info = 'Hello World'
font_face = cv2.FONT_HERSHEY_COMPLEX
font_scale = 2
thickness = 2
text_size = cv2.getTextSize(info, font_face, font_scale, thickness)
print(text_size)
p_center = (int(512 / 2 - text_size[0][0] / 2), int(512 / 2 - text_size[0][1] / 2))
cv2.putText(img, info, p_center, font_face, font_scale, (0, 0, 0), thickness)
cv2.imshow('demo', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
标签:ttext for pre str enter win show numpy window
原文地址:https://www.cnblogs.com/yeran/p/10585498.html