(image: np.ndarray, text: str, text_color: Tuple[int, int, int] = (0, 0, 0))
| 144 | # from src import ptp_utils |
| 145 | |
| 146 | def text_under_image(image: np.ndarray, text: str, text_color: Tuple[int, int, int] = (0, 0, 0)): |
| 147 | h, w, c = image.shape |
| 148 | offset = int(h * .2) |
| 149 | img = np.ones((h + offset, w, c), dtype=np.uint8) * 255 |
| 150 | font = cv2.FONT_HERSHEY_SIMPLEX |
| 151 | # font = ImageFont.truetype("/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf", font_size) |
| 152 | img[:h] = image |
| 153 | textsize = cv2.getTextSize(text, font, 1, 2)[0] |
| 154 | text_x, text_y = (w - textsize[0]) // 2, h + offset - textsize[1] // 2 |
| 155 | cv2.putText(img, text, (text_x, text_y ), font, 1, text_color, 2) |
| 156 | return img |
| 157 | |
| 158 | def view_images(images, save_path, base_count, num_rows=1, offset_ratio=0.02, step=None): |
| 159 | if type(images) is list: |
no outgoing calls
no test coverage detected