(image: np.ndarray, text: str, text_color: Tuple[int, int, int] = (0, 0, 0))
| 22 | |
| 23 | |
| 24 | def text_under_image(image: np.ndarray, text: str, text_color: Tuple[int, int, int] = (0, 0, 0)): |
| 25 | h, w, c = image.shape |
| 26 | offset = int(h * .2) |
| 27 | img = np.ones((h + offset, w, c), dtype=np.uint8) * 255 |
| 28 | font = cv2.FONT_HERSHEY_SIMPLEX |
| 29 | # font = ImageFont.truetype("/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf", font_size) |
| 30 | img[:h] = image |
| 31 | textsize = cv2.getTextSize(text, font, 1, 2)[0] |
| 32 | text_x, text_y = (w - textsize[0]) // 2, h + offset - textsize[1] // 2 |
| 33 | cv2.putText(img, text, (text_x, text_y ), font, 1, text_color, 2) |
| 34 | return img |
| 35 | |
| 36 | |
| 37 | def view_images(images, num_rows=1, offset_ratio=0.02): |
nothing calls this directly
no outgoing calls
no test coverage detected