1 position = (30, 30)
2 text = "Some text including newline \n characters."
3 font_scale = 0.75
4 color = (255, 0, 0)
5 thickness = 3
6 font = cv2.FONT_HERSHEY_SIMPLEX
7 line_type = cv2.LINE_AA
8
9 text_size, _ = cv2.getTextSize(text, font, font_scale, thickness)
10 line_height = text_size[1] + 5
11 x, y0 = position
12 for i, line in enumerate(text.split("\n")):
13 y = y0 + i * line_height
14 cv2.putText(frame,
15 line,
16 (x, y),
17 font,
18 font_scale,
19 color,
20 thickness,
21 line_type)
22